langchain-arxiv-retriever
A LangChain retriever for the arXiv API.
pip install langchain-arxiv-retriever
from langchain_arxiv import ArxivRetriever
retriever = ArxivRetriever()
docs = retriever.invoke('ti:"attention is all you need"')
One Document per paper, in arXiv's relevance order. Three knobs, one metadata schema, typed errors, nothing silent.
Documentation: https://j1c.github.io/langchain-arxiv-retriever/
Usage
Abstracts (default)
page_content is the paper's abstract — fast, no downloads:
retriever = ArxivRetriever() # k=3 papers by default
docs = retriever.invoke("grokking transformers", k=10) # per-call override
Full text
page_content is the whole paper. Text comes from arXiv's native HTML rendering when available and from the PDF otherwise; metadata["source_format"] tells you which ("html" or "pdf"):
full = ArxivRetriever(full_text=True, k=2)
docs = full.invoke("2404.19756")
docs[0].metadata["content_length"] # 140369 — never silently cut
Need both modes? Instances are stateless and cheap — make two. For runtime switching inside a chain, use LangChain's standard configurable_fields mechanism on full_text.
Fetch by arXiv ID
A query consisting only of arXiv identifiers is fetched directly instead of searched:
retriever.invoke("1706.03762") # new-style ID
retriever.invoke("quant-ph/9508027") # old-style ID
retriever.invoke("2305.05665 2404.19756") # several at once
Query semantics
Queries go to the arXiv API verbatim. Everything in the arXiv API manual works: ti:, abs:, au:, cat:, all:, AND/OR/ANDNOT, quoted phrases.
Be aware that arXiv search is lexical, not semantic. Keyword-style queries retrieve well; conversational questions don't.
Metadata schema
Identical keys in both modes, snake_case, JSON-serializable:
| Key | Type | Notes |
|---|---|---|
entry_id |
str |
Canonical abs URL, e.g. http://arxiv.org/abs/2305.05665v2 (also the Document.id) |
arxiv_id |
str |
Short ID with version, e.g. 2305.05665v2 |
version |
int | None |
Parsed from the ID |
title, summary |
str |
summary is the abstract, in both modes |
authors |
list[str] |
|
published, updated |
str |
ISO dates: first submission / this version |
primary_category |
str |
e.g. cs.LG |
categories |
list[str] |
|
doi, journal_ref, comment |
str | None |
None when absent |
pdf_url |
str | None |
|
content_length |
int |
Length of page_content in chars |
token_estimate |
int |
content_length // 4 |
truncated |
bool |
True only if max_content_chars fired |
source_format |
str |
"abstract", "html", or "pdf" |
Why not langchain-community's ArxivRetriever?
This package exists because langchain-community has been deprecated and is no longer maintained, and uses deprecated functions from arxiv-py. Lastly, the community implementation has accumulated footguns:
langchain-community |
langchain-arxiv-retriever |
|
|---|---|---|
| "Full documents" mode | Silently truncated at 4,000 chars (doc_content_chars_max default) — about a page and a half |
Whole text by default; truncation only if you opt in, and then it's flagged in metadata |
| Full-text source | PDF only, parsed with PyMuPDF (AGPL) | arXiv's native HTML when it exists (most papers since Dec 2023), pypdf (BSD) fallback — permissive licenses only |
arXiv field syntax (ti:, cat:, …) |
Strips : and - from queries in full-text mode, breaking it |
Queries pass through verbatim |
| Query length | Silently cut at 300 chars | Untouched |
| Metadata | Different keys, casing, and value types per mode | One snake_case schema, both modes |
| Errors | Returned as a fake Document ("Arxiv exception: …") that flows into your prompt |
Raised, always, as typed exceptions |
| API traffic | Fetches 100 results per request regardless of k; re-downloads PDFs to disk on every call |
Fetches what k needs; downloads stay in memory; nothing written to disk |
Metadata
Release files for langchain-arxiv-retriever 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| langchain_arxiv_retriever-1.0.0.tar.gz | 530.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_arxiv_retriever-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 542.3 kB
Release files / langchain_arxiv_retriever-1.0.0.tar.gz
| Download URL | langchain_arxiv_retriever-1.0.0.tar.gz |
|---|---|
| Size | 530.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a99107f02ad7849557373dceff0d8a29bd311a244f9d7106b55769d4ba43ddc3
|
|
BLAKE2b-256 checksum How to use checksums |
3e9ec408a585669fc3d808c1e25ce97c48bd01452b293c03edb8dfa53f0ad0ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / langchain_arxiv_retriever-1.0.0-py3-none-any.whl
| Download URL | langchain_arxiv_retriever-1.0.0-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7e158a97af655630532dc961e313bf7559c0f1ea3b3aa93008715254d2754b9f
|
|
BLAKE2b-256 checksum How to use checksums |
073a3ff553da16dc391ed5369a3520d48d72e0c7196925cbf262fd60533f863a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for langchain-arxiv-retriever 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.