PaperQA2 is a package for doing high-accuracy retrieval augmented generation (RAG) on PDFs, text files, Microsoft Office documents, and source code files, with a focus on the scientific literature. See our recent 2024 paper to see examples of PaperQA2's superhuman performance in scientific tasks like question answering, summarization, and contradiction detection.
Table of Contents
In this example we take a folder of research paper PDFs, magically get their metadata - including citation counts with a retraction check, then parse and cache PDFs into a full-text search index, and finally answer the user question with an LLM agent.
pip install paper-qa
mkdir my_papers
curl -o my_papers/PaperQA2.pdf https://arxiv.org/pdf/2409.13740
cd my_papers
pqa ask 'What is PaperQA2?'
Question: Has anyone designed neural networks that compute with proteins or DNA?
The claim that neural networks have been designed to compute with DNA is supported by multiple sources. The work by Qian, Winfree, and Bruck demonstrates the use of DNA strand displacement cascades to construct neural network components, such as artificial neurons and associative memories, using a DNA-based system (Qian2011Neural pages 1-2, Qian2011Neural pages 15-16, Qian2011Neural pages 54-56). This research includes the implementation of a 3-bit XOR gate and a four-neuron Hopfield associative memory, showcasing the potential of DNA for neural network computation. Additionally, the application of deep learning techniques to genomics, which involves computing with DNA sequences, is well-documented. Studies have applied convolutional neural networks (CNNs) to predict genomic features such as transcription factor binding and DNA accessibility (Eraslan2019Deep pages 4-5, Eraslan2019Deep pages 5-6). These models leverage DNA sequences as input data, effectively using neural networks to compute with DNA. While the provided excerpts do not explicitly mention protein-based neural network computation, they do highlight the use of neural networks in tasks related to protein sequences, such as predicting DNA-protein binding (Zeng2016Convolutional pages 1-2). However, the primary focus remains on DNA-based computation.
PaperQA2 is engineered to be the best agentic RAG model for working with scientific papers. Here are some features:
By default, it uses OpenAI embeddings and models with a Numpy vector DB to embed and search documents. However, you can easily use other closed-source, open-source models or embeddings (see details below).
PaperQA2 depends on some awesome libraries/APIs that make our repo possible. Here are some in no particular order:
We've been working hard on fundamental upgrades for a while and mostly followed SemVer, until December 2025. Meaning we've incremented the major version number on each breaking change. This brings us to the current major version number v5. So why call is the repo now called PaperQA2? We wanted to remark on the fact though that we've exceeded human performance on many important metrics. So we arbitrarily call version 5 and onward PaperQA2, and versions before it as PaperQA1 to denote the significant change in performance. We recognize that we are challenged at naming and counting at FutureHouse, so we reserve the right at any time to arbitrarily change the name to PaperCrow.
Prior to December 2025 we used semantic versioning. This eventually led to confusion in two ways:
To resolve these confusions, in December 2025,
we moved to calendar versioning.
The developer burden is diminished because
we're basically removing guarantees of backwards compatibility across releases
(as CalVer is ZeroVer bound to dates).
It solves the "speaking" issue because Git tags are now
quite different from publication terminology (e.g. PaperQA2 vs v2025.12.17).
When someone says "PaperQA" it will just refer to the system,
not a particular snapshot of agentic behaviors.
When someone says "PaperQA2" it will refer to paper-qa>=5,
which applies to both SemVer tags v5.0.0 and the new CalVer tags v2025.12.17.
This switch is backwards compatible for version 5's SemVer, as the year 2025 is strictly greater than major version 5.
Version 5 added:
pqaDocs objectNote that Docs objects pickled from prior versions of PaperQA are incompatible with version 5,
and will need to be rebuilt.
Also, our minimum Python version was increased to Python 3.11.
The last four months since version 5.29.1 have seen many changes:
summary_llm during creationenrichment_llm promptaiohttp and httpx to just httpxhttpx-aiohttp for performanceContext relevance is simplified and some assumptions were removedContext creation upon invalid JSON,
compatibility with fall 2025's frontier LLMs,
and improved prompt templatesTo understand PaperQA2, let's start with the pieces of the underlying algorithm. The default workflow of PaperQA2 is as follows:
| Phase | PaperQA2 Actions |
|---|---|
| 1. Paper Search | - Get candidate papers from LLM-generated keyword query |
| - Chunk, embed, and add candidate papers to state | |
| 2. Gather Evidence | - Embed query into vector |
| - Rank top k document chunks in current state | |
| - Create scored summary of each chunk in the context of the current query | |
| - Use LLM to re-score and select most relevant summaries | |
| 3. Generate Answer | - Put best summaries into prompt with context |
| - Generate answer with prompt |
The tools can be invoked in any order by a language agent. For example, an LLM agent might do a narrow and broad search, or using different phrasing for the gather evidence step from the generate answer step.
For a non-development setup, install PaperQA2 (aka version 5) from PyPI. Note version 5 requires Python 3.11+.
pip install paper-qa>=5
For development setup, please refer to the CONTRIBUTING.md file.
PaperQA2 uses an LLM to operate,
so you'll need to either set an appropriate API key environment variable
(i.e. export OPENAI_API_KEY=sk-...)
or set up an open source LLM server (i.e. using llamafile.
Any LiteLLM compatible model can be configured to use with PaperQA2.
If you need to index a large set of papers (100+),
you will likely want an API key for both
Crossref
and Semantic Scholar,
which will allow you to avoid hitting public rate limits using these metadata services.
Those can be exported as CROSSREF_API_KEY and SEMANTIC_SCHOLAR_API_KEY variables.
The fastest way to test PaperQA2 is via the CLI. First navigate to a directory with some papers and use the pqa cli:
pqa ask 'What is PaperQA2?'
You will see PaperQA2 index your local PDF files, gathering the necessary metadata for each of them (using Crossref and Semantic Scholar), search over that index, then break the files into chunked evidence contexts, rank them, and ultimately generate an answer. The next time this directory is queried, your index will already be built (save for any differences detected, like new added papers), so it will skip the indexing and chunking steps.
All prior answers will be indexed and sto
$ claude mcp add paper-qa \
-- python -m otcore.mcp_server <graph>