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

Basic usage:

# Display LaTeX source with comments
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

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

# Copy to clipboard
arxiv-to-prompt 2303.08774 | pbcopy

# 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"

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 latest version of the paper, so you don't need to specify the version.

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)

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

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.
  • 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.

If you're using arxiv-to-prompt in your project, please submit a pull request to add it to this list!

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.4.0.tar.gz (11.7 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.4.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: arxiv_to_prompt-0.4.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.1

File hashes

Hashes for arxiv_to_prompt-0.4.0.tar.gz
Algorithm Hash digest
SHA256 73790ace12b3dc7364616fb5ebf3fa8c31aafe930a4f7d2a1c37ce5745957f37
MD5 7c1904e44a5dac110fb27bfa1cc4f804
BLAKE2b-256 5f6cb775cd07012f3c6cd7988d2aaebe686f8a42c9fe97523f7bd104c57c71aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for arxiv_to_prompt-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 80d113a5d7a3083d54161c6462f8d358bdaa7306cb25de506f35a79e36e775af
MD5 3c9a7958f1bf270045d451818534b9c4
BLAKE2b-256 5732a04e541da7b821ea049ca7dc8d21b44756c8ab75ad25c0ef12524bde6470

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