As part of my journey to gain more hands on experience building Retrieval Augmented Generation systems, I built a small self hosted RAG experiment designed to run on low powered hardware.
The goal was simple: see how far I could push a compact RAG stack without relying on cloud infrastructure, large commercial models, or expensive hardware. Instead, I wanted to use efficient open source models, local vector search, and a Raspberry Pi 5 with 16GB of RAM.
One interesting design choice I made was to go relatively heavy on the embedding model. Rather than using the smallest possible embedding model, I used a larger Gemma based embedding model with around 300 million parameters. The idea was that, in a RAG system, retrieval quality is often more important than raw generation power. If the system retrieves poor context, even a strong language model can produce weak answers. But if the retrieved context is relevant, a compact language model can often generate a useful response.
For the language model, I used SmolLM2 360M, which gave the system more generation capability while still being small enough to run locally on low powered hardware.
The project is available here: Github Link
What is RAG?
Retrieval Augmented Generation, usually shortened to RAG, is a technique that combines information retrieval with text generation.
Instead of asking a language model to answer purely from its internal training data, a RAG system first retrieves relevant information from an external knowledge base. That retrieved context is then passed to the language model, which uses it to generate a more grounded answer.
A typical RAG system has two main parts:
- Retriever: The retriever searches a database, document store, or vector index for relevant information.
- Generator: The generator takes the retrieved context and produces a natural language response.
This makes RAG useful for tasks such as:
- question answering
- document search
- chatbots
- summarisation
- knowledge base assistants
- internal company tools
In many real world systems, RAG is useful because it allows the model to answer using information that was not present in its original training data.
What are Embeddings?
Embeddings are numerical representations of text. They convert words, sentences, paragraphs, or documents into dense vectors that capture semantic meaning.
In simple terms, similar pieces of text should end up close together in vector space.
For example, a fact about lions should hopefully be closer to a question about big cats than to a question about penguins.
Embeddings are commonly used for:
- semantic search
- document retrieval
- clustering
- recommendation systems
- question answering
- RAG pipelines
In this project, I used a Gemma based embedding model with around 300 million parameters to convert animal facts into vectors. This was a deliberate choice. I wanted the retrieval part of the system to be strong, even though the final language model was still relatively compact.
This made the system heavier than using a tiny embedding model, but it helped test an important idea: for RAG, it can be worth investing more in the retriever because the quality of retrieved context heavily influences the quality of the final answer.
What is Faiss?
Faiss, short for Facebook AI Similarity Search, is a library developed by Meta AI for fast similarity search over dense vectors.
In a RAG system, Faiss acts as the retrieval engine. Once the animal facts have been converted into embeddings, Faiss indexes those vectors so that they can be searched efficiently.
When a user asks a question, the question is also converted into an embedding using the same embedding model. Faiss then compares that query vector against the stored vectors and returns the most similar entries.
For this project, that meant:
- Convert 100,000 animal facts into embeddings using the Gemma-based embedding model.
- Store those embeddings in a Faiss index.
- Convert the user question into an embedding.
- Search the index for the closest matching facts.
- Pass those facts to the language model as context.
How Does Faiss Work?
Faiss supports several different indexing strategies depending on the size of the dataset and the performance requirements.
Some common approaches include:
-
Flat indexing
Stores all vectors directly and compares the query against every vector. This is simple and accurate, but can become slower as the dataset grows. -
Hierarchical or approximate indexing
Organises vectors in a way that reduces the number of comparisons needed. -
Quantisation based indexing
Compresses vectors to reduce memory usage and speed up search, usually with some trade off in accuracy.
For this experiment, the dataset was small enough that a relatively simple Faiss setup worked well on the Raspberry Pi 5.
SmolLM2 360M: A Compact but More Capable LLM
For generation, I used SmolLM2 360M, a compact open source language model that offers more capability than the smaller 135M variant while still being lightweight compared with larger LLMs.
This felt like a good middle ground for the experiment. The 135M version would have been lighter, but I wanted the generator to have enough capacity to make reasonable use of the retrieved context. At the same time, I did not want to jump to a much larger model that would make the Raspberry Pi setup feel unrealistic.
There is also a larger 1.7B parameter version of SmolLM2, which could potentially produce better responses, but it would require more memory and compute. For this project, SmolLM2 360M was a practical balance between performance and efficiency.
The overall design was therefore:
- stronger retrieval using a 300M parameter Gemma based embedding model
- compact generation using SmolLM2 360M
- efficient vector search using Faiss
- local deployment on a Raspberry Pi 5
The Experiment
The RAG system was built using the following components:
- Dataset: 100,000 rows of random animal facts
- Embedding model: Gemma based embedding model with around 300M parameters
- Vector database/search: Faiss
- Language model: SmolLM2 360M
- Hardware: Raspberry Pi 5 with 16GB RAM
The basic pipeline was:
- Load the animal facts dataset.
- Generate embeddings for each fact using the Gemma based embedding model.
- Store the embeddings in a Faiss index.
- Take a user question.
- Embed the user question using the same embedding model.
- Retrieve the most relevant facts from Faiss.
- Pass the retrieved facts into SmolLM2 360M.
- Generate an answer based on the retrieved context.
The Raspberry Pi 5 handled the system better than expected. While it is obviously not comparable to a desktop GPU or cloud server, it was capable of running the pipeline and generating responses using compact models.
Using a 300M embedding model and a 360M language model made the setup more demanding than an ultra lightweight RAG pipeline, but it also made the experiment more realistic. In practical RAG systems, the embedding model and generator both matter. The embedding model controls what information is retrieved, while the language model controls how well that information is used.
Challenges and Observations
The system worked, but it also exposed some of the common challenges in building RAG systems.
Retrieval quality matters a lot
One of the biggest lessons was that retrieval quality matters more than I initially expected.
I deliberately used a larger embedding model because the retriever controls what information the LLM sees. If the retrieved facts are weak, irrelevant, or only loosely related, the generator has very little chance of producing a good answer.
The Gemma based embedding model helped make the retrieval side of the system stronger, but it did not solve everything. The system could still sometimes retrieve facts about related but incorrect animals. For example, a question about one species might retrieve facts about a similar species.
This shows that good RAG is not just about choosing a bigger embedding model. Dataset quality, chunking, similarity search settings and reranking can all matter as well.
SmolLM2 360M was a better fit than a tiny generator
Using SmolLM2 360M gave the generator more room to work with the retrieved context. Compared with using a smaller 135M model, the 360M version felt like a better fit for this experiment because it still remained compact while offering more generation capability.
However, it still had limitations. A 360M parameter model is small by modern LLM standards, so it can still struggle with more complex reasoning, ambiguous questions, or poorly retrieved context.
This reinforced one of the key lessons of RAG: the generator can only work with the information it is given. Better retrieval reduces the burden on the language model, but it does not remove the need for clear prompting and good context selection.
RAG is not just about the LLM
One of the biggest takeaways was that the LLM is only one part of the system. The quality of the dataset, embedding model, vector search, retrieval settings and prompt all have a major impact on the final answer.
This experiment made that very clear. I chose to spend a decent amount of the system’s budget on embeddings while still using a compact generator. That trade off made sense because RAG systems depend heavily on the quality of retrieved information.
In many cases, a smaller model with strong retrieval can be more useful than a larger model with weak or irrelevant context.
Conclusion
This experiment showed that it is possible to build a self hosted RAG system using compact open source models and run it on low powered hardware such as a Raspberry Pi 5.
It also showed that “small RAG” does not necessarily mean making every component as small as possible. In this case, I deliberately used a stronger 300M parameter Gemma based embedding model and paired it with SmolLM2 360M for generation.
That trade off made sense because retrieval quality is central to RAG. A compact language model can still produce useful answers if it receives the right context, but poor retrieval quickly leads to poor outputs.
The system was not perfect, but that was part of the value of the experiment. It helped me better understand the full RAG pipeline, from embeddings and vector search through to prompt construction and language model generation.
Future Improvements
There are several ways I could improve this system:
- compare the Gemma based embedding model against smaller embedding models
- test whether the 300M embedding model noticeably improves retrieval quality
- compare SmolLM2 360M against the 135M and 1.7B variants
- experiment with different Faiss index types
- add reranking after retrieval
- improve the prompt template
- improve the quality and structure of the dataset
- add a simple web UI or API layer
- measure retrieval accuracy and response quality more systematically
- benchmark inference speed and memory usage on the Raspberry Pi 5
Longer term, I would like to explore whether a small self hosted RAG system like this could be useful for private knowledge bases, offline assistants, or lightweight AI tools running on edge devices.
Overall, this was a useful experiment in building efficient AI systems from the ground up. It showed that RAG does not always need large cloud infrastructure to be interesting or useful. With the right balance between retrieval, generation and hardware constraints, even small devices can run meaningful AI workflows.