MCPcopy Index your code
hub / github.com/Future-House/paper-qa

github.com/Future-House/paper-qa @v2026.03.18 sqlite

repository ↗ · DeepWiki ↗ · release v2026.03.18 ↗
801 symbols 4,045 edges 58 files 246 documented · 31%
README

PaperQA2

GitHub PyPI version tests License PyPI Python Versions

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


Quickstart

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?'

Example Output

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.

What is PaperQA2

PaperQA2 is engineered to be the best agentic RAG model for working with scientific papers. Here are some features:

  • A simple interface to get good answers with grounded responses containing in-text citations.
  • State-of-the-art implementation including document metadata-awareness in embeddings and LLM-based re-ranking and contextual summarization (RCS).
  • Support for agentic RAG, where a language agent can iteratively refine queries and answers.
  • Automatic redundant fetching of paper metadata, including citation and journal quality data from multiple providers.
  • A usable full-text search engine for a local repository of PDF/text files.
  • A robust interface for customization, with default support for all LiteLLM models.

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:

  1. Semantic Scholar
  2. Crossref
  3. Unpaywall
  4. Pydantic
  5. tantivy
  6. LiteLLM
  7. pybtex

PaperQA2 vs PaperQA

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.

PaperQA2 Goes CalVer in December 2025

Prior to December 2025 we used semantic versioning. This eventually led to confusion in two ways:

  1. Developers: should we major version bump based on settings or fundamental system capabilities? What if a bug fix requires breaking changes to the agent's behaviors?
  2. Speaking: should one use terminology from our publications (e.g. PaperQA1, PaperQA2) or the Git tags (e.g. v5) from this repo/package? When someone says "PaperQA" -- what version do they mean?

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.

What's New in Version 5 (aka PaperQA2)?

Version 5 added:

  • A CLI pqa
  • Agentic workflows invoking tools for paper search, gathering evidence, and generating an answer
  • Removed much of the statefulness from the Docs object
  • A migration to LiteLLM for compatibility with many LLM providers as well as centralized rate limits and cost tracking
  • A bundled set of configurations (read this section here)) containing known-good hyperparameters

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

What's New in December 2025?

The last four months since version 5.29.1 have seen many changes:

  • New modalities: tables, figures, non-English languages, math equations
  • More and better readers
  • Two new model-based PDF readers: Docling and Nvidia nemotron-parse
  • All PDF readers now can parse images and tables, report page numbers, support DPI
  • A reader for Microsoft Office data types
  • Multimodal contextual summarization
  • Media objects are also passed to the summary_llm during creation
  • Media objects' embedding space is enhanced using an enrichment_llm prompt
  • Simpler and performant HTTP stack
  • Consolidation from aiohttp and httpx to just httpx
  • Integration with httpx-aiohttp for performance
  • Context relevance is simplified and some assumptions were removed
  • Many minor features such as retrying Context creation upon invalid JSON, compatibility with fall 2025's frontier LLMs, and improved prompt templates
  • Multiple fixes in metadata processing via Semantic Scholar and OpenAlex, and metadata processing (e.g. incorrectly inferring identical document IDs for main text and SI)
  • Completed the deprecations accrued over the past year

PaperQA2 Algorithm

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

Installation

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.

CLI Usage

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

Core symbols most depended-on inside this repo

aadd
called by 44
src/paperqa/docs.py
aquery
called by 30
src/paperqa/docs.py
query
called by 29
src/paperqa/clients/__init__.py
from_name
called by 28
src/paperqa/settings.py
name_in_text
called by 21
src/paperqa/utils.py
aget_evidence
called by 21
src/paperqa/docs.py
from_coordinates
called by 17
packages/paper-qa-nemotron/src/paperqa_nemotron/api.py
parse_pdf_to_pages
called by 16
packages/paper-qa-pypdf/src/paperqa_pypdf/reader.py

Shape

Function 393
Method 288
Class 103
Route 17

Languages

Python100%

Modules by API surface

tests/test_paperqa.py124 symbols
src/paperqa/types.py63 symbols
src/paperqa/settings.py49 symbols
src/paperqa/utils.py40 symbols
src/paperqa/agents/search.py35 symbols
src/paperqa/llms.py29 symbols
tests/test_agents.py28 symbols
tests/test_clients.py27 symbols
src/paperqa/agents/tools.py24 symbols
tests/conftest.py23 symbols
packages/paper-qa-nemotron/tests/test_api.py20 symbols
src/paperqa/clients/client_models.py19 symbols

Dependencies from manifests, versioned

PyMuPDF1.24.12 · 1×
PyPDF3 · 1×
anyio
docling2.74 · 1×
docling-core2 · 1×

For agents

$ claude mcp add paper-qa \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact