AiQAI Qualitatively

A field log from a qualitative research team

We built our own RAG

What a RAG does that an LLM does not

When an LLM answers, it is drawing on its memory of a huge amount of text, everything it was trained on. Some tools also let it search the web first, which widens where the answer can come from even further. That is what makes it powerful, and for research it is also the problem, because you can never be sure an answer came from your own sources rather than from somewhere else. A RAG is the opposite: you give it a small, defined set of sources, it can only answer from those, and it shows you the exact place each part of the answer came from.

You also cannot tell, with an LLM, whether it has repeated what a source actually said or quietly reworded it. A RAG hands you back the exact words it found.

What does RAG stand for, and how does one work?

RAG stands for retrieval-augmented generation. It has two steps: first find the relevant passages, then have an LLM write an answer from only those passages.

To make the finding possible, the documents are cut into short passages. A model called an embedding model turns each passage into a long list of numbers that stands for its meaning, so two passages about the same thing get similar numbers even when they share no words. The lists are saved in a database.

When you ask a question, the question is turned into numbers the same way, and the database returns the passages whose numbers are closest. Those passages are handed to the LLM with an instruction to answer from them alone and to say which passage each claim came from.

Why we needed one

We were doing data work, and we needed to ask our questions of the specific interviews we had collected, so we needed a RAG. Those interviews are our data, and any answer about them has to come from what was actually said in them. As with everything an LLM reads, the versions we use are de-identified first.

Where NotebookLM fell short

We were using NotebookLM, but it was not rigorous enough. Once it found a couple of sources that answered a question, it would stop there and never work through the rest of the corpus, where there were often more relevant sources. We also could not feed it as many of our interviews as we wanted, or tell it how many answers to return or how much relevance should count.

The app's controls: respondent alias, interview year, retrieval mode, analysis style and a minimum relevance slider
The controls we could not get anywhere else: filter by respondent or year, choose how the retrieval runs, and set a minimum relevance so weak matches are dropped rather than padded into the answer.

What we built

And so we built our own. (To be continued.)

An answer with its synthesis, a count of how many interviews it rests on, and the passages it came from
An answer, with the number of interviews the evidence rests on and the passages underneath it. The excerpt shown here is fabricated, standing in for the real one.