Skip to content
cd ..~/abhay/projects/talkative.md · 5.6K · case study 05 of 09

9 files open · click a tab, or use prev / next at the bottom of the page

// case 05 — RAG system · 2026

Mr. Talkative.md

A RAG system that checks every answer against its sources before the user sees it.

> Hybrid vector + graph retrieval with a critique loop that rewrites the query when an answer isn't grounded.

MY ROLESolo build: ingestion, retrieval and agents
TIMELINEJul 2026
TEAMJust me
STACK
LangGraph.jsLangChain.jsQdrantNeo4jRedisCohere RerankRagasHonoExpo
talkative · POST /query · streaming
$ POST /query "who approved the Q3 vendor change?"
classify: relational · multi-hop → 2 sub-queries
retrieve qdrant dense + sparse ∥ neo4j graph
fuse weighted RRF → cohere rerank → top 8
generate answer with inline citations [1][3]
FAIL critique 1 claim not grounded → rewrite query
retry re-retrieve with missing-context hints
OK critique passed · faithful + relevant · cached
$
PIPELINE
1Classify
2Hybrid retrieve
3Rerank
4Generate
5Critique
STORESQdrant + Neo4j
EVALRagas
CACHERedis
checks itself before it answers
// 01 — context

the problem_

cat problem.md

Most RAG demos retrieve some chunks, generate an answer and hope. When retrieval misses, the model fills the gap with something plausible, and nothing between the model and the user notices.

Talkative treats an answer as a draft: a critique agent checks every claim against the retrieved context, and a failed check turns into a specific fix (rewrite, decompose or re-retrieve) instead of a shrug.

## constraints
  • Private documents
  • PII scrubbed before indexing
  • Answers cite sources
  • Graph queries are LLM-written
  • One retrieval leg can fail
  • Streamed to mobile
./my-role.sh --verbose

abhay@os ~ % what did I actually do?

  1. 01Built the ingestion pipeline: parsers for PDF, DOCX, HTML, Markdown and text, PII scrubbing, exact and MinHash near-duplicate detection, semantic chunking and incremental re-ingestion.
  2. 02Indexed each chunk twice: dense and sparse embeddings in Qdrant, plus entities and relationships extracted with schema-validated LLM calls into Neo4j.
  3. 03Built query understanding: classification into retrieval weights, decomposition of multi-hop questions and normalisation against conversation history.
  4. 04Built hybrid retrieval: vector and graph legs in parallel with separate timeouts, per-source normalisation, weighted reciprocal rank fusion and Cohere reranking.
  5. 05Built the self-RAG loop in LangGraph.js: generate with citations, critique claim by claim, map each failure to a fix and keep the best answer seen.

[ ok ] exit 0 · 5 tasks · owner: abhay

// 02 — results

what moved_

Three numbers I'd put on a slide. Measured in production, not in a benchmark I wrote the night before.

RETRIEVAL3 legsdense · sparse · graphFused with weighted RRF, then reranked.
CHECKSper claimgrounding verifiedUngrounded claims trigger a rewrite and retry.
FORMATS5document types ingestedPDF, DOCX, HTML, Markdown and plain text.
// 03 — architecture

how it fits_

Two indexes, one answer. Vector search finds passages; the graph finds how things connect. Each leg can fail alone without failing the query.

open architecture.excalidraw — talkative
INGEST
ParsersPDF · DOCX · HTML · MD
Scrub + dedupePII · MinHash
BullMQ
INDEX
Qdrantdense + sparse
Neo4jentities · relations
retrieve
RETRIEVE
Classifyweights · sub-queries
FuseRRF · rerank
context
SELF-RAG
Generateinline citations
Critiqueclaim by claim
Rewriteand retry
request / write pathresponse / events backevery graph query is dry-run first
// 04 — key decisions

git blame me_

adr-001.md
CHOSE

Normalise scores per source, then fuse

REJECTED

Mixing raw scores

TRADE-OFF

More bookkeeping, but dense, sparse and graph scores live on different scales and can't be compared raw.

adr-002.md
CHOSE

Check LLM-written Cypher twice

REJECTED

Trusting the prompt

TRADE-OFF

An extra round trip, but a regex blocks writes and a real EXPLAIN catches anything the regex missed.

adr-003.md
CHOSE

Keep the best answer across iterations

REJECTED

Returning the last one

TRADE-OFF

Slightly more state, but a rewrite that makes things worse never reaches the user.

// 05 — under the hood

the good bit_

vim services/api/src/agents/graph.tsTypeScript
1.addNode('entry_check', entryCheckNode)
2.addNode('generator', generatorNode)
3.addNode('critique', critiqueNode)
4.addNode('loop_control', loopControlNode)
5.addNode('rewrite_signal', rewriteSignalNode)
6.addNode('query_rewriter', queryRewriterNode)
7.addNode('post_rewrite_check', postRewriteCheckNode)
8.addNode('finalize', finalizeNode)
9.addEdge(START, 'entry_check')
10.addConditionalEdges('entry_check', exitOrContinue, { exit: 'finalize', continue: 'generator' })
11.addEdge('generator', 'critique')
12.addEdge('critique', 'loop_control')
13.addConditionalEdges('loop_control', exitOrContinue, { exit: 'finalize', continue: 'rewrite_signal' })
14.addEdge('rewrite_signal', 'query_rewriter')
15.addEdge('query_rewriter', 'post_rewrite_check')
16.addConditionalEdges('post_rewrite_check', exitOrContinue, { exit: 'finalize', continue: 'generator' })
17.addEdge('finalize', END);
NORMAL services/api/src/agents/graph.ts17 lines · utf-8

The whole self-correcting loop as a graph: generate, critique, decide, rewrite and go round again, or finalize with the best answer so far.

less lessons.txt

If I built it again, I'd change…

  1. L1Chunk on meaningCutting where adjacent-sentence similarity drops beat fixed windows, as long as huge tables are force-split.
  2. L2Deterministic ids convergeEntity ids from the normalised name made the same entity land on the same node across documents.
  3. L3Failures need names"Bad answer" is not actionable. Irrelevant, hallucinated and incomplete each map to a different fix.

lessons.txt (END) — press q to quit

// 06 — timeline

git log --since_

Jul 2026

git log --reverse --format=milestone talkative
  1. 01Jul 2026IngestionParsers, scrubbing, dedupe, chunking, embeddings.
  2. 02Jul 2026GraphEntity extraction and Neo4j writing.
  3. 03Jul 2026RetrievalClassification, hybrid search, fusion, rerank.
  4. 04Jul 2026Self-RAGCritique loop, semantic cache, sessions, API.
cd ~/work./contact — itsabhay@abhay.si