# PaperQA

> High-accuracy, citation-backed RAG over scientific papers and documents

- Category: Retrieval & Knowledge (RAG) / RAG Frameworks & Platforms
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/Future-House/paper-qa
- Website: https://futurehouse.gitbook.io/futurehouse-cookbook
- Canonical page: https://ai-tldr.dev/tools/paperqa/

## In short

PaperQA2 is a Python library for retrieval augmented generation (RAG) on PDFs, text files, Microsoft Office documents, and source code, with a focus on scientific literature. It answers questions with grounded responses that include in-text citations pointing back to the exact pages they came from. It sits in the RAG Frameworks & Platforms category of the Retrieval & Knowledge (RAG) tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

PaperQA2 is a Python library for retrieval augmented generation (RAG) on PDFs, text files, Microsoft Office documents, and source code, with a focus on scientific literature. It answers questions with grounded responses that include in-text citations pointing back to the exact pages they came from.

It is built for researchers, scientists, and developers who need answers they can trust and check, rather than unattributed summaries. It fetches paper metadata from providers like Semantic Scholar, Crossref, and Unpaywall, including citation counts and retraction checks, and builds a local full-text search index over your document folder.

As a RAG framework, PaperQA2 supports an agentic workflow where a language agent can iteratively refine its queries and answers. By default it uses OpenAI embeddings and models with a NumPy vector store, but it works with any LiteLLM-supported provider, so you can swap in other closed- or open-source models.

## What it does

- Grounded answers with in-text citations tied to specific document pages
- Works with PDFs, text files, Microsoft Office documents, and source code
- Automatic paper metadata fetching, including citation counts and retraction checks, from multiple providers
- Local full-text search index over your own repository of files
- Agentic RAG: a language agent can iteratively refine queries and answers
- Model flexibility through LiteLLM, with default OpenAI embeddings and a NumPy vector store

## Getting started

Install the package, drop some papers in a folder, then ask a question from the command line. PaperQA2 reads from your OpenAI API key by default, so set that in your environment first.

1. Install PaperQA2

   Install from PyPI with pip. It requires a supported Python version (see the PyPI badge in the README).

```bash
pip install paper-qa
```

2. Add papers and ask a question

   Put your PDFs in a folder, move into it, then use the pqa CLI to ask a question. PaperQA2 fetches metadata, indexes the documents, and answers with citations.

```bash
mkdir my_papers
curl -o my_papers/PaperQA2.pdf https://arxiv.org/pdf/2409.13740
cd my_papers
pqa ask 'What is PaperQA2?'
```

## When to use it

- Asking questions across a folder of research papers and getting answers with verifiable page-level citations
- Summarizing scientific literature for a review while keeping each claim traceable to its source
- Detecting contradictions between papers in a collection
- Building a local, searchable knowledge base over your own PDFs and documents without sending them to an external service
