EWU RAGBot
A document-grounded assistant exploring semantic search and generated answers.
Understand.
How EWU RAGBot finds an answer
The pipeline runs in two halves: documents are prepared once and stored, then a question retrieves context and an answer is produced from it.
A whole document is loaded and cleaned, then divided into many passages. Each passage becomes one retrievable unit rather than the document being searched as a whole.
Each passage is converted into a fixed-length vector. Passages that mean similar things sit close together in that space, even when their wording differs.
Passage vectors are stored one per row. The question is embedded the same way and matched against them, and the nearest passages come back as the context.
The retrieved passages and the user’s question are placed into one message. The model then answers from that message, so the context bounds what it can say.
The model writes the answer, the answer is compared against the retrieved passages, and a person judges the result. No accuracy figure, citation, or production claim is made.
Preparing documents
University material arrives as documents, but retrieval works on smaller pieces of text that can be compared with one another.
Documents are loaded and structured, then split into passages. Each passage becomes the unit that is embedded and stored.
The quality of every later answer is decided here, because a passage that was split badly cannot be retrieved well.
Under the hoodThe two paths, kept apart
- 01
Load the documents
PythonUniversity source material is loaded into the notebook and turned into plain text that can be split.
- 02
Split into passages
Text splittingThe documents are divided into passages, because a passage is small enough to embed and specific enough to retrieve on its own.
- 03
Embed each passage
Hugging FaceA sentence-transformer model converts every passage into a vector, which is the form the store can compare.
- 04
Store the vectors
ChromaDBThe embedded passages are written to a ChromaDB vector store, which is the offline half of the pipeline.
- 05
Embed the question and retrieve
ChromaDBAt question time the question is embedded with the same model and matched against the stored vectors to pull back the nearest passages.
- 06
Assemble the prompt and answer
LangChain and GeminiLangChain places the retrieved passages and the question into one prompt, and Gemini generates the answer from it.
Documents are chunked and embedded into a ChromaDB vector store, then retrieved passages feed a LangChain chain and Gemini. Ingestion and question answering are separate steps: the store is built once from the documents, and each question is answered against it.
What it actually does
Document preparation
Turns university material into retrievable passages.
Semantic search
Hugging Face embeddings and ChromaDB find relevant context.
Context-based answers
LangChain connects retrieved passages with language models.
Evaluation experiments
Examines retrieval quality and generated-answer behavior.
How it moves forward
- 01
Prepare
Structure documents and generate embeddings.
- 02
Retrieve
Find passages related to a question.
- 03
Respond
Generate an answer using the retrieved context.
The tools behind it
Notebook pipeline
- Python
- LangChain
Vector store
- ChromaDB
Embeddings and generation
- Hugging Face
- Gemini
Interface
- Gradio
How the pieces connect
Ingestion
Index
Response
- Ingestion: Documents. University source material. Chunking. Source material split into passages.
- Index: Hugging Face embeddings. Sentence-transformer vectors for each passage. ChromaDB. Vector store queried at request time.
- Response: LangChain chain. Assembles the question and retrieved context. Gemini. Generates the answer from that context.
Engineering decisions
Retrieval before generation
The project explores sentence-transformer embeddings, a ChromaDB vector store, and LangChain retrieval chains.
Ingestion kept separate from questions
Building the store is an offline step over the documents, while each question runs only against the passages that were already embedded.
Experimental by design
The notebook compares model and retrieval behavior. It is an academic experiment rather than a deployed support service.
Challenges
Retrieval is simple to describe and awkward to build. These were the parts where the honest answer was a trade-off rather than a technique.
Splitting documents well
A passage that is too long dilutes its meaning and a passage that is too short loses the context needed to answer from it.
Retrieving something relevant
Similarity alone can return a passage that is on the topic but does not carry the answer the question needs.
Answering from the context
The generated answer has to stay grounded in the retrieved passages, and the notebook treats that as something to check rather than assume.
Measuring without overclaiming
The pipeline is an experiment, so the project compares behaviour rather than publishing an accuracy score it has not established.
What stayed with me
What stayed with me from building the retrieval pipeline was mostly about how much of the work happens before the model is ever called.
Preparation decides the ceiling
Document preparation shapes the quality of retrieval. A weak store cannot be rescued later by a stronger model.
Relevant is not the same as sufficient
A retrieved passage can be on topic and still not contain the answer, which is why the context has to be inspected.
Context assembly is a design decision
What goes into the prompt and in what order changes the answer, so the assembly step deserves the same attention as the model.
An experiment should say so
The project states what it tried and what it observed instead of implying a deployed system it has not built.