News for hackers. Stuff that matters.
Re:I want flexible queries, not RAG by hn_throwaway_99 on Tuesday May 21, 2024 @06:01PM (#40434598)
This feels like a "No true Scotsman" answer. You say

> RAG is not used to try to anchor to reality a general LLM by somehow making it come up with sources and links.

but that definitely is one particular use of RAG, i.e. to limit some potential hallucinations by grounding it in data provided in the prompt.

Re:I want flexible queries, not RAG by bambax on Tuesday May 21, 2024 @06:10PM (#40434674)
Not really. RAG works very differently from a general (or generalist?) LLM.

RAG is vector search first. It encodes the query, finds nearest vectors in the vector database, retrieves the fragments attached to those vectors, and then sends those vectors to the LLM for it to summarize them.

A general LLM like Gemini or Claude or ChatGPT first produces an answer to a question, based on its training. This doesn't involve searching any external source at that point. Then after that answer is produced, the LLM can try to find sources that match what it has come up with.

Re:I want flexible queries, not RAG by simonw on Tuesday May 21, 2024 @08:48PM (#40436119)
You don't have to use vector search to implement RAG. You can use other search mechanisms instead or as well - whatever it takes to populate the context with the material most likely to help answer the user's question.

Two common alternatives to vector search:

1. Ask the LLM to identify key terms in the user's question and use those terms with a regular full-text search engine

2. If the content you are answering questions about is short enough - an employee handbook for example - just jam the whole thing in the context. Claude 3 supports 200,000 tokens and Gemini Pro 1.5 supports a million so this can actually be pretty effective.

Re:I want flexible queries, not RAG by bambax on Wednesday May 22, 2024 @03:15AM (#40438182)
You're right and I was imprecise. 2. is how RAG is implemented in most cases. (I wouldn't call 1. 'RAG' exactly, though?)
Re:I want flexible queries, not RAG by bigfudge on Wednesday May 22, 2024 @04:35AM (#40438714)
HYDE is a related technique. Ask the model to generate a response with no context, then use this for semantic search agains actual data and respond by summarising these documents.
Re:I want flexible queries, not RAG by simonw on Wednesday May 22, 2024 @09:20AM (#40440615)
I'd definitely call 1 (the FTS version) RAG. It's how Bing and Google Gemini and ChatGPT Browse work - they don't have a full vector index of the Web to work with (at least as far as I know), they use the model's best guess at an appropriate FTS query instead.
Re:I want flexible queries, not RAG by outofpaper on Tuesday May 21, 2024 @06:20PM (#40434755)
This is a generalization. These proprietary systems do different things at different times. With GPT4o you can see little icons when a RAG is in use or when code and tests are being used.

People, we have to stop talking about what we know as though it's all there is. Don't confuse our knowledge for understanding. Understanding only comes from repeadly trying to prove our understandings wrong and learning how things truly are.

Re:I want flexible queries, not RAG by acka on Tuesday May 21, 2024 @10:10PM (#40436659)
This. There is no point in arguing amongst ourselves when we're all wearing blindfolds and it is the zookeeper who decides what parts of the proprietary elephant we're allowed to touch.
Re:I want flexible queries, not RAG by ozr on Tuesday May 21, 2024 @10:23PM (#40436728)
That's not what RAG is. RAG is the process of adding relevant information to a prompt in an LLM. It's a form of in-context learning.
Re:I want flexible queries, not RAG by mr_toad on Tuesday May 21, 2024 @11:20PM (#40437001)
It’s right there in the name - first you Retrieve relevant information (often a vector lookup) then you use it to Augment the prompt, then you Generate an answer.

It’s bloody useful if you can’t cram your entire proprietary code base into a prompt.

Re:I want flexible queries, not RAG by kergonath on Wednesday May 22, 2024 @01:16AM (#40437566)
What makes it useful is precisely that it is not learning.
Re:I want flexible queries, not RAG by ozr on Wednesday May 22, 2024 @02:59PM (#40444773)
Yes it is; it's just not updating the weights.

https://ai.stanford.edu/blog/understanding-incontext/

Re:I want flexible queries, not RAG by kergonath on Wednesday May 22, 2024 @01:14AM (#40437553)
RAG really is not the right tool for that. It does not event prevent hallucinations. It is useful because it can retrieve information from documents the model never saw during its training phase and does not require a costly re-training. It is not a fine tuning either, and it cannot fundamentally change the model’s behaviour.
Re:I want flexible queries, not RAG by bigfudge on Wednesday May 22, 2024 @04:33AM (#40438703)
In my experience, it really does reduce the risk of hallucination, especially if paired with a prompt which explicitly instruct the model to use only facts from the context window. Another strategy is to provide unique identifiers for the rag chunks dropped into the context and ask the model to cross reference in its response. You can then check that the response is exciting evidence from the context with Simple pattern match.
Re:I want flexible queries, not RAG by sahn44 on Wednesday May 22, 2024 @07:54AM (#40439872)
Can you elaborate a little more on this? What's an example of how you do that in the prompt?
Re:I want flexible queries, not RAG by tkellogg on Wednesday May 22, 2024 @08:15AM (#40440021)
not OP, but for the "unique identifiers", you can think of it like the footnote style of markdown links. Most of these models are fine-tuned to do markdown well, and a short identifier is less likely to be hallucinated (my philosophy anyway), so it usually works pretty well. For the examples, something like this can work

ID: 1

URL: https://example.com/test.html

Text: lksdjflkdsjlksjkl

And then tell it to use the ID to link to the page.

Re:I want flexible queries, not RAG by throwthrowuknow on Wednesday May 22, 2024 @12:27PM (#40442834)
Instead of having the LLM generate the links couldn’t you use a combination of keyword matching and similarity on the model output and the results to automatically add citations? You could use a smaller NLP model or even a rule based system to extract entities or phrases to compare. I’m sure this is already being done by bing for example.
Re:I want flexible queries, not RAG by bigfudge on Thursday May 23, 2024 @04:50PM (#40459749)
You definitely can do that. It’s just sometimes simpler to dump lots of stuff in context and then check it wasn’t made up. It like the idea of using markdown footnotes. I think that would word well - ChatGPT does handle markdown really well.
Re:I want flexible queries, not RAG by notjoemama on Wednesday May 22, 2024 @01:35AM (#40437656)
This feels like a quantification fallacy. You say

> but that definitely is one particular use of RAG

One use of RAG doesn't imply that all uses of RAG are for grounding LLM hallucinations.

Additionally, I disdain when fallacies come up in conversation when it doesn't appear someone is making an argument in bad faith. We all use logical fallacies by accident from time to time. A good use of calling them out is when they are used in poor taste. I find that more on Reddit than Hacker News.

I have now also engaged in the Tu Quoque fallacy in this reply. See how annoying they are?