Skip to main content

LLM-powered BibTeX cleaner

Project description

BibTeX Cleaner

BibTeX Cleaner overview

BibTeX Cleaner is an LLM-powered BibTeX cleaning agent and command-line tool that integrates with DBLP, Semantic Scholar, and arXiv to automatically clean, normalize, enrich, and deduplicate BibTeX entries, while optionally standardizing citation keys and conference/journal information.

Features

  • Cleaning & Normalization: Standardizes BibTeX entries, fixes formatting, and ensures consistent fields.
  • Metadata Enhancement: Fetches accurate metadata from DBLP, Semantic Scholar, and ArXiv.
  • Conference Info: Updates venue information to official conference titles (e.g., "The 37th International Conference on Machine Learning (ICML)").
  • Custom Citation Keys: Generates citation keys based on customizable patterns (e.g., {author}{year}{shorttitle}).
  • Deduplication: Detects and removes duplicate entries.
  • Key Mapping JSON: Writes a JSON sidecar file that maps original BibTeX keys to their cleaned/deduplicated keys.
  • Missing Field Diagnostics: Prints a summary of entries that are missing required core fields (e.g., pages for @inproceedings) so you can fix them manually.

Installation

You can install the package via pip (or uv):

pip install bibtex-cleaner
# or
uv pip install bibtex-cleaner

Environment Variables

You need to create a .env file in your project root with your API key first:

OPENAI_API_KEY=your_api_key_here

Usage

Basic Cleaning

Clean a BibTeX file using default settings:

bib-cleaner input.bib output.bib

Configuration

The tool uses a bibtex_cleaner_config.yaml file for configuration. You can specify a custom config path with the --config flag.

Example bibtex_cleaner_config.yaml:

# BibTeX Cleaner Configuration

# LLM Settings
model: "gpt-4o-mini"

# Processing Settings
batch_size: 5
delay: 1.0
retry_count: 3

# Feature Flags
enhance_conferences: false  # Set to true for deep conference metadata enhancement
key_format: "{author}{year}{shorttitle}"

# Output Settings
json: false
output: "cleaned.bib"

CLI Options

bib-cleaner input.bib [output.bib] [--config path/to/config.yaml]

Key Mapping JSON Output

When you specify an output.bib file (either via CLI or config), the cleaner also generates a JSON file with the same stem:

  • Output: For output.bib, a output.json file is created alongside it.
  • Content: A mapping from original keys to their final keys and status, for example:
    • original key that was successfully cleaned and kept -> { "status": "success", "new_key": "<final_key>" }
    • original key that was detected as a duplicate and removed -> { "status": "duplicate", "new_key": "<canonical_key>" }
    • original key that failed cleaning -> { "status": "failed" }

This makes it easy to update citations in your LaTeX project after renaming and deduplication.

Diagnostics and Known Limitations

  • Missing field warnings: After cleaning, the CLI prints a short report to stderr listing entries that are missing important fields (for example, pages for @inproceedings, or journal/year for @article). These warnings do not stop the run; they are there to help you manually patch edge cases.
  • Upstream metadata gaps (e.g., pages): Sometimes DBLP / Semantic Scholar / arXiv do not provide complete metadata (most commonly page ranges for conference papers). In those cases the tool will warn about missing pages, but it will not fabricate values.

Citation Key Formatting

You can customize the citation key format in the configuration file using placeholders:

  • {author}: First author's surname
  • {year}: Publication year
  • {title}: Full sanitized title
  • {shorttitle}: First 3 meaningful words of title (default)
  • {veryshorttitle}: First 1 meaningful word of title
  • {mediumtitle}: First 5 meaningful words of title
  • {venue}: Venue/journal name
  • {doi}: DOI

Example: key_format: "{author}-{year}-{veryshorttitle}" -> Smith-2023-Attention

Contributor of This Project

This idea was born from discussions between Kai Kamijo, Mengyu Ye, Ryosuke Takahashi, and Taïga Gonçalves (in alphabetical order).

Ryosuke Takahashi implemented the core LangChain-based cleaning pipeline, and Taïga Gonçalves developed the initial conference-metadata resolver prototype. Mengyu Ye refactored and streamlined these components, added parallel cleaning support, integrated them into a unified Python package, and finalized the current release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bibtex_cleaner-0.1.0.tar.gz (5.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bibtex_cleaner-0.1.0-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file bibtex_cleaner-0.1.0.tar.gz.

File metadata

  • Download URL: bibtex_cleaner-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for bibtex_cleaner-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bc44a1bdd7c2c63e7e6863ea84445385157f3077a98e36f1e3da4cf39226d126
MD5 091206a72dc312ff4f42d07f6356f681
BLAKE2b-256 e1a7d867d0868eb986901386380d3f1065333df763ca77bbeb1208606bf6ad64

See more details on using hashes here.

File details

Details for the file bibtex_cleaner-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bibtex_cleaner-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e841a5dc8259b48f7d3abc1b87c4bcafc4169d7d215ff61b0e1b838e15766020
MD5 3cdb0f54fc3bb6227b24afec5ffd973a
BLAKE2b-256 4ef2bf6d78b29dd660a5406198b5fe149801ebe7668840206240a634905b9d7c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page