4 ms·
Long-Term, Personalized Memory for AI Agents Using Graph DBs
- PHOTON1233 2y agoHi Guys! This is a quick demo of AffinityRAG. Ask it a question, and it will fetch sub-graphs from a larger knowledge graph (Alex's medical history) and answer your queries BETTER than just RAG. I've built a lot more since then including remembering you're specific info. I will open-source it if you guys want it.
- rahimnathwani 2y agoThis idea could be applied to HN as well. A naive way to 'ask a question' to HN would be to chunk and embed every comment, and use RAG. But then you would miss out ok comments that have something interesting to say, but don't mention enough context, because the rely on the reader knowing what they're talking about due to the parent or GP comment. Treating HN stories (or perhaps top-level comments) as graphs might work better than just RAG?
- PHOTON1233 2y agoThats a fun use case! I might try that out after flashing out this conversational-personal assistant usecase. Thanks for the idea!
- asimpleusecase 2y agoWe are working on this type of problem. Very interested in seeing an open source solution
- PHOTON1233 2y agoIm nearly done with a version 2. Ill showcase that, gauge the interest and start work on open sourcing it!
- ahmadswalih 2y agoTested it , It's interesting man. So how do you made it? like how the long-term memory actually works? I am not into that much of the Technical part , but am curious to get some info , if you can provide some articles or something ,that's also works.
- PHOTON1233 2y agoIve got some amazing articles saved on my computer! Will get back to you. Until then, its basically a csv with (head,relation,tail)—> converted to a KG (networkx)-> nodes embedded and vector stored ->queried similarity nodes on conversation-> n-neighbours connected to KG extracted and fed into llm relevant context.
- unraveller 2y agowhere does traditional RAG semantic text embedding fit into this Knowledge Graph scheme then? before and/or after the node embeddings are grabbed for prompt context? or not needed at all? Anything that makes RAG more generalizable automagically in the background is welcome.
- saxenauts 2y agoWhy choose a graph data structure ? Is it better for memory than AI agents as opposed to vector embeddings of statements or having a NoSQL database? I am bullish on graph, but seems like noone else is, so want to understand your perspective on this
- PHOTON1233 2y agoGraph DBs (KGs) add a much needed structure to unstructured data fed into traditional RAG. They are more holistic (interconnectedness of all things) than traditional relational DBs. That comes with 3 advantages; 1. They find insights you didn’t know you needed. Like discovering both Bob and Alice like to play basketball & paint the wilderness, so they could be a good match! 2. KGs are simple to read by humans, so are perfect for natural language processing. 3. KGs are dead simple and scalable. No complex tables and referencing. Just dots and lines. So LLMs have an easy time understanding. I really think graph data structures is the missing piece to fixing RAG, but it hasn’t been mass adopted because, building quality graphs from unstructured data is HARD. But we’re getting there!
- DrStartup 2y agoDo you have any examples of the kind of questions it can answer using a graph backend vs tradition rag and chunking? Did you test different embedding / chunking strategies of the RAG vector db? Is the KG vectorized?
- jexp 2y agoMany advanced RAG patterns are easier with a graphdb and you can pull the relevant context starting with the vector search results. You can also construct graphs with an llm out of text. See here. https://neo4j.com/labs/genai-ecosystem/llm-graph-builder/ https://neo4j.com/labs/genai-ecosystem/llm-graph-builder/
- PHOTON1233 2y agoI think the link was spammed folks! Someone ate through my openai credits! So it'll no longer work. If you want to see what Im building, add me on github! @Photon48