retrieval-augmented generation
Fetching relevant context from an external data source as additional context to inform a language model's response.
Also written: RAG
Example
Neo4j includes features for both vector and graph retrieval.
prompt
What movie features a toy protagonist who becomes jealous of a new arrival?ai.text.embed turns that description into queryVector. The SEARCH clause reads the moviePlots index for the five films whose own vectors lie nearest it.
cypher
WITH ai.text.embed($searchPrompt, 'OpenAI', {
token: $token, model: 'text-embedding-3-small'
}) AS queryVector
MATCH (movie:Movie)
SEARCH movie IN (
VECTOR INDEX moviePlots
FOR queryVector
LIMIT 5
) SCORE AS similarityScore
RETURN movie.title AS title, movie.plot AS plot, similarityScoretext
Toy Story 0.9334269165992737
Little Rascals, The 0.9214372634887695
NeverEnding Story III, The 0.9206198453903198
Drop Dead Fred 0.9199690818786621
E.T. the Extra-Terrestrial 0.919100284576416Only the first title shares a word with the description. The other four matched on plot alone. Those five plots become the context the model answers from, and asked the same thing with nothing fetched it answers from its training alone.
Lessons that use this term
The lesson and course links below open in a new tab.
No published lesson uses this term yet.