NB
Back to board
AI / ML · Research · Data

QuickQA

RAG QA pipeline with an experimental Tiny Recursive Model encoder path.

QuickQA is a retrieval-augmented question-answering pipeline: it ingests a local document corpus, indexes it for hybrid dense + keyword search, and answers questions with an extractive reader. Alongside the stable MiniLM baseline, it wires in an experimental Tiny Recursive Model (TRM) encoder, researching whether TRM-based representations can reduce dependence on standard tokenization and improve efficiency.

PythonRAGFAISSBM25RoBERTaTRMPyTorchSQuAD

Pipeline overview

Ingest & index

  • Loads documents from a local corpus (.txt, .pdf, .docx), falling back to SQuAD validation passages when empty.
  • Splits text into sentence-aware chunks (300 words, 50-word overlap).
  • Encodes chunks into dense vectors and builds a FAISS inner-product index plus a BM25 keyword index.
  • Persists a JSONL passage store alongside both indexes.

Query & answer

  • Encodes the question to a dense vector and retrieves candidates from FAISS and BM25 in parallel.
  • Fuses the two candidate sets with weighted Reciprocal Rank Fusion, then re-ranks by cosine similarity.
  • Extracts the final answer span with a RoBERTa (deepset/roberta-base-squad2) reader, returning the answer, score, and source chunk.
  • A SQuAD evaluation command reports Exact Match, F1, and Recall@k.

TRM encoder path (experimental)

The pipeline supports swappable encoder backends behind a config flag. MiniLM is the default and the only backend that is fully stable end to end. The TRM backend is wired into the same ingest/query interface: text is converted from UTF-8 bytes into a fixed grid representation, bridged into ARC vocabulary IDs, and run through a Tiny Recursive Model whose hidden states are pooled, L2-normalized, and used for retrieval just like the MiniLM embeddings.

Query conditioning on the TRM path currently uses a CRC32 hash-bucket placeholder rather than learned semantics, so answer quality still trails the MiniLM baseline — the point right now is validating that TRM representations can sit in the same retrieval pipeline at all.

Status & roadmap

MiniLM remains the best end-to-end quality today. The TRM path needs a valid checkpoint and matching dataset metadata, and its byte-to-vocabulary bridge is still deterministic rather than learned.

  • Replace CRC32 query conditioning with learned, query-aware conditioning.
  • Train the byte-to-vocabulary bridge with supervised/contrastive objectives instead of a fixed mapping.
  • Fine-tune retrieval quality directly on QA triplets.
  • Benchmark TRM against MiniLM on quality and runtime, then package a reproducible demo.