Latest / AI Fire Daily / #59 Max: RAG 2.0 is Here – Build an AI Agent That Understands Your Data with Knowledge Graphs
Transcript
- 0:00Imagine an AI that doesn't just, you know, pull
- 0:02up facts, but one that truly understands how
- 0:06those facts connect, how they influence each
- 0:08other. An AI that can reason, much like a brilliant
- 0:12research assistant, not just a super fast search
- 0:15engine. We're really talking about a fundamental
- 0:17shift in how AI interacts with information. It's
- 0:21like giving AI not just a memory, but a mind,
- 0:23you know, a way to connect things. This capability,
- 0:26it genuinely changes what's possible. Welcome
- 0:29to the Deep Dive. Today we're exploring a really
- 0:31cutting edge development in AI. It's this fusion
- 0:34of... agentic RG and knowledge graphs. Sounds
- 0:38fancy. It does. But our mission here is to unpack
- 0:41why the traditional ways AI retrieves information
- 0:43often, well, they hit a wall. Right. And then
- 0:46see how combining this sort of photographic memory
- 0:48with the ability to connect the dots creates
- 0:51something genuinely powerful. You'll get a feel
- 0:54for what enables this, how it's actually built,
- 0:57and what it could mean for how you interact with
- 0:59your own data. Yeah, and I think a lot of us
- 1:01have used AI to chat with documents, right? It
- 1:04feels pretty magical sometimes. It does. You
- 1:05ask a question, boom, it finds the answer right
- 1:08there in your files. But what happens when the
- 1:11questions get really complex, when you need to
- 1:14understand relationships, maybe compare strategies
- 1:18across different sources? That's where it gets
- 1:20tricky. Right. So for anyone who's played with
- 1:23traditional RRAG, that's retrieval augmented
- 1:25generation, it's a good starting point. It's
- 1:27meant to ground a language model in your specific
- 1:30documents. But what are its limits? When do questions
- 1:34need more than just a simple lookup? Well, think
- 1:37of it like this. Traditional RRAG, it's great
- 1:40for direct answers, finding that specific sentence.
- 1:42But it's fundamentally inflexible. The process
- 1:45usually involves breaking documents into these
- 1:47little chunks. Then you create mathematical embeddings,
- 1:50sort of numerical fingerprints for each chunk,
- 1:53and store them in what's called a vector database.
- 1:56This is for quick similarity searches. So when
- 1:59you ask a question, the AI just finds the most
- 2:02similar chunks and stuffs them into the prompt
- 2:04for the language model. So it gets the context,
- 2:07the raw text, but it can't really reason about
- 2:09it. It doesn't understand the meaning behind
- 2:11it. Precisely. The AI is constrained. It can't
- 2:15say, look at the initial search results and think,
- 2:17hmm, these aren't quite right. Let me try a different
- 2:19angle. It's not built to explore complex relationships
- 2:23or do multi -step reasoning across different
- 2:27facts it finds. So essentially, it ends up being
- 2:29a very sophisticated search engine. But still
- 2:31just a search engine. Yeah, exactly. And one
- 2:34that's kind of blind to the deeper connections.
- 2:35It's like someone reading random paragraphs from
- 2:38a dozen books, but never grasping the overall
- 2:40story. Okay, so what specific kinds of questions
- 2:43really break these traditional ARG agents? Where
- 2:47do they really stumble? Questions about relationships,
- 2:49comparisons, or maybe cause and effect. Those
- 2:52often cause major trouble. Got it. Questions
- 2:55needing more than just finding similar words.
- 2:57Yeah, things that require synthesis. Right. Okay.
- 3:00So here's where it gets really interesting then.
- 3:02This new approach, agentic R, combined with knowledge
- 3:05graphs, you said it gives AI not just that memory,
- 3:08but also this ability to connect the dots. That
- 3:11really does sound like a big leap. It truly is.
- 3:14Think of it like this. If traditional R is a
- 3:16really, really good filing cabinet, excellent
- 3:19at pulling out specific files quickly, then this
- 3:23new system... is more like your brilliant research
- 3:26assistant. This assistant hasn't just read every
- 3:28document you gave them. They've actually understood
- 3:30how everything within those documents relates
- 3:33to everything else. They've built this comprehensive
- 3:35mental map. So the AI itself, the agent, it has
- 3:38autonomy. It gets to decide the best strategy
- 3:41to answer my question instead of just following
- 3:42one rigid search then answer path. Exactly. That's
- 3:46the core idea. For a simple fact, like what year
- 3:48was this company founded? It might just do a
- 3:51quick vector search. Fast and easy. If you ask
- 3:53about relationships, like how does this new regulation
- 3:57impact our main competitor, It can traverse the
- 4:00knowledge graph, mapping out those connections.
- 4:02And for really complex queries, it might intelligently
- 4:05combine both methods. Two -sec silence, you know,
- 4:09a real -world example. Instead of just finding
- 4:11separate documents mentioning Microsoft and OpenAI,
- 4:14this agent, because it has that knowledge graph,
- 4:17it understands their multibillion -dollar partnership.
- 4:19It knows how that connection impacts their strategies,
- 4:22their products, everything. It's connected knowledge.
- 4:25not just isolated facts. And that's what you
- 4:27mean by agentic argue, the agent choosing the
- 4:30strategy. Yep. An AI system where the agent itself
- 4:33figures out the best way to find and use information
- 4:36to answer your query. So how does this deeper
- 4:39level of understanding fundamentally change what
- 4:42AI can do for us? What kinds of problems can
- 4:45it tackle now? Well, it allows the AI to actually
- 4:48reason and provide much more nuanced answers
- 4:50going way beyond simple fact retrieval. It starts
- 4:53to sound like actual understanding. It's getting
- 4:55closer. This capability, it sounds pretty advanced.
- 4:59What are the actual tools making this possible?
- 5:02Is this all super proprietary, complex stuff?
- 5:05Surprisingly, no. A lot of it is built on open
- 5:07source components. We're talking about things
- 5:09like Pydantic AI. That's a Python library that
- 5:12helps build structured, reliable outputs from
- 5:14the AI agent. So it's not just rambling. It gives
- 5:16you organized answers. Okay, structure is good.
- 5:18Yeah. And for the knowledge graph itself, there's
- 5:21a tool called Graffiti. to help define the structure,
- 5:24the schema. And then Neo4j is pretty much the
- 5:28leader for graph databases where all those intricate
- 5:31connections actually live and get queried. Right,
- 5:33Neo4j. And what about the vector database piece
- 5:35for that initial similarity search? Ah, yeah,
- 5:38that's a pretty clever choice in this setup.
- 5:40It uses PostgreSQL, the familiar, robust SQL
- 5:44database, but with an extension called pgVector.
- 5:48So your standard relational database suddenly
- 5:50gains high -performance vector search capabilities.
- 5:52Whoa, wait. Postgresible with PGVector? So it's
- 5:55like a database and a vector search engine rolled
- 5:58into one, a two -in -one superpower? Yeah, kind
- 6:00of like having a sports car that also happens
- 6:02to be a submarine. Yeah. It's really powerful.
- 6:04You get this solid, reliable SQL foundation,
- 6:07but can also handle the vector stuff extremely
- 6:09well for many use cases. That sounds incredibly
- 6:12versatile. But I wonder, does putting vector
- 6:15search inside PostgreSQL have any trade -offs
- 6:18compared to using, say, a totally separate specialized
- 6:21vector database? That's a fair question. You
- 6:25definitely gain a lot of convenience and often
- 6:27simplify your whole setup. You have one less
- 6:29system to manage. But, you know, for scenarios
- 6:32demanding absolutely massive scale, maybe billions
- 6:35of vectors or ultra -low latency search. a dedicated
- 6:39specialized vector database might still have
- 6:41an edge. Okay. For most applications, though,
- 6:44this Swiss army knife approach with Postgres
- 6:46and PG vector is incredibly effective and flexible.
- 6:49Plus, the whole thing uses fast API for the API
- 6:52layer, which is modern and fast. Right. And critically
- 6:55important, I think, you have amazing flexibility
- 6:57with the large language models of brains, right?
- 7:01You can plug in OpenAI's models or run open source
- 7:04models locally using Alama or use Google Gemini
- 7:07models. You're not locked into one vendor. No,
- 7:10vendor lock -in is huge. So what's the key benefit,
- 7:13the sort of magic, when you combine these specific
- 7:15tools, Pydantic AI, Graffiti, Neo4j, Postgres
- 7:19Vector, FastAPI? It's that seamless integration
- 7:21that allows you to build these really powerful
- 7:24yet customizable AI systems that can both search
- 7:28and reason. Powerful and customizable. I like
- 7:31the sound of that. Sponsoreed mid -roll. Okay,
- 7:34so how does someone actually build this kind
- 7:35of assistant? It sounds like a lot of moving
- 7:37parts, but the article suggests it's pretty approachable
- 7:40if you're willing to dive in. Yeah, the article
- 7:42lays it out step by step. You basically get the
- 7:44code, set up your Python environment. You'll
- 7:46need PostgreSQL. And they suggest maybe using
- 7:48a managed service like Neon, which handles the
- 7:50vector stuff easily. Okay, Neon for Postgres.
- 7:53And then your Neo4j instance for the graph database,
- 7:57Beat. But the really crucial part, the magic
- 8:01moment, is loading your knowledge base. Right,
- 8:03your documents. Exactly. You just put your documents,
- 8:06PDFs, text files, whatever, into a specific folder.
- 8:08Then you run an ingestion script, and the AI
- 8:11gets to work. What's it doing, though? It splits
- 8:13the text into meaningful chunks, not just random
- 8:15bits. It generates those vector embeddings for
- 8:19the similarity search in Postgresql. And this
- 8:21is key. It uses a large language model to read
- 8:24through the text and identify the important entities
- 8:27like people, companies, concepts, and the relationships
- 8:30between them. Ah, so the LLM itself helps build
- 8:34the knowledge graph. Precisely. It extracts that
- 8:36structure, that understanding, and populates
- 8:39the Neo4j graph database. That's where the real
- 8:41understanding of your data gets built. Okay,
- 8:43so once that's built and the graph is populated...
- 8:46How do we test it? What kinds of questions really
- 8:48show off its reasoning beyond just finding facts?
- 8:52This is the fun part. You can actually see its
- 8:54logic. Ask it something simple like, what are
- 8:56Google's main AI initiatives? The agent will
- 8:59probably just use a quick vector search. Finds
- 9:01the relevant passages. Simple. Right. But then
- 9:04ask something like, how are Amazon and Anthropic
- 9:06connected? Now, it gets interesting. The agent
- 9:09should realize this is about a relationship.
- 9:12So it uses the graph search. It navigates the
- 9:15connections in Neo4j and finds their big investment
- 9:18relationship, maybe Anthropic's use of AWS infrastructure.
- 9:22It pieces together the connection. That's cool.
- 9:25And then for the really complex stuff, multi
- 9:27-step reasoning. Ask it something like, compare
- 9:30Microsoft's AI strategy with OpenAI's approach.
- 9:33Okay, that's not a simple lookup. Not at all.
- 9:36Beep, beep. Here, the agent has to be smart.
- 9:39It needs to combine vector search to pull specific
- 9:41facts about each company's strategy and graph
- 9:44search to understand their deep partnership,
- 9:46how one influences the other. The result should
- 9:49be a really nuanced, comprehensive answer that
- 9:51considers both the individual parts and their
- 9:54relationship. It's genuinely impressive when
- 9:56you see it work. Wow. Imagine scaling that kind
- 9:59of analysis. A billion queries like that. The
- 10:01depth of understanding you could unlock. It's
- 10:04incredible. Really remarkable potential there.
- 10:07So thinking about getting it running, beyond
- 10:10just installing the software and setting environment
- 10:12variables, what's often the trickiest part in
- 10:15getting the quality right, making sure the understanding
- 10:18is actually good. Yeah, that's key. Setting up
- 10:21the databases and making sure all the connections
- 10:23and like. API keys are right, can definitely
- 10:25be tricky for first timers. But getting the quality
- 10:28often comes down to the data feeding in and how
- 10:31the agent reasons. Right, the inputs matter.
- 10:33Hugely. Okay, so once a system is built, how
- 10:36locked in are you? How customizable is it? Can
- 10:39you really tailor it? Oh, absolutely. That's
- 10:42the beauty of it being mostly open source. You
- 10:44can totally customize the types of entities and
- 10:46relationships it looks for. Maybe you need it
- 10:48to understand legal clauses or specific scientific
- 10:50concepts. You could integrate multimodal knowledge.
- 10:54Imagine feeding it images or audio files alongside
- 10:57text. You can set up real -time updates so as
- 11:00new documents come in, the knowledge graph grows.
- 11:03And you can definitely optimize performance for
- 11:06really massive data sets. It's designed to be
- 11:09flexible. That's really powerful. Now, what's
- 11:11equally fascinating, you mentioned earlier, is
- 11:13how the system itself was actually built. The
- 11:16author used something called context engineering
- 11:18with an advanced AI like Claude. So the AI wasn't
- 11:21just like a co -pilot helping out. It was more
- 11:23fundamental. Way more than a co -pilot, really.
- 11:26The description makes it sound like... Imagine
- 11:29the AI was the incredibly skilled camera operator,
- 11:32the lighting expert, the sound engineer, and
- 11:35the editor. Wow. While the human was primarily
- 11:38the film director, providing the vision and the
- 11:40overall plan. Apparently, over 90 % of the system's
- 11:43code was generated by the AI in just 35 minutes.
- 11:4635 minutes. Yeah. By feeding it a really detailed
- 11:50project specification, the requirements, and
- 11:53crucially, access to the documentation for all
- 11:55those tools we mentioned. vulnerable admission
- 11:58I mean I still wrestle with prompt drift myself
- 12:01sometimes getting the AI to consistently do what
- 12:04I want so seeing this level of complex system
- 12:07generation through AI assistance is genuinely
- 12:10mind -blowing and that's context engineering
- 12:12giving the AI all that background material essentially
- 12:14yeah it's about guiding the AI assistant by providing
- 12:18comprehensive documentation clear examples detailed
- 12:21plans basically giving it everything it needs
- 12:24to understand the task deeply and generate the
- 12:27right code or system components. So what's the
- 12:29big takeaway then from seeing AI build such a
- 12:32sophisticated system so rapidly? What does that
- 12:35imply more broadly? It just shows how AI -assisted
- 12:37development can drastically speed up the creation
- 12:39of complex systems. It's a game changer for building
- 12:42things quickly. A definite force multiplier.
- 12:44Okay, so for listeners who are thinking, hey,
- 12:46I want to try building this, are there any common
- 12:48pitfalls, any gotchas they should watch out for
- 12:51that might trip them up? Definitely a few things
- 12:53to keep in mind. First, during your initial testing
- 12:56phase, creating that knowledge graph from scratch
- 12:59can sometimes take a really long time, especially
- 13:02with lots of documents. Right. The good news
- 13:05is you can actually skip that step temporarily
- 13:07for faster iteration. There's usually a flag
- 13:10you can use when running the ingestion script,
- 13:12something like no knowledge graph, just to get
- 13:15the vector search part working first. Okay. Handy
- 13:18tip for testing. What else? Another common one.
- 13:20Sometimes you find the agent gets stuck in a
- 13:23rut. It always uses vector search or always tries
- 13:26the graph, even when the question clearly suits
- 13:29the other method. Ah, it's not making the right
- 13:32decision. Exactly. If that happens, you need
- 13:34to go back and refine the system prompt you give
- 13:37the agent. You have to be super clear about the
- 13:39criteria it should use to decide which tool vector
- 13:42search or graph search is appropriate for different
- 13:45kinds of questions. So tweaking the agent's instructions.
- 13:50off irrelevant like it's not finding the right
- 13:53chunks yeah that can happen first thing is maybe
- 13:56experiment with different embedding models some
- 13:58are better than others for certain types of text
- 14:00okay but crucially pay attention to how you're
- 14:04chunking the documents this idea of semantic
- 14:06chunking is really important semantic chunking
- 14:08yeah instead of just chopping documents into
- 14:10rigid say 500 word blocks right You split them
- 14:15based on logical breaks in the content, paragraph
- 14:17sections, topic shifts, meaningful segments.
- 14:21That usually gives the vector search much better
- 14:23context to work with. Semantic chunking basically
- 14:25is just dividing text into meaningful, logically
- 14:28coherent parts, not just fixed size blocks. It
- 14:31makes a big difference. Makes sense. Better chunks,
- 14:34better search. And what about if you just can't
- 14:37connect to Neo4j, the graph database? Oh yeah,
- 14:39that's usually simpler. Double check your credentials,
- 14:41username, password, database URL, and just make
- 14:44sure the Neo4j service is actually running on
- 14:46your machine or wherever it's hosted. It's often
- 14:49just a configuration type or the service isn't
- 14:51started. Standard troubleshooting then. So beyond
- 14:54these specific fixes, what's a good general mindset
- 14:57to have when you're troubleshooting these complex
- 14:59AI systems? Patience. iteration it often involves
- 15:04carefully tweaking the AI's internal prompts
- 15:06trying different chunking strategies maybe adjusting
- 15:09parameters and seeing how it affects the results
- 15:11it's rarely a one -shot fix careful refinement
- 15:15is key iteration and refinement got it so let's
- 15:19pull back what does this all mean for us what's
- 15:21the really big idea here it feels like more than
- 15:23just a new technique I think it is. The big idea
- 15:27is that the future of AI, especially when it
- 15:29comes to understanding information, isn't just
- 15:31about making search faster or training even bigger
- 15:33language models. It's really about building systems
- 15:36that can genuinely reason. We're moving away
- 15:38from thinking about static databases that just
- 15:40store isolated facts towards building dynamic,
- 15:43interconnected knowledge networks where the relationships
- 15:46are just as important as the facts themselves.
- 15:50You know, traditional reg gives you a really
- 15:52good search engine. Agetic reg, combined with
- 15:54knowledge graphs, starts to give you something
- 15:57closer to a brilliant research assistant. From
- 15:59search engine to research assistant, that's a
- 16:01powerful shift. It's a fundamental change in
- 16:04how we can expect AI to help us make sense of
- 16:07complex information. So this deep dive really
- 16:10reveals a fundamental shift, doesn't it? Moving
- 16:13from just simple search towards an intelligent
- 16:15understanding that actually grasps context and
- 16:18crucially relationships. Absolutely. And the
- 16:21tools are becoming accessible enough to actually
- 16:24build this now. So maybe some homework for our
- 16:26listeners, if you're feeling ambitious, that
- 16:28is. Yeah. Get your hands dirty. Try setting this
- 16:30system up. The article provides the guide and
- 16:32the code. Load it with your own documents. Maybe
- 16:35it's your company's internal notes. Maybe research
- 16:37papers you need to synthesize. Project documentation.
- 16:40Whatever complex information you need to master.
- 16:43And then test it. Exactly. Ask it different kinds
- 16:46of questions, simple facts, relationship questions.
- 16:49Those complex comparison queries push its boundaries.
- 16:52See what it can do with your data. Because this
- 16:54is really about more than just playing with code,
- 16:56isn't it? It's about starting to grasp how AI
- 16:59can navigate that incredibly complex web of relationships
- 17:03within your information, uncovering insights
- 17:05that were maybe hidden before. It's about starting
- 17:07to build that future of AI for yourself, tailored
- 17:10to what you need to understand. So the final
- 17:13thought to leave... everyone with, what kind
- 17:15of complex relationship -based questions could
- 17:17you finally get answers to if your AI truly understood
- 17:20your data? Out to your own music.