Pandion
Retrieval pipelines you can inspect, step by step.
Pandion parses your documents, cleans and chunks them, embeds and stores them, then searches, reranks and answers questions. Every step is a strategy you can swap, and every step tells you what it did. Each result is cached under a hash of its settings, so the same files with the same settings are never processed twice.
Pandion is named after the osprey, which spots a fish under the water and dives to retrieve it. It is the engine of RAG Playground, a web app that shows every step of a pipeline on a PDF.
Install
Pandion needs Python 3.13.
pip install "pandion[pdfium,lancedb,local]"
The base install is small. Parsers, stores and models are extras, and a step whose extra is missing tells you which one to install:
| Extra | What it brings | Needed by |
|---|---|---|
pdfium |
pypdfium2 | the fast pdfium parser |
docling |
Docling and its OCR engine | the docling parser, for layout, tables and scans |
lancedb |
LanceDB and pyarrow | the index, and the dense, bm25 and hybrid_rrf search |
qdrant |
qdrant-client | the qdrant index: Qdrant in a folder or on a server |
sql |
SQLAlchemy | the sql conversation store: SQLite, Postgres, MySQL or SQL Server |
local |
sentence-transformers and torch | the local embedders, and the mmr and cross_encoder rerankers |
anthropic |
the Anthropic SDK | llm_rewrite, llm_rerank and chat with Claude |
openai |
the OpenAI SDK | the same steps with OpenAI, OpenRouter or a compatible server |
files |
fsspec (plus gcsfs or s3fs for a bucket) | FilesSource, sync from a source |
pandion install pipeline.yaml installs the extras a pipeline file needs.
Quick start
from pandion import Pipeline
p = Pipeline(
path="./my-index",
parse="pdfium",
chunk={"use": "recursive_character", "chunk_size": 400, "chunk_overlap": 40},
embed="bge-small-en-v1.5",
store="lancedb",
search="hybrid_rrf",
answer="search",
)
p.index.run("report.pdf")
print(p.ask("What does the report recommend?").text)
The embedder downloads once, on first use. After that, a second p.index.run on the
same file finds every step already stored and reuses it.
What you can do
- Run one step on its own, with no pipeline and no cache:
pandion.parse(pdf, use="pdfium"),pandion.clean(...),pandion.chunk(...). - Write a pipeline three ways: as a YAML file (
Pipeline.from_file("pipeline.yaml")), as a dict per step, or with classes such asfrom pandion.parse import Docling. The three give the same pipeline and the same cache. - Build and update an index:
p.index.run(files)indexes them, andp.index.sync(folder)adds, changes and removes files to match a folder. - Search:
p.retrieve(question)runs the rewrite, search and rerank steps and returns each step's result as well as the hits. - Ask:
p.ask(question)returns the pieces found, or an answer from a chat model that cites them. - Evaluate and compare:
pandion.evaluate(p, "questions.json")scores a pipeline on a question set and says where each miss was lost, andpandion.compareruns one stage with several settings and names the best. - Questions written for you:
pandion.evaluation.write_questions(doc, model=...), orpandion questions report.pdf --model ..., has a chat model write a checked question set. - Start from a template:
pandion.compose_template("tables", "precision")joins an index template (how a kind of document is indexed) and a query template (how a kind of question is searched and answered) into a pipeline, andpandion.list_templates()lists them. See Templates. - Write your own strategy for any stage, register it with
@registerfrompandion.extend, and use it by name, from code, fromplugins:in a pipeline file, or with--pluginson the command line. The worked example writes one for every stage.
Start a project
pandion init my-project asks which index and query template to use, then writes a
folder you can run straight away: pipeline.yaml, run.py, requirements.txt, a
README and an empty docs/ for your documents. In code, pandion.new_project(folder, pipeline)
writes the same folder for any pipeline. See
Start a project.
pandion init my-service --serve writes a project for a server instead, with a Dockerfile,
serve.py, policy.py and a quality test; see
A project to serve.
Use Pandion from the command line
pandion validate pipeline.yaml, pandion index pipeline.yaml report.pdf, pandion ask pipeline.yaml "...",
pandion models pull pipeline.yaml (downloads the public model weights a pipeline needs, for example at Docker build time), pandion forget-user alice --url-env VAR --yes (deletes one user's conversations, memories and traces from a conversation store), pandion trace TRACE_ID --url-env VAR and pandion report --since 7d --url-env VAR (read the traces a conversation store kept), pandion review --url-env VAR (list the flagged and thumbs-down traces; with --evaluate [--only NAME] [--sample 2%] [--judge] it scores the stored traces with your @online_evaluator plugins and, with --judge, a relevance judge, in a batch you schedule; --promote TRACE_ID --questions q.json adds a trace to a question set), and pandion sync pipeline.yaml (reads the source: block of the file, needs pandion[files]
for the files source, prints one JSON summary line and exits non-zero when a document was
left out): the same pipeline, from the command line. pandion eval pipeline.yaml questions.json --record-baseline base.json saves a baseline with the platform and models it was made with, and
--baseline base.json then fails when any category newly misses a question (asked once more
first when a step can differ between runs). Before it searches, pandion eval exits 1 on a
question whose expected passage is no longer in the parsed documents. --judge (off by default,
costs model calls) also grades each answer against the question's expected answer, and
--judge-gate fails a baseline comparison when the mean correctness fell more than 0.05. A question with a history (a follow-up) is rewritten first with claude-haiku-4-5, which needs ANTHROPIC_API_KEY; without it the question is searched as written and counted in rewrites_failed. Follow-ups are their own gated category, follow-up. See
the pandion command.
Chat turns
pandion.chat_turn.chat_turn(p, store, user_id=..., question=...) answers one turn of a
conversation kept in a conversation store (pandion[sql]). A follow-up is first rewritten
into a question that stands alone, using the running summary and the last turns, and the
answer step is asked only that question, so history gives meaning and only the sources give
facts. fold_summary folds older turns into the summary; run it after replying. With
ChatSettings(memory=True) (off by default), remember keeps a user's short facts and they
help the rewrite only, never the answer. All are
Provisional. See A chat turn
and chat_turn.py.
When the store is also a TraceStore (the sql store is), each answered turn leaves one
trace record: question, answer, grounding label, flags, sources, stage times and cost, plus any
feedback from the user (give_feedback). It follows
the conversation's retention. See Traces.
Answers are made safer by default: sources are fenced in the prompt as untrusted data, and
chat_turn removes links and images from a reply unless a source holds the same address
(ChatSettings(strip_urls=False) turns that off). See
Answer safety.
Extend Pandion
These are the extension points and how steady each one is. Pandion is 0.x, and a Stable contract changes only after a deprecation in the changelog. Each recipe below is taken from an example that the repository's tests run.
| Extension point | Level | Tested example |
|---|---|---|
| Source | Stable | zip_source.py |
| Route check | Stable | route.py |
| Access rule | Stable | owner_access.py |
| Index store | Stable | json_file_store.py |
| Conversation store | Stable | dict_conversation_store.py |
| Policy | Stable | policy_example.py |
| Step plugins, executor events, online evaluators | Provisional |
Import the module before you build the pipeline (or list it under plugins: in the
pipeline file), so its name is registered.
A source lists documents and reads one on request. index.sync(source) reads only
what is new or changed, so give each entry a version that changes when its content does.
The example is registered as zip:
import zip_source # registers "zip"
from pandion.document_sources import get_source
report = pipeline.index.sync(get_source("zip", location="docs.zip"))
In the pipeline file, source: {use: zip, location: docs.zip} and pandion sync do the same.
A route check looks at a DocumentInfo and returns True or False. The example is
is_invoice. Register it with
@route_check("is_invoice", ...) and use it as when: {use: is_invoice}.
An online evaluator takes one stored TraceRecord and returns the outputs it declared (float, str or bool). The example is
answer_length. Register it with @online_evaluator("answer_length", version="1", outputs={...}); pandion review --evaluate
saves its results on each trace as answer_length@1.<output>, and pandion report averages them. It is Provisional.
An access rule takes a DocumentInfo and returns role names, or None for no
opinion. The example, team_from_path, gives legal/a.pdf the role legal. Use it as
access: {rules: [team_from_path]}. A rule that fails leaves the document visible to nobody.
An index store keeps the rows of an index. Apply the filter before you rank; a row with empty
roles never matches a roles filter. The example is registered as json_file, proven with
pandion.testing.store_conformance, and used from code:
from pandion.index_store import get_store
store = get_store("json_file", {"folder": "my-index"})
A registered store reaches pipeline.yaml only through an index step, because
StoreIndex is not a Stable export.
A Policy (in pandion-api) is its one place for a site's rules. See the pandion-api README.
Learn more
- The guide: every step, setting and error.
- Examples: index, sync, search, ask, the three ways to write a pipeline, your own strategy for every stage, and a source, access rule and index store of your own.
- RAG Playground: try the same pipelines in the browser.
- Changelog: what changed in each release.
License
MIT. See LICENSE.
Metadata
Release files for pandion 0.8.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 | Actions |
|---|---|---|---|---|
| pandion-0.8.0.tar.gz | 597.4 kB | With provenance | Details for pandion-0.8.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pandion-0.8.0-py3-none-any.whl | Python 3 | none | any | Details for pandion-0.8.0-py3-none-any.whl |
Total release size: 975.0 kB
Release files / pandion-0.8.0.tar.gz
| Download URL | pandion-0.8.0.tar.gz |
|---|---|
| Size | 597.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2022cc9910d576c0990729ab583cf03ecc3e91e64344c5a0fe392fdbb52d3f66
|
|
BLAKE2b-256 checksum How to use checksums |
432cf1fd582c6b229646f8b1ddec549d14fb059977532dc19d8cb40f903d339c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logRelease files / pandion-0.8.0-py3-none-any.whl
| Download URL | pandion-0.8.0-py3-none-any.whl |
|---|---|
| Size | 377.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ada3d8a3be3d7eac2d72dbf328443be1befd8f8fd330116eac0cd9002f2351dd
|
|
BLAKE2b-256 checksum How to use checksums |
4337417da4fbbeb8d294c7759bfcd7504b4814b8e88a11f42d05cf23063044e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logSecurity for pandion 0.8.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pandion-0.8.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logA 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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.