Skip to main content

transform arXiv papers into a single latex prompt for LLMs

Project description

PyPI version Tests License Changelog Downloads

A command-line tool to transform arXiv papers into a single LaTeX source that can be used as a prompt for asking LLMs questions about the paper. It downloads the source files, automatically finds the main tex file containing \documentclass, and flattens multiple files into a single coherent source by resolving \input and \include commands. The tool also provides options to remove LaTeX comments and appendix sections from the output (which can be useful to shorten the prompt).

Installation

pip install arxiv-to-prompt

Usage

# Display LaTeX source
arxiv-to-prompt 2303.08774

# Display LaTeX source without comments
arxiv-to-prompt 2303.08774 --no-comments

# Display LaTeX source without appendix sections
arxiv-to-prompt 2303.08774 --no-appendix

# Combine options (no comments and no appendix)
arxiv-to-prompt 2303.08774 --no-comments --no-appendix

# Copy to clipboard
arxiv-to-prompt 2303.08774 --copy # or -c

You can use either the arXiv ID (e.g., 2303.08774) or the full URL (e.g., https://arxiv.org/abs/2303.08774). It will automatically download the most recent version of the paper, so you don't need to specify the version. Downloaded papers are cached locally, so subsequent runs for the same paper will use the cached version without re-downloading.

Advanced Options

# Force re-download even if the paper is already cached
arxiv-to-prompt 2303.08774 --force-download

# Process a local folder containing TeX files (instead of downloading from arXiv)
arxiv-to-prompt --local-folder /path/to/tex/files

# Cache locking is on by default (120s timeout); increase/decrease it if needed
arxiv-to-prompt 2303.08774 --lock-timeout 300

# List all sections (with subsections indented)
arxiv-to-prompt 2307.09288 --list-sections
# Introduction
# Pretraining
#   Pretraining Data
#   Training Details
#     Training Hardware \& Carbon Footprint
#   ...

# Extract specific sections
arxiv-to-prompt 2307.09288 --section "Introduction" --section "Pretraining"

# Ambiguous names show a helpful error
arxiv-to-prompt 2307.09288 --section "Human Evaluation"
# Warning: 'Human Evaluation' is ambiguous. Found at:
#   - Fine-tuning > RLHF Results > Human Evaluation
#   - Appendix > Additional Details for Fine-tuning > Human Evaluation
# Use path notation to disambiguate.

# Use path notation when the same name appears multiple times
arxiv-to-prompt 2307.09288 --section "Fine-tuning > RLHF Results > Human Evaluation"

# Output figure file paths instead of LaTeX text
arxiv-to-prompt 2303.08774 --figure-paths

# Figure paths from main body only (exclude appendix and commented-out figures)
arxiv-to-prompt 2303.08774 --figure-paths --no-appendix --no-comments

# Output only the abstract text
arxiv-to-prompt 2303.08774 --abstract

# Expand \newcommand and related macro definitions inline
arxiv-to-prompt 2303.08774 --expand-macros

# Print token count (requires pip install 'arxiv-to-prompt[tokens]')
arxiv-to-prompt 2303.08774 --token-count
# 94253

# Combine with other flags to see how they affect token count
arxiv-to-prompt 2303.08774 --no-comments --no-appendix --token-count
# 62451

# Combine with the `llm` library from https://github.com/simonw/llm to chat about the paper
arxiv-to-prompt 1706.03762 | llm -s "explain this paper"

Python API

You can also use arxiv-to-prompt in your Python code:

from arxiv_to_prompt import process_latex_source

# Get LaTeX source with comments
latex_source = process_latex_source("2303.08774")

# Get LaTeX source without comments
latex_source = process_latex_source("2303.08774", keep_comments=False)

# Get LaTeX source without appendix sections
latex_source = process_latex_source("2303.08774", remove_appendix_section=True)

# Combine options (no comments and no appendix)
latex_source = process_latex_source("2303.08774", keep_comments=False, remove_appendix_section=True)

# Force re-download even if the paper is already cached
latex_source = process_latex_source("2303.08774", use_cache=False)

# Process LaTeX sources from a local folder (instead of downloading from arXiv)
latex_source = process_latex_source(local_folder="/path/to/tex/files")

# Get resolved figure file paths instead of LaTeX text
figure_paths = process_latex_source("2303.08774", figure_paths_only=True)

# Get only the abstract text
abstract = process_latex_source("2303.08774", abstract_only=True)

# Expand custom macro definitions inline
latex_source = process_latex_source("2303.08774", expand_macros_flag=True)

# Count tokens (requires pip install 'arxiv-to-prompt[tokens]')
from arxiv_to_prompt import count_tokens
token_count = count_tokens(latex_source)

Projects Using arxiv-to-prompt

Here are some projects and use cases that leverage arxiv-to-prompt:

  • arxiv-latex-mcp: MCP server that fetch and process arXiv LaTeX sources for precise interpretation of mathematical expressions in papers.
  • arxiv-tex-ui: chat with an LLM about an arxiv paper by using the latex source.
  • paper2slides: transform an arXiv paper into slides.
  • notations-cli: extract notation tables from arXiv papers using LLMs, generating searchable HTML documentation of mathematical symbols and their definitions.
  • ArXivToPrompt: iOS app that allows users to easily extract LaTeX source from arXiv papers on their iPhone and copy it to the clipboard for use with LLM apps.

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

arxiv_to_prompt-0.13.0.tar.gz (30.0 kB view details)

Uploaded Source

Built Distribution

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

arxiv_to_prompt-0.13.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file arxiv_to_prompt-0.13.0.tar.gz.

File metadata

  • Download URL: arxiv_to_prompt-0.13.0.tar.gz
  • Upload date:
  • Size: 30.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for arxiv_to_prompt-0.13.0.tar.gz
Algorithm Hash digest
SHA256 d154d7eb1cf099e60296477db9ab93ff3d668be35c40cb04905b85b53ed17eff
MD5 6e47571809e523e9483c173d11c83432
BLAKE2b-256 a61ba6d8ebc247f69cdfa8446b30fa21221bafff855c4f91ab15e70d9da8fad3

See more details on using hashes here.

Provenance

The following attestation bundles were made for arxiv_to_prompt-0.13.0.tar.gz:

Publisher: publish.yml on takashiishida/arxiv-to-prompt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arxiv_to_prompt-0.13.0-py3-none-any.whl.

File metadata

File hashes

Hashes for arxiv_to_prompt-0.13.0-py3-none-any.whl
Algorithm Hash digest
SHA256 35f995b99216f042ba4f9b9c4a1953a06dcc3a9d731aed58f7a14697e0169d04
MD5 49e246e76b4503da1f86a001e6c93680
BLAKE2b-256 3d3a6a557e35b96fa10a67d8312698c7995354c8227dcaf6cae54374f6628e04

See more details on using hashes here.

Provenance

The following attestation bundles were made for arxiv_to_prompt-0.13.0-py3-none-any.whl:

Publisher: publish.yml on takashiishida/arxiv-to-prompt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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