Fixes 4005: Add a procedure for RAG #455
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes
https://github.com/neo4j-contrib/neo4j-apoc-procedures/issues/4005
Added a procedure for RAG you pass the user question plus a graph pattern (paths) and relevant attributes and it creates a prompt to answer the user question using the data on those paths and executes that with the llm provider and returns the answer
Retrieval-augmented generation (RAG) is a technique that reduces hallucinations and enhances the accuracy and reliability of generative AI models with facts fetched from external sources.
See here: https://aws.amazon.com/it/what-is/retrieval-augmented-generation/
Changes
apoc.ml.rag(paths, attributes, question, conf)
procedurepaths
can be a list of paths to retrieve and augment the prompt, it can also be a matching query or a vector index nameattributes
is the list of relevant attributes useful to retrieve and augment the promptquestion
is the user questionconf
can havegetLabelTypes
(to add label/rel names to the useful info),embeddings
to retrieve entities from vector node/rel indexestopK
to retrieve k result in case of vector index searchprompt
to customize the base prompt to be augmented with the contextapiKey
TODO
https://github.com/neo4j-contrib/neo4j-apoc-procedures/issues/3971
will be merged