This repo provides source-grounded retrieval infrastructure over a local corpus. It is not a chatbot application, and it is not asking agents to hand-parse PDFs.
When a user asks a question about the corpus, answer from the retrieval pipeline, not from memory and not from ad hoc file extraction.
Run commands from the repo root.
Prefer the project virtualenv executable because it has the repo's PDF and retrieval dependencies:
.venv/bin/rag status
.venv/bin/rag context "<question>" --top-k 8Use bare rag ... only after activating the virtualenv:
. .venv/bin/activate
rag status
rag context "<question>" --top-k 8If .venv/bin/rag does not exist, set up the environment first:
python3 -m venv .venv
. .venv/bin/activate
python -m pip install -e .
rag initIf the package is installed but the console script is unavailable, run the module with the virtualenv Python:
.venv/bin/python -m rag_pipeline.cli status
.venv/bin/python -m rag_pipeline.cli context "<question>" --top-k 8- Run
.venv/bin/rag statusto confirm the current database has documents, chunks, and vectors. - If there are zero documents, rebuild the intended corpus before answering.
- Run
.venv/bin/rag context "<question>" --top-k 8 --format jsonto get an LLM-ready context pack. - Check
answerability.statusbefore answering. Treatlow_confidenceandno_resultsas insufficient evidence. - Use only the returned
results[*].text,summary,keywords, and metadata for claims about the corpus. - Cite claims with the returned
citation_markdownfields when present. - If the context is insufficient, say what is missing and suggest a narrower or better query.
- If the first context pack is broad, run one narrower follow-up query using key terms found in the first results.
When the user wants to evaluate a new production corpus:
- Put files in
corpus/. - Run
.venv/bin/rag rebuild corpus --yes. - Run
.venv/bin/rag status. - Run
.venv/bin/rag evalafter updatingeval/questions.ymlfor the new corpus. - Use
.venv/bin/rag context "<question>"for downstream answering.
rag rebuild ... --yes deletes generated data and creates a clean database. It does not delete source files.
If the input produces zero documents, rebuild fails unless --allow-empty is supplied.
For an isolated trial rebuild, use:
.venv/bin/rag --data-dir data-production-test rebuild corpus --yes
.venv/bin/rag --data-dir data-production-test status
.venv/bin/rag --data-dir data-production-test eval --file eval/your-production-questions.yml
.venv/bin/rag --data-dir data-production-test context "<question>"If corpus/ only contains README.md, ask the user to add real source files before treating the corpus as production-ready.
- Prefer
rag contextover direct database queries for answering. - Use
rag searchwhen debugging ranking. - Use
rag inspect-doc <document_id>andrag inspect-chunk <chunk_id>for traceability. - Use returned
citation_markdownfields exactly when present. - Do not invent source links; use returned
source_link,page_link,source_markdown, orcitation_markdownfields. - Never assume the current corpus matches prior runs; always check
rag status.
- Do not run
pdftotext,fitz,pypdf, or custom PDF parsing to answer normal corpus questions. The pipeline already extracted, chunked, enriched, indexed, and linked the sources. - Do not use system Python for repo commands unless the virtualenv is unavailable and you are setting it up.
- Do not answer from a single file path just because a filename looks relevant. Retrieve ranked context first.
- Do not cite raw filenames when
citation_markdownis available. - Do not treat an old terminal result as current after
rag rebuild,rag reset, or a data-directory change.