Uses LLMs to fix bibliography entries, because doing so manually is annoying.
FixTeX is a Python tool that automatically finds, verifies, and reformats BibTeX entries using:
- Google Scholar: To find and verify citations
- Selenium: To automate web scraping and select the most reputable sources
- OpenRouter API: To reformat citations using state-of-the-art LLMs
- Automatically searches for each BibTeX entry on Google Scholar
- Clicks "All N versions" to compare different versions of papers
- Selects the most reputable source (e.g., ICML over arXiv)
- Uses LLMs to reformat and standardize BibTeX entries
- Preserves original entry IDs while improving citation quality
- Clone the repository:
git clone https://github.com/MiniXC/fixtex.git
cd fixtex- Install dependencies:
pip install -r requirements.txt- Set up your OpenRouter API key:
cp .env.example .env
# Edit .env and add your OpenRouter API keyBasic usage:
python fixtex.py input.bibThis will create input_fixed.bib with the reformatted entries.
python fixtex.py input.bib -o output.bib # Specify output file
python fixtex.py input.bib -s ieee # Use IEEE citation style
python fixtex.py input.bib -k YOUR_API_KEY # Provide API key directly
python fixtex.py input.bib --no-headless # Show browser (for debugging)python fixtex.py example.bib- Python 3.7+
- Chrome/Chromium browser (for Selenium)
- OpenRouter API key (Get one here)
Create a .env file in the project directory with your OpenRouter API key:
OPENROUTER_API_KEY=your_api_key_here
OPENROUTER_MODEL=anthropic/claude-3.5-sonnet # Optional, defaults to claude-3.5-sonnetYou can also pass the API key directly via command line:
python fixtex.py input.bib -k YOUR_API_KEYFixTeX works with any model available on OpenRouter. Some recommended models:
anthropic/claude-3.5-sonnet(default, best quality)anthropic/claude-3-haiku(faster, lower cost)openai/gpt-4(high quality)openai/gpt-3.5-turbo(faster, lower cost)
If you encounter Chrome/ChromeDriver errors:
-
Ensure Chrome or Chromium is installed:
google-chrome --version # or chromium-browser --version -
ChromeDriver should be automatically managed by Selenium 4.x
-
Try running in non-headless mode to see what's happening:
python fixtex.py input.bib --no-headless
Google Scholar may rate-limit requests. The script includes delays between requests, but if you're processing many entries:
- Consider processing in smaller batches
- The script waits 3 seconds between entries by default
- Avoid running multiple instances simultaneously
If you encounter OpenRouter API errors:
- Verify your API key is correct
- Check your account has sufficient credits
- Some models may have usage limits or require specific permissions
- Parse: Reads the input BibTeX file
- Search: For each entry, searches Google Scholar using the title or author+year
- Select: Clicks "All versions" and uses an LLM to select the most reputable source by analyzing:
- Publication venue (conference, journal, preprint server)
- Peer-review status
- Venue reputation (ICML, NeurIPS, CVPR, ACL, IEEE, ACM, etc.)
- Publication type (full paper vs workshop vs preprint)
- Extract: Gets the BibTeX citation from the selected source
- Reformat: Uses an LLM (via OpenRouter) to clean and standardize the entry
- Output: Writes all entries to a new BibTeX file
Unlike traditional tools that rely on hardcoded rules, FixTeX uses an LLM to intelligently evaluate and select the most reputable version of each paper. The LLM considers:
- Peer-reviewed venues: Prioritizes top-tier conferences (ICML, NeurIPS, CVPR, ACL) and journals (IEEE, ACM, Springer)
- Publication quality: Distinguishes between full conference papers, workshop papers, and preprints
- Context awareness: Understands venue reputation within specific research domains
- Flexibility: Adapts to new venues and publication types without code changes
This approach is more robust and maintainable than keyword matching, and can make nuanced decisions based on the full context of each publication.
MIT License