There you can find a complete guide with examples written in GO.
Retrieval-Augmented Generation (RAG) is an architecture that's revolutionizing how we interact with Large Language Models. This open source project was born with the goal of explaining in detail how RAG works and providing practical implementation examples using modern, fully local technologies.
What is RAG and Why It Matters
RAG represents a popular alternative to fine-tuning large language models. Instead of retraining a model every time data changes, RAG uses a retrieval mechanism that enables more flexible content generation, leveraging pre-trained models combined with a knowledge database.
The operation is elegant in its simplicity: content is stored in a vector database, and when a user asks a question, the system transforms the query into a vector and uses vector search to find the most relevant information. This information is then provided to the language model as context, enabling more accurate and up-to-date responses.
Explaination
Retrieval-Augmented Generation (RAG) is a popular alternative to fine-tuning large language models, it allows for more flexible content generation by leveraging pre-trained models and a retrieval mechanism. Content is stored on a database, relevant information to the user query can be found by transforming the query in a vector and using a vector search on a database to find the most relevant data to what the user is talking about. By storing the data on a database you can easly obtain it without training a model each time the data changes.
A popular example of RAG is Google's new AI Overview tool.
When you search for something on Google the overview tool takes the top results from the search and tries to answer to your question using a RAG system.
This is a perfect usecase for RAG, the data that is being fetched from search results is constantly changing, it would be impossible to train the model on new data each time someone makes an update, RAG allows more flexibility at the small cost of performance.
Advantages of a Local Implementation
Implementing RAG locally presents numerous advantages over cloud solutions:
Complete Privacy - Your data never leaves your machine. This is fundamental when working with sensitive or proprietary information.
Reduced Costs - There are no costs for API calls or cloud storage. After the initial hardware investment, the system can run indefinitely without recurring costs.
Full Control - You have total control over models, data, and configurations. You can experiment freely without limitations imposed by external services.
Low Latency - Requests don't have to travel over the internet, resulting in faster response times, especially for repeated queries.
Practical Use Cases
The applications of a local RAG system are numerous:
Enterprise chatbots - Create virtual assistants that can answer questions based on internal company documentation, keeping data completely private.
Document search - Implement semantic search systems over large document archives, allowing you to find information even when exact terms don't match.
Knowledge management - Build knowledge management systems that allow natural language queries on enterprise knowledge bases.
Code analysis - Create assistants that can answer questions about large codebases, suggesting implementations or explaining complex patterns.
Conclusions
Local RAG Example demonstrates that it's possible to build sophisticated artificial intelligence systems without depending on cloud services or external APIs. With the right technologies and a good understanding of RAG architecture, you can create powerful solutions that respect privacy and offer complete control over your data.
The project represents an excellent educational resource for anyone wanting to deeply understand how RAG works, and a solid starting point for production implementations. The combination of PostgreSQL, Ollama, and Go creates a robust and scalable technology foundation, perfect for both experimentation and real applications.
This policy explains how cookies are used on ciannavei.dev (the “Site”), the personal portfolio of
Francesco Ciannavei. Questions? Write to francesco@ciannavei.dev.
01 What are cookies?
Cookies are small text files a website stores on your device when you visit. They let the Site remember things between page
loads — for example, whether you agreed to be counted in the visitor statistics. The same rules described here apply to
any similar technology that stores or reads information on your device.
02 How I ask for your consent
On your first visit this panel appears with two equally weighted choices: Accept all and
Reject all. Nothing is measured until you choose Accept all. If you choose
Reject all, no analytics cookie is set and no visit is recorded.
Your answer is remembered so you are not asked again on every page. You can change it at any time — see section 07.
03 The cookies this Site uses
There are no advertising cookies, no third-party trackers and no social or embedded-content cookies. Both cookies below are
first-party. I do not sell or share any data.
trackingStrictly necessary
Purpose
Stores your answer (true or false) so this panel does not reappear on every page.
Set when
You choose Accept all or Reject all
Duration
12 months
tracking_sessionAnalytics
Purpose
Ties the pages you open in one sitting to a single visit, so repeat page views are not counted as separate visitors.
Set when
Only after you choose Accept all
Duration
Until you close your browser
The tracking cookie holds nothing but true or false. The
tracking_session cookie is a random identifier with no meaning outside my own statistics, and is readable only by
the server, never by scripts in the page.
04 What the analytics collect
If — and only if — you accept, my own analytics record, for each page view:
the address of the page you opened on the Site;
the page you arrived from, when your browser sends one;
your browser identification (the user agent: browser, version, operating system);
your IP address, used to work out an approximate location (country level);
the session identifier described above, and the date and time of the visit.
I use this only to see which parts of my portfolio people read. There is no profiling, no advertising and no automated
decision-making.
The analytics run on my own server: nothing is sent to Google Analytics or any other third-party service, and no third-party
cookie is involved. The Site is delivered through Cloudflare’s network, which serves pages from the location closest to
you; my image CDN is my own code and sets no cookies.
05 Legal basis and retention
Under the GDPR and the ePrivacy Directive:
the analytics — the tracking_session cookie and the data above — rely on your
consent, which you give by choosing Accept all and can withdraw at any time;
the tracking cookie is strictly necessary to record and respect your answer, so it does not
require consent.
Retention: visit data is kept for a maximum of 12 months, after which it is deleted.
06 Your rights
Under the GDPR you have the right to access the data relating to you, to have it corrected or erased, to restrict its
processing and to receive a copy in a portable format. In practice I cannot act on any of those, because I have no way
of telling which visits are yours. There is no account and no name here, and the session identifier — the only
handle a visit has — is never shown to you and is gone the moment you close your browser. Article 11 of the GDPR covers
exactly this: where a controller genuinely cannot identify the person, those rights do not apply, provided the controller says
so. This paragraph is me saying so.
The exception is if you can identify your own records for me. While the browsing session is still open, your browser’s
developer tools will show you the value of the tracking_session cookie; send it, with a rough idea of when you
visited, to francesco@ciannavei.dev and I will act on your request. I will not
match a request to an IP address instead: I cannot verify that an address belongs to whoever is asking, and answering on that
basis would mean handing over somebody else’s data.
Two rights are unaffected, because neither of them needs me to know who you are:
withdrawing your consent at any time — the cookie button on any page stops all further recording, and
does not affect what was lawfully collected before (see section 07);
lodging a complaint with your data protection authority.
07 Changing or withdrawing your consent
You can change your mind whenever you like:
use the cookie button in the bottom corner of any page to reopen this panel and answer again; or
delete the tracking and tracking_session cookies in your browser settings — this panel then
reappears on your next visit.
Most browsers also let you block or delete cookies entirely from their own settings.
08 Changes to this policy
I may update this policy if the Site or the law changes. The date at the top always reflects the current version.