Hi 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.
This 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?
Tested 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.
Ive 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.
where 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.
Why 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
Graph 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!
I 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