Skip to content

RAGeATM: Evidence-Bound Local RAG Assistant Prototype

A small explainable Retrieval-Augmented Generation prototype that demonstrates grounded answer behavior, retrieval thresholds, and refusal when local evidence is insufficient.

Context

Prototype / Academic Project

Current state

Local RAG prototype

Role

Sole builder for ingestion, retrieval, thresholding, generation modes, and benchmark notes

Problem

AI assistants can hallucinate or answer unsupported questions when they respond without checking whether the available evidence actually supports the answer.

Core Constraint

Evidence boundary: the system has to refuse unsupported questions when local retrieval does not clear the relevance threshold.

Solution / What I Built

I built a local RAG prototype that ingests text files, chunks them, indexes the chunks with TF-IDF, retrieves evidence with cosine similarity, checks a minimum relevance threshold, and only answers when the retrieved context clears that threshold. When the local evidence is insufficient, the assistant refuses instead of guessing.

Results

Indexed 7 local source documents into 15 searchable chunks and produced 7/7 useful retrieval/refusal decisions on a small sanity benchmark using TF-IDF + cosine similarity with a default 0.12 threshold.

Project data and checks

Dataset sizes and recorded checks within this project’s stated scope.

7

local source documents

15

searchable chunks

15 × 772

TF-IDF matrix shape

TF-IDF + cosine similarity

retrieval method

0.12

default minimum relevance threshold

7/7

useful retrieval/refusal decisions on the small benchmark

Architecture

The pipeline is shown as explicit stages so the system boundary is inspectable.

  1. 1

    data/raw text files

    Seven local source documents provide the bounded knowledge corpus.

  2. 2

    ingestion

    Text files are loaded into the prototype for local processing.

  3. 3

    chunking

    Documents are split into 15 searchable chunks.

  4. 4

    TF-IDF index

    The chunk corpus becomes a 15 × 772 TF-IDF matrix.

  5. 5

    cosine similarity retrieval

    Queries retrieve top-k chunks by lexical similarity.

  6. 6

    threshold check

    The assistant answers only when retrieved context clears the minimum relevance threshold.

  7. 7

    answer or refuse

    In-domain questions are answered from local evidence; unsupported questions are refused.

Technical Stack

PythonTF-IDFCosine SimilarityLocal RetrievalThreshold RefusalOptional OpenAI Mode

Applied Relevance

Where the pattern matters

  • Internal documentation assistants
  • Course assistants
  • Policy Q&A
  • Small-business knowledge assistants
  • Grounded AI patterns

Implementation and evidence

Implementation details and the artifacts available for review.

Demo Behavior

Implementation notes

The prototype demonstrates both grounded answers and explicit refusal when the local corpus does not support a question.

  • In-domain questions retrieve local context and answer from that evidence.
  • An out-of-domain question such as "What is the capital of France?" refuses because the local corpus does not support the answer.

Architecture / Pipeline

Implementation notes

The flow is intentionally small and inspectable: local files become chunks, chunks become TF-IDF features, retrieval is thresholded, and generation depends on retrieved evidence.

  • data/raw text files -> ingestion -> chunking -> TF-IDF index.
  • Cosine similarity returns top-k local evidence.
  • Minimum relevance threshold decides whether to answer or refuse.

Grounding Controls

Implementation notes

The main applied lesson is the refusal boundary, not broad RAG accuracy.

  • Top-k retrieval with minimum relevance threshold.
  • Offline retrieval-conditioned generation by default.
  • Optional OpenAI mode only when configured.

Artifacts & Evidence

Linked artifacts

The evidence is intentionally modest and quantified as a sanity benchmark.

  • 7 local source documents, 15 searchable chunks, and 15 × 772 TF-IDF feature matrix.
  • 7-question sanity benchmark with 7/7 useful retrieval/refusal decisions.
  • Public GitHub repository linked for code review.

Scope and limitations

Interpreting this work

  • Small educational corpus.
  • Lexical TF-IDF retrieval, not neural embeddings.
  • No Chroma/vector database.
  • No persistent memory.
  • No agents/tools.
  • No voice/UI/deployment.
  • The 7/7 result is a sanity benchmark, not broad accuracy.

Further technical work

Possible next steps

  • Add a lightweight UI for demonstrating answer/refusal behavior.
  • Compare TF-IDF retrieval against an embedding-based retriever on the same corpus.
  • Expand the benchmark beyond seven sanity-check questions.
  • Add richer citation display and evaluation logging before claiming broader quality.

Retrieval methods and tradeoffs

How the implemented TF-IDF baseline differs from other retrieval options.

RAGeATM implements TF-IDF with cosine similarity and a refusal threshold. The other methods below are comparison options, not implemented features or a universal ranking. Their usefulness depends on the corpus, query types, evaluation set, and operating constraints.

Retrieval methods and tradeoffs
MethodMechanismUseful whenLimitation
Exact keyword searchLiteral words or phrases in a query and document.Finding an exact identifier, name, or known phrase.Misses relevant passages that use different wording.
TF-IDFWeighted term overlap using cosine similarity; implemented in this prototype.A small, inspectable lexical baseline when queries and documents share vocabulary.Word overlap can miss paraphrases or retrieve passages with the right terms but the wrong meaning.
BM25Improved keyword relevance with term-frequency saturation and document-length normalization.A lexical baseline to compare against TF-IDF on the same documents and queries.Lexical matching remains weak for synonyms and paraphrases without matching terms.
Static embeddingsFixed word vectors combined into a representation of a query or passage.Exploring similarity beyond literal word overlap with a simple vector representation.A fixed vector for a word does not adapt to its meaning in each sentence.
Modern embedding modelsLearned query and passage vectors compared by similarity.Testing semantic retrieval for varied wording and paraphrases.Similar passages can still be irrelevant; model choice, language coverage, and corpus fit matter.
Hybrid searchLexical and embedding retrieval combined into one candidate set or ranking.Corpora where both exact terminology and varied wording matter.Fusion choices need evaluation and add indexing and operational complexity.
Reranked retrievalA second model scores query–passage relevance within an initial candidate set.Testing whether a smaller set of more relevant passages improves downstream answers.Adds latency and cost, and cannot recover relevant passages missing from the candidate set.

A useful next evaluation would compare TF-IDF, BM25, and an embedding retriever on the same documented queries, including paraphrases, ambiguous requests, and unsupported questions. Report retrieval relevance, refusal errors, latency, and run conditions before drawing broader conclusions.

Related Case Studies

More portfolio context.

Prototype / Academic ProjectApplied dashboard prototype

WeatherForge

A collaborative University of St. Thomas SEIS 745 project in which David Braun served as lead developer and primary implementer, turning large NOAA weather datasets into county-level risk views and decision-support reporting.

PythonShinyPlotlyParquet
Read case study
R&DActive Build

DGM

Workflow orchestration layer in active development for managing state, decision flow, and human review inside StormIQ.

PythonFastAPIWorkflow GraphsQueue-backed Jobs
Read case study
Back to all work