ContextWalker
ContextWalker is a local PDF question-answering system that combines contextual chunking, semantic retrieval, BM25 keyword retrieval, Reciprocal Rank Fusion, neural reranking, and agent-driven exploration of neighboring chunks.
This repository is a modular reorganization of agent_sample.py. Its retrieval
and answering logic is intentionally unchanged.
How it works
PDF extraction
-> document summary
-> overlapping chunks
-> LLM-generated context for every chunk
-> FAISS vector search + BM25 keyword search
-> Reciprocal Rank Fusion
-> cross-encoder reranking
-> top five starting chunks
-> agent explores neighboring chunks
-> supported answer
See the architecture guide for a module-by-module explanation.
Requirements
- Python 3.9 or newer
- Ollama running locally at
http://localhost:11434 - The Ollama model
gpt-oss:20b - A PDF named
data.pdfin the directory from which ContextWalker is run
Installation
Install the published package from PyPI:
python -m pip install contextwalker
ollama pull gpt-oss:20b
For local development from a cloned repository:
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e .
ollama pull gpt-oss:20b
Place the document at data.pdf, start Ollama, and run:
contextwalker
Alternatively:
python -m contextwalker
Type exit, quit, or q to stop the interactive prompt.
Runtime cache
The first run creates rag_cache/document_summary.txt and
rag_cache/contextual_chunks.json. Later runs reuse the contextual chunks but
rebuild the in-memory FAISS and BM25 indexes. Delete rag_cache/ when changing
the PDF or chunk-generation settings.
Configuration
The original constants are preserved in src/contextwalker/config.py:
- chunks: 900 characters with 150 characters of overlap
- vector candidates: 60
- BM25 candidates: 60
- fused candidates: 100
- final reranked candidates: 5
- neighbor radius: at most 5 chunks
- agent reasoning steps: at most 25
- tool calls per question: at most 40
Development
Validate imports and syntax without starting the heavyweight models:
python -m compileall -q src
The original agent_sample.py remains outside this repository and has not been
modified.
Release maintainers should follow the publishing guide for the PyPI release process.
Metadata
Release files for contextwalker 0.1.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 | |
|---|---|---|---|
| contextwalker-0.1.0.tar.gz | 14.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| contextwalker-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.1 kB
Release files / contextwalker-0.1.0.tar.gz
| Download URL | contextwalker-0.1.0.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c5abc92676b549d9e551186f91a94d33287002fca50c8a77d40bd90a5e7b3830
|
|
BLAKE2b-256 checksum How to use checksums |
37c412cbcd9a6ec1e1473cf9692b3cffaed50f33fb0ad04131f3341f4715edf4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 29, 2026.
Transparency logRelease files / contextwalker-0.1.0-py3-none-any.whl
| Download URL | contextwalker-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ad1c95290ef441c1b584ae74625e2652e12e3e0b218f3517cd1b1157db8ea29
|
|
BLAKE2b-256 checksum How to use checksums |
b2b2d3330c524ecaf3f3ffa33d67bc14f345aa0a2d8a2e2fdcdf757cb813f4f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 29, 2026.
Transparency log