RAG: how an assistant finds the answer in your documents
An assistant that answers with your data does not memorize it: it looks it up on every question. Pick a query and watch which fragments reach the model.
- RAG
- Asistentes
- Documentos
When I build an assistant for a business, the first question is usually "do we need to train the AI on our data?". Almost never. What we do is simpler and more reliable: on every question, the system searches your documents for the fragments that help and hands them to the model along with the query. It's called RAG (retrieval-augmented generation) and it's the difference between a bot that makes things up and one that answers with your real policies.
How it works, in three steps
- Split. Your documents (FAQs, policies, catalog) are cut into short fragments, one topic each.
- Search. When a question arrives, its meaning is compared with each fragment's and every fragment gets a similarity score. It doesn't look for matching words: "how long until it arrives?" finds the delivery-times fragment even if they share no words.
- Answer. The top three fragments go to the model with a clear instruction: "answer only with this information".
Try it with a sample store. Pick a query and watch the fragments reorder:
Customer«Do you ship to Córdoba?»
- Shipping: nationwide by mail; own couriers in the Buenos Aires area. 0.91 Sent to the model
- Timing: 1 to 2 business days in the Buenos Aires area; 3 to 6 days elsewhere. 0.62 Sent to the model
- Store pickup: free, from 2 hours after purchase. 0.55 Sent to the model
- Returns: 30 days to exchange any unused product. 0.21 Sent to the model
- Payment: credit card in up to 6 installments, debit, transfer and Mercado Pago. 0.12 Sent to the model
- Hours: Monday to Friday 9 to 6; Saturdays 10 to 2. 0.09 Sent to the model
Assistant reply
Yes! We ship nationwide by mail and, in the Buenos Aires area, with our own couriers. If it suits you, you can also pick it up at the store for free.
Sample similarity scores. The top three fragments travel to the model along with the question.
Where it breaks
Almost every RAG problem lives in the first step, not in the model:
- Fragments that mix topics. If shipping and payments share a paragraph, the score gets confused and the model receives information nobody asked for.
- Stale information. The assistant confidently repeats whatever the document says, even if prices changed two months ago.
- Questions with no answer. If no fragment scores well, the right move is "I don't know, let me connect you with someone", not improvising. That's configurable, and it's the first thing I configure.
What you need to start
Less than you think: a tidy document with the questions you get the most and their real answers. That's enough for a first version. The rest (connecting it to stock, a calendar, WhatsApp) comes later, once the base answers well.
More from the blog
- Tokens: how a model reads (and why it bills you that way) Models read neither letters nor words: they read chunks. Type something and see how it gets cut, how much it weighs and what it costs.
- Temperature: the knob that decides whether AI makes things up A language model does not pick words: it rolls loaded dice. Turn the knob and watch the odds change.
- What not automating costs you (do the math) Repetitive tasks never show up on an invoice, but you pay for them every month. Move the numbers and see how much yours takes.
Have something similar in mind?
Let's talk