Skip to content

Context Refinery

A desktop app that turns a goal and your files into one token-budgeted prompt. Parked.

Situation
An answer is only as good as its context, and single-pass retrieval returns noisy chunks.
Task
I wanted a laptop pipeline that retrieves widely, reranks and checks context before a model sees it.
Action
I built a four-stage LangGraph pipeline with hybrid retrieval, reranking and a retry step.
Result
Version 0.1.0 runs offline with Ollama. With no baseline benchmark, it claims no accuracy number.
RoleCreator
Timeline2026
StackPython, LangGraph, FastAPI, Vue 3, Tauri v2, ChromaDB, Ollama
Links
$ python main.py   # serves on :8741
# pipeline
intent → retrieve → rerank → refine
retrieve  dense + BM25, fused with RRF
rerank    cross-encoder, ms-marco-MiniLM-L-6-v2
refine    up to 3 passes, scored locally
Impact

Version 0.1.0 is out under the MIT license. It scores every run, but it has no benchmark against a baseline, so it claims no accuracy number.

How I built it

  1. A four-stage LangGraph state machine: intent, hybrid retrieval, reranking, refinement.

  2. Hybrid retrieval that runs ChromaDB dense vectors and BM25 side by side and merges them with Reciprocal Rank Fusion.

  3. Cross-encoder reranking with ms-marco-MiniLM-L-6-v2.

  4. A retry step that runs the writer again, up to three times, when the local score falls short.

  5. Three local metrics by default (n-gram grounding, information density and budget use), so the offline path needs no key.

Why these choices

LangGraph instead of a chain

The refinement step loops based on a score. A state machine makes that branch explicit instead of burying it in nested chains.

Dense plus BM25, fused

Vectors catch meaning and BM25 catches exact terms. Reciprocal Rank Fusion merges the two rankings so neither blind spot wins.

Local metrics by default

The offline path has to work without an API key, so the default scorer is three metrics that run locally.

What shipped

  • Four stages: intent, hybrid retrieval, rerank, retry
  • ChromaDB and BM25 retrieval merged with Reciprocal Rank Fusion
  • A retry gated by a local score, up to three passes
  • Version 0.1.0, MIT licensed, with Windows installers; Mac and Linux run from source

Failures and limits

  • The README once read as if desktop builds existed for every platform. Only Windows installers are published, so the docs now say so.
  • The optional DeepEval and RAGAS scorers use those libraries' OpenAI-backed defaults. A Google or Anthropic key does not configure them.
  • The retry step is a plain retry: it gets no eval feedback and keeps the last attempt, not the best. The local gate can be passed by copying the context back.
  • No benchmark against a baseline, so no accuracy claim.

Check the work