Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

paper-qa

> DevOps
Open source

High accuracy RAG for answering questions from scientific documents with citations

9.0K stars0 likes1 views
WebsiteGitHub

About

High accuracy RAG for answering questions from scientific documents with citations

PaperQA2

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
    • Example Output
  • What is PaperQA2
    • PaperQA2 vs PaperQA
    • PaperQA2 Goes CalVer in December 2025
    • What's New in Version 5 (aka PaperQA2)?
    • What's New in December 2025?
    • PaperQA2 Algorithm
  • Installation
  • CLI Usage
    • Bundled Settings
    • Rate Limits
  • Library Usage
    • Agentic Adding/Querying Documents
    • Manual (No Agent) Adding/Querying Documents
    • Async
    • Choosing Model
      • Locally Hosted
    • Embedding Model
      • Specifying the Embedding Model
      • Local Embedding Models (Sentence Transformers)
    • Adjusting number of sources
    • Using Code or HTML
    • Multimodal Support
    • Using External DB/Vector DB and Caching
    • Creating Index
      • Manifest Files
    • Reusing Index
    • Using Clients Directly
  • Settings Cheatsheet
  • Where do I get papers?
  • Callbacks
    • Caching Embeddings
  • Customizing Prompts
    • Pre and Post Prompts
  • FAQ
    • How come I get different results than your papers?
    • How is this different from LlamaIndex or LangChain?
    • Can I save or load?
  • Reproduction
  • Citation

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.

bash
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+.

bash
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 s

Issues· 152 open

View all issuesOpen on GitHub
  • #399

    Dependency Dashboard

    Updated Sep 29, 2026
  • #1355

    SearchIndex.filecheck silently skips files previously marked as ERROR

    Updated Sep 29, 2026
  • #1275

    missing option for trapping exceptions during indexing

    enhancementUpdated Sep 16, 2026
  • #525

    Unit test that all configurations in `paperqa/configs/` don't repeat defaults

    enhancementgood first issueUpdated Aug 2, 2026
  • #1068

    Error Parsing PDF

    bugUpdated Jul 11, 2026
  • #1325

    Insecure pickle deserialization in PaperQA2 persisted search indexes can lead to code execution when querying a poisoned index

    bugUpdated May 7, 2026
  • #1317

    LiteLLM unnecessary memory usage when only trying to use paper metadata features

    Updated Apr 29, 2026
  • #1261

    TimeoutError: Timeout (60.00999999999663 secs): rate limit for key: ('client', 'gpt-5.2-2025-12-11')

    bugUpdated Apr 29, 2026
  • #1227

    Potential Deserialization Vulnerability in SearchIndex.index_files Using pickle.loads

    bugUpdated Apr 29, 2026
  • #1183

    To increase the speed of this library

    questionUpdated Apr 29, 2026

> Tags

Pythonairagsciencesearch

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 29, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理