fix: prevent topic drift in writeup and harden LaTeX/plotting pipeline#88
Open
YihanJIANG-lab wants to merge 1 commit intoSakanaAI:mainfrom
Open
fix: prevent topic drift in writeup and harden LaTeX/plotting pipeline#88YihanJIANG-lab wants to merge 1 commit intoSakanaAI:mainfrom
YihanJIANG-lab wants to merge 1 commit intoSakanaAI:mainfrom
Conversation
A collection of fixes for the paper generation pipeline: ## Topic drift prevention (perform_icbinb_writeup.py) - Add get_topic_anchor_terms(): extract key terms from idea.json Name/Title/ Short Hypothesis to serve as topic anchors - Add latex_matches_idea(): verify generated LaTeX contains at least 2 anchor terms, preventing the LLM from drifting to unrelated topics - Writeup now retries once with explicit correction prompt if first draft drifts away from the original research idea - Add topic anchor reminder to each reflection round prompt - Add explicit anti-drift instruction in the writeup system prompt ## LaTeX compilation hardening (perform_icbinb_writeup.py) - Increase compile_latex timeout from 30s to 300s for complex papers - Add encoding='utf-8', errors='replace' to subprocess calls to prevent encoding crashes on Windows - Skip PDF compilation gracefully when pdflatex/bibtex not available - Handle FileNotFoundError for missing LaTeX binaries - Check reflection PDF exists before attempting VLM review - Fix summary file path resolution: auto-discover run log dir instead of hardcoding 'logs/0-run/' ## Review encoding fix (perform_llm_review.py) - Add encoding='utf-8' to load_review() json.load - Add errors='replace' to paper text file reading ## Plotting robustness (perform_plotting.py) - extract_code_snippet() now returns empty string instead of raw LLM text when no code block is found, preventing writing natural language as Python - Add validate_python_snippet() using compile() to catch syntax errors before running aggregator scripts - Reduce target figure count guidance (4-6 instead of ~12) for more reliable generation on resource-constrained setups - Add guidance to keep scripts compact and prefer robust numeric plots
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
During long paper generation runs, the LLM tends to drift away from the original research topic. This PR adds:
latex_matches_idea()validation to detect and retry drifted content