Latest / CyberSecurity Summary / Learning LangChain: Building AI and LLM Applications with LangChain and LangGraph
Transcript
- 0:00Speaker 1: Welcome to the Deep Dive. We're the show that gets
- 0:02Speaker 1: you quickly and thoroughly well informed on the topics that
- 0:04Speaker 1: really matter. And today we are plunging headfirst into something that, honestly,
- 0:09Speaker 1: it still feels a bit like science fiction, but it's
- 0:11Speaker 1: very much real now, the world of artificial intelligence, specifically
- 0:16Speaker 1: large language models or LMS. I mean, think about it.
- 0:20Speaker 1: I remember when chat GPT just exploded onto the scene exactly.
- 0:24Speaker 1: It wasn't just some tech news item. It went global,
- 0:27Speaker 1: pulling what over one hundred million users in just two months.
- 0:30Speaker 1: It really felt like these things could just conjure up text, answers,
- 0:34Speaker 1: anything right out of thin air.
- 0:35Speaker 2: It did feel a bit magical, didnety totally.
- 0:38Speaker 1: So our mission with this Deep Dive is really to
- 0:40Speaker 1: give you a shortcut into learning liang chain, building AI
- 0:44Speaker 1: and LM applications. We want to go beyond the buzzwords,
- 0:47Speaker 1: you know, get into the core concepts, the actual practical
- 0:50Speaker 1: strategies for building powerful AI apps with this thing called
- 0:54Speaker 1: lang chain. Our goal isn't just to tell you what's
- 0:56Speaker 1: happening in AI, but really show you why it matters,
- 0:59Speaker 1: point out the aha moments, and crucially equip you the
- 1:03Speaker 1: listener with the knowledge to maybe even apply it yourself.
- 1:06Speaker 2: And to guide us through this pretty intricate, in let's
- 1:10Speaker 2: be honest, rapidly evolving landscape. We're drawing directly from a
- 1:13Speaker 2: really fantastic source, the book Learning lang Chain by myo
- 1:17Speaker 2: Ocean and Nunocampos. And these aren't just you know, academics
- 1:20Speaker 2: writing about the fields from Afar. Mayo was actually an
- 1:23Speaker 2: early developer, an advocate for the lang Chain open source
- 1:25Speaker 2: library itself, a real pioneer in that whole chat with
- 1:29Speaker 2: data movement, and Nun is a founding software engineer at
- 1:32Speaker 2: lang Chain. So this book, it isn't just theory, it's
- 1:35Speaker 2: packed with super clear explanations, actionable techniques. Industry experts are
- 1:39Speaker 2: calling it the go to resource for building production ready
- 1:43Speaker 2: generative AI and agents.
- 1:45Speaker 1: That's fantastic, a really solid foundation. Then, So the big
- 1:48Speaker 1: question we're tackling today is this, how can developers, maybe
- 1:53Speaker 1: even those who don't have a deep machine learning background,
- 1:57Speaker 1: how can they harness this incredible power of lllms to
- 2:00Speaker 1: build genuinely production ready generative AI applications and these intelligent agents. Right,
- 2:05Speaker 1: we're going to unpack the essential tools, the patterns, the
- 2:07Speaker 1: thinking that transforms these powerful models from cool tech demos
- 2:11Speaker 1: into practical, usable solutions. So, okay, let's start right at
- 2:16Speaker 1: the beginning. These lms, they seem almost magical. How exactly
- 2:18Speaker 1: do they know the answers they give and what precisely
- 2:21Speaker 1: is a token in their world?
- 2:22Speaker 3: Yeah, good place to start.
- 2:24Speaker 2: So at their heart, large language models are generative models
- 2:28Speaker 2: specifically built for text. They're trained on just vast amounts
- 2:32Speaker 2: of text, think everything publicly available, books, articles, forums, code,
- 2:37Speaker 2: even cleaned up video transcripts, an immense data set. Their
- 2:41Speaker 2: core function isn't really magic, though it looks like it.
- 2:43Speaker 2: It's incredibly sophisticated prediction. They basically predict the most probable
- 2:48Speaker 2: next word or token in a sequence based on all
- 2:51Speaker 2: the patterns they've learned. So if you feed it the
- 2:53Speaker 2: capital of England is, it's learned from countless examples that
- 2:56Speaker 2: the highest probability next word is.
- 2:58Speaker 1: London, ok N, matching on a massive scale. But what's
- 3:02Speaker 1: a token? Is it just a word?
- 3:04Speaker 3: Not always?
- 3:05Speaker 2: Yeah, a token is the fundamental unit the LM processes.
- 3:08Speaker 2: Often it's a word, but sometimes longer or less common
- 3:12Speaker 2: words get broken down, like dearest might become two tokens.
- 3:15Speaker 2: Done and arrest on average. You know, for common English text,
- 3:19Speaker 2: one token is roughly four characters. And the driving engine
- 3:22Speaker 2: behind all this predictive power is something called the transformer
- 3:25Speaker 2: neural network architecture.
- 3:26Speaker 1: Right, the transformer architecture.
- 3:27Speaker 2: Heard a lot about that, Yeah, it's key. Think of
- 3:29Speaker 2: it as being really good at understanding context. It relates
- 3:33Speaker 2: every word in a sentence to every other word, building
- 3:35Speaker 2: this rich understanding of meaning and relationships. That's how they
- 3:38Speaker 2: handle complex grammar and nuance, not just simple word prediction.
- 3:43Speaker 1: And it was that understanding, or perhaps a limitation of
- 3:46Speaker 1: that understanding, that led to lang chain, Right, I read
- 3:48Speaker 1: Harrison Chase started the open source library back in October
- 3:51Speaker 1: twenty twenty two. What was the key realization.
- 3:54Speaker 2: Exactly, the real breakthrough, The thing that sparked lang chain
- 3:56Speaker 2: was this insight in LM, as brilliant as it is
- 4:00Speaker 2: with language, could totally fumble basic arithmetic, Like ask it
- 4:03Speaker 2: to calculate one two hundred and thirty four module one
- 4:06Speaker 2: twenty three on its own. It might just guess or
- 4:08Speaker 2: get it wrong.
- 4:09Speaker 1: Huh weird. Right, It can write poetry but not do
- 4:12Speaker 1: simple math.
- 4:13Speaker 3: It is kind of paradoxical.
- 4:14Speaker 2: Yeah, And that raised this crucial question, how do you
- 4:18Speaker 2: give this powerful language model capabilities it just doesn't have intrinsically.
- 4:22Speaker 2: Harrison Chase's pivotal realization was, and this is key, the
- 4:26Speaker 2: most interesting LLM applications needed to use lms together with
- 4:30Speaker 2: other sources of computation or knowledge. Laying Chain was essentially
- 4:34Speaker 2: built to provide the building blocks, the interfaces, and the
- 4:38Speaker 2: tooling to reliably combine llms with other things, like giving
- 4:42Speaker 2: it the ability to call out to a calculator when
- 4:44Speaker 2: it sees a math problem.
- 4:46Speaker 1: That makes so much sense giving it tools. So, if
- 4:48Speaker 1: the LLM isn't a calculator or a database itself, how
- 4:51Speaker 1: do we even talk to it effectively? How do we
- 4:53Speaker 1: guide it to do what we need?
- 4:55Speaker 2: Yeah, that's all about prompting. The prompt is basically the
- 4:57Speaker 2: instructions and input you provide to the model, and crucially,
- 5:01Speaker 2: how you phrase that prompt significantly influences the model's output.
- 5:06Speaker 2: There's also this fascinating control called temperature. You can think
- 5:08Speaker 2: of it like a creativity dial. Lower temperature makes the
- 5:11Speaker 2: output more focused, more deterministic, predictable. Higher temperature it lets
- 5:16Speaker 2: the model take more risks, get more creative, maybe even
- 5:19Speaker 2: a bit random, useful for different tasks.
- 5:22Speaker 1: Okay, so prompting is key, temperature, controls, creativity. What are
- 5:26Speaker 1: the main ways we prompt these things?
- 5:28Speaker 2: There are several core techniques, each kind of addressing a
- 5:31Speaker 2: different need. The absolute simplest is zero shot prompting. Just
- 5:35Speaker 2: give it a direct instruction like that example earlier, how
- 5:39Speaker 2: Old was the thirtiest president of the United States when
- 5:41Speaker 2: his wife's mother died. It's straightforward for basic questions, but
- 5:44Speaker 2: you know it can often lead to inaccuracies or just
- 5:47Speaker 2: making things up at the info is and baked into
- 5:49Speaker 2: his training data.
- 5:50Speaker 1: Hallucinations, right, the dreaded hallucinations joys lely.
- 5:53Speaker 2: Then you've got chain of thought or co T. This
- 5:55Speaker 2: is where you literally tell the model think step by step.
- 6:00Speaker 2: It's intriguing because this often dramatically improves performance on reasoning tasks.
- 6:04Speaker 2: It forces the LM to sort of show its work,
- 6:07Speaker 2: break down the problem like we learned in school math
- 6:09Speaker 2: pretty much. But here's a funny quirk. The book notes
- 6:12Speaker 2: that sometimes for tasks where humans also tend to overthink
- 6:16Speaker 2: and make mistakes, COKE can actually make the LLLM perform worse.
- 6:21Speaker 2: A good reminder they aren't just scaled up human brains.
- 6:24Speaker 1: Huh interesting?
- 6:25Speaker 3: What else next?
- 6:27Speaker 1: Up?
- 6:27Speaker 2: And this is fundamental for making lllms useful with your
- 6:30Speaker 2: data is retrieval augmented generation or OURG. This means providing
- 6:36Speaker 2: relevant pieces of text also known as context, directly within
- 6:39Speaker 2: the prompt. So if you want the LLLM to know
- 6:41Speaker 2: about your company's latest internal reporter today's news, you use
- 6:45Speaker 2: OURG to feed at that specific information alongside the question.
- 6:49Speaker 1: Ah okay, so ori is how you give it knowledge
- 6:51Speaker 1: it wasn't trained on precisely.
- 6:53Speaker 2: And then for making lllms do things, there's tool calling.
- 6:56Speaker 2: This lets you give the LM a list of external
- 6:58Speaker 2: functions or calculator. Example, maybe a search engine, API, a
- 7:01Speaker 2: weather service, whatever. You train it to recognize when it
- 7:03Speaker 2: needs a tool and to signal it's intent.
- 7:05Speaker 1: To use it, so it can decide I need to
- 7:07Speaker 1: search for this or I need to calculate that exactly.
- 7:10Speaker 2: And often the most powerful applications combine these techniques. Maybe
- 7:14Speaker 2: use chain of thought to plan or ready to fetch
- 7:16Speaker 2: relevant data, and then tool calling to perform a specific
- 7:20Speaker 2: action or calculation based on that data. Oh and one
- 7:23Speaker 2: more few shot prompting. This is where you give the
- 7:26Speaker 2: LM just a small number of examples, like here's a question,
- 7:28Speaker 2: here's the right kind of answer. It helps it learn
- 7:31Speaker 2: new tasks or formats on the fly without full retraining,
- 7:34Speaker 2: like showing it a few examples to get the hang
- 7:36Speaker 2: of something new.
- 7:37Speaker 1: Wow, Okay, that's a whole toolkit for interacting with them,
- 7:40Speaker 1: and lang chain helps manage all of this.
- 7:41Speaker 3: Yeah, that's the beauty of it.
- 7:43Speaker 2: Lang chain was one of the earliest open source libraries
- 7:46Speaker 2: to provide these core LM and prompting building blocks, and
- 7:49Speaker 2: it's taken off massively. The community is huge, over seventy
- 7:52Speaker 2: two thousand members, twenty eight million downloads a month.
- 7:55Speaker 3: It's staggering.
- 7:56Speaker 2: What lang chain does is offer these simple abstractions for
- 7:59Speaker 2: all those tech niques we just discussed, zero shot solo
- 8:02Speaker 2: t rrag tool calling fushot plus. It integrates seamlessly with
- 8:07Speaker 2: all the major LLLM providers open Ai, Anthropic, Google, and
- 8:11Speaker 2: popular open source models like Lama. This common interface is
- 8:15Speaker 2: a really big deal. It means you can easily experiment,
- 8:17Speaker 2: swap out different llms, and crucially avoid being locked into
- 8:21Speaker 2: a single provider.
- 8:22Speaker 3: That gives you a huge flexibility.
- 8:24Speaker 1: That flexibility sounds key Okay, so this brings us to
- 8:27Speaker 1: a really crucial challenge, especially for us the builders. If
- 8:30Speaker 1: these alans are brilliant, but they fundamentally can't know everything.
- 8:33Speaker 1: They weren't trained on my company's latest financials or yesterday's news,
- 8:36Speaker 1: how do we stop them from just making stuff up,
- 8:38Speaker 1: from hallucinating when we ask about that information.
- 8:41Speaker 3: You've nailed the core problem.
- 8:43Speaker 2: Just relying on the LM's pre train knowledge often isn't
- 8:47Speaker 2: enough for real world apps, precisely because, like you said,
- 8:50Speaker 2: they lack private data stuff not on the public Internet,
- 8:53Speaker 2: and they lack knowledge of current events because of their
- 8:56Speaker 2: knowledge cutoff date.
- 8:57Speaker 3: When they don't have.
- 8:58Speaker 2: The information they need, they tend to hallucinate, generating plausible
- 9:02Speaker 2: sounding but incorrect or even totally fabricated answers.
- 9:06Speaker 1: Which can be dangerous in a real application.
- 9:08Speaker 2: Absolutely, and that's exactly where retrieval augmented generation are AG
- 9:12Speaker 2: becomes essential. It's basically your defense mechanism against hallucination by
- 9:16Speaker 2: providing the necessary context RAG.
- 9:19Speaker 1: So walk us through how it actually works. How does
- 9:21Speaker 1: it ground the LM in specific maybe private or very
- 9:25Speaker 1: current information.
- 9:26Speaker 2: Okay, So, our RAG is specifically designed to enhance the
- 9:30Speaker 2: accuracy of outputs generated by llms by providing context from
- 9:35Speaker 2: external sources. Meta AI actually coined the term, and their
- 9:39Speaker 2: research found that RAG makes models more factual and specific.
- 9:43Speaker 2: The whole process generally involves four key steps for getting
- 9:46Speaker 2: your documents ready, sometimes called ingestion or indexing. First, you
- 9:50Speaker 2: extract the text from whatever documents you have. Lang chain
- 9:53Speaker 2: has helpers for this, like text loater for plain text files,
- 9:56Speaker 2: or pd sloader for PDFs, and many others. Simple enough,
- 10:00Speaker 2: the text out step one. Step two, you split that
- 10:02Speaker 2: text into manageable chunks. This is really important because, as
- 10:06Speaker 2: we mentioned, LM's have a context window, a limit on
- 10:09Speaker 2: how much text they can look at in one go.
- 10:11Speaker 2: Can't just feeding up five hundred page document, right, It's
- 10:13Speaker 2: too big Exactly so, tools like lang teen's where cursive
- 10:16Speaker 2: character text splitter, cleverly break the text down. It tries
- 10:20Speaker 2: to split along natural boundaries first like paragraphs and sentences,
- 10:23Speaker 2: then words. To keep things coherent, you can configure the
- 10:25Speaker 2: chunk size and also add some chunk overlap, meaning consecutive
- 10:28Speaker 2: chunks share a bit of text.
- 10:30Speaker 1: Ah overlap helps maintain context across the breaks.
- 10:34Speaker 2: Precisely, It's like making sure the end of one chapter
- 10:37Speaker 2: flows smoothly into the start of the next third step.
- 10:40Speaker 2: You convert these text chunks into numbers, specifically into embeddings.
- 10:44Speaker 1: Embeddings. Okay, this sounds like where the magic happens.
- 10:47Speaker 3: It kind of is.
- 10:48Speaker 2: Think of an embedding as a long list of numbers
- 10:51Speaker 2: a vector that represents the meaning of that text chunk.
- 10:55Speaker 2: Now it's a lossy representation. You can't perfectly reconstruct the
- 10:58Speaker 2: original words just from the numbers, like you can't get
- 11:01Speaker 2: perfect ced quality back.
- 11:02Speaker 3: From an MP three.
- 11:03Speaker 1: But it captures the essence exactly.
- 11:05Speaker 2: It captures the semantic essence, and this allows for math
- 11:08Speaker 2: on words. This is a huge lead from older systems
- 11:11Speaker 2: that just did keyword searching LM based embeddings or semantic
- 11:15Speaker 2: embeddings understand meaning.
- 11:16Speaker 1: Okay, this is fascinating. How do we teach a computer
- 11:19Speaker 1: the difference between say, lion, pet and dog. I get
- 11:24Speaker 1: the related but how does the computer quantify that? If
- 11:27Speaker 1: we connect this to the bigger picture, this cosign similarity
- 11:31Speaker 1: idea quantifying how close pet and dog are numerically versus lion.
- 11:37Speaker 1: That seems powerful, But how does that number crunching actually
- 11:40Speaker 1: enable better search?
- 11:42Speaker 2: That's a fantastic question. Really gets to the heart of
- 11:44Speaker 2: semantic search. Imagine all these words, or rather the concepts
- 11:48Speaker 2: they represent, existing is points in some vast high dimensional space.
- 11:53Speaker 2: The embedding vectors for pet and dog would literally be
- 11:56Speaker 2: mapped closer together in this space. Then either would be
- 11:58Speaker 2: to lion because they meanings are more related. Cosine similarity
- 12:02Speaker 2: is just the mathematical tool we use to measure the
- 12:04Speaker 2: angle or the closeness between these vectors. It gives a
- 12:07Speaker 2: score usually between natus, one opposite meaning and one identical meaning.
- 12:11Speaker 2: So pet and dog would have a cosine similarity score
- 12:14Speaker 2: much closer to one than pet and lion.
- 12:16Speaker 1: Ah. Okay, so similarity means closer in this meaning space exactly.
- 12:21Speaker 2: And this ability to turn text into embeddings that capture
- 12:24Speaker 2: deep meaning lets us search based on concepts, not just keywords.
- 12:28Speaker 2: You could search for happy house animal and the system
- 12:31Speaker 2: could find documents talking about joyful puppies or content cats.
- 12:35Speaker 2: Even if the exact words happy house or animal aren't there,
- 12:38Speaker 2: it understands the underlying meaning is similar.
- 12:40Speaker 1: That's incredibly powerful search. Okay, so we've extracted, split, and
- 12:44Speaker 1: embedded the text. What's the final step.
- 12:47Speaker 2: The fourth step is to store these embeddings in a
- 12:49Speaker 2: vector store. Think of this as a specialized database designed
- 12:53Speaker 2: to store these numerical vectors and perform those complex similarity
- 12:57Speaker 2: calculations like cosine similarity really efficiently and quickly. There are
- 13:02Speaker 2: lots of options, open source ones like pg vector, an
- 13:05Speaker 2: extension for post cresscool, dedicated databases like wev eight or
- 13:08Speaker 2: pine Cone, or cloud services. When you, the user ask
- 13:12Speaker 2: a question, your question is also converted into an embedding vector.
- 13:16Speaker 2: The vector store then rapidly finds the stored embeddings and
- 13:19Speaker 2: their corresponding text chunks that are most similar mathematically to
- 13:23Speaker 2: your query embedding. Those relevant chunks are then retrieved and
- 13:27Speaker 2: passed to the LLM along with your original.
- 13:29Speaker 1: Question, giving it the specific context it needs to answer
- 13:31Speaker 1: accurate precisely.
- 13:32Speaker 2: And lane Chain also provides tools like its indexing API
- 13:36Speaker 2: and record manager to help keep this vector store up
- 13:38Speaker 2: to date. As your source documents change, you can efficiently
- 13:41Speaker 2: track those changes, add new embeddings, remove old ones, and
- 13:45Speaker 2: avoid costly reprocessing of unchanged documents, keeping the knowledge current.
- 13:49Speaker 1: Okay, that makes sense. We've got the basic arget pipeline down,
- 13:53Speaker 1: index the data, retrieve relevant chunks, give them to the LLM.
- 13:57Speaker 1: But I imagine building something truly production ready involves more nuance.
- 14:02Speaker 1: What are the common challenges and how do we refine
- 14:05Speaker 1: that search for knowledge to be even more accurate and robust?
- 14:08Speaker 2: Yeah, moving from a basic a RAGI demo to production
- 14:12Speaker 2: definitely introduces complexity. Users ask questions in all sorts of ways,
- 14:15Speaker 2: sometimes ambiguously. Your data might live in multiple different places,
- 14:19Speaker 2: and you often need to translate that natural language question
- 14:22Speaker 2: into something more structured for retrieval. So we need more
- 14:25Speaker 2: advanced strategies.
- 14:26Speaker 1: Okay, what are they?
- 14:26Speaker 2: The book highlights three main categories of strategy. The first
- 14:30Speaker 2: is query transformation. The idea here is to modify the
- 14:33Speaker 2: user's input before you even search to improve the chances
- 14:36Speaker 2: of finding the best documents.
- 14:38Speaker 1: Ah, like cleaning up the question first exactly.
- 14:40Speaker 2: One technique is rewrite retrieve read. Here, you actually use
- 14:44Speaker 2: another LM call first just to rewrite the user's potentially
- 14:47Speaker 2: vague or conversational query into a clearer, more focused search query.
- 14:51Speaker 2: Then you use that rewritten query for the retrieval step.
- 14:54Speaker 1: Smart like having an assistant clarify your question before searching.
- 14:58Speaker 1: Does it add much delay?
- 15:00Speaker 2: Yeah, it's a little bit of latency. Yeah, because it's
- 15:02Speaker 2: an extra LM call, but often the improvement in retrieval
- 15:06Speaker 2: quality is worth it. Another transformation technique is multi query retrieval.
- 15:11Speaker 2: Instead of just one query, you have the LMM generate
- 15:14Speaker 2: multiple versions of the given user question, maybe from slightly
- 15:18Speaker 2: different angles or using different keywords.
- 15:20Speaker 1: Oh interesting, why do that?
- 15:21Speaker 2: It's great for complex questions that might need information from
- 15:24Speaker 2: multiple perspectives. You run retrievals for all those generated queries
- 15:28Speaker 2: in parallel, then combine the unique documents found. It casts
- 15:31Speaker 2: a wider net, reducing the chance you miss something important.
- 15:35Speaker 2: Building on that is RAG fusion. It starts like multiquery,
- 15:39Speaker 2: generating multiple queries and retrieving results for each, but then
- 15:42Speaker 2: it has a crucial final re ranking step using something
- 15:45Speaker 2: called the reciprocal rank of fusion.
- 15:47Speaker 3: RF algorithm.
- 15:49Speaker 1: Sounds technical.
- 15:50Speaker 2: It's a clever way to combine the rankings from all
- 15:52Speaker 2: the different searches. Documents that consistently rank highly across multiple
- 15:57Speaker 2: queries get boosted to the very top. Really effective at
- 16:00Speaker 2: finding the most relevant stuff while also broadening discovery.
- 16:03Speaker 1: Okay, so RF aggregates the wisdom of multiple searches. Cool
- 16:07Speaker 1: any other transformation tricks?
- 16:09Speaker 2: One more interesting one is hypothetical document embeddings or Heidi
- 16:14Speaker 2: this kind of counterintuitive. Instead of searching with the user's query,
- 16:17Speaker 2: you first have an LM create a hypothetical document that
- 16:21Speaker 2: would be a perfect answer to the query.
- 16:23Speaker 1: Wait, it makes up an answer first.
- 16:24Speaker 3: Yeah.
- 16:25Speaker 2: The intuition is that this generated ideal answer, even though
- 16:28Speaker 2: it's hypothetical, is often semantically more similar to the actual
- 16:32Speaker 2: relevant documents than the original maybe short or ambiguous user query.
- 16:37Speaker 2: So you embed this hypothetical answer and use that embedding
- 16:41Speaker 2: for the similarity search.
- 16:42Speaker 1: Huh, that's sliver. Using an ideal answer is a better
- 16:45Speaker 1: search query? Okay, so that's query transformation. What's the second strategy?
- 16:49Speaker 2: The second strategy is query routing. This tackles the problem
- 16:53Speaker 2: you mentioned earlier. What if your data lives in different places.
- 16:57Speaker 2: Maybe you have Python docks in one vector store and
- 17:00Speaker 2: JavaScript docs in another.
- 17:02Speaker 1: Right, how do you send the query to the right place?
- 17:04Speaker 2: That's exactly what quer routing does, forward a user's query
- 17:08Speaker 2: to the relevant data source. There are a couple of
- 17:11Speaker 2: ways logical routing uses an LLM to make the decision.
- 17:15Speaker 2: You give the LM descriptions of your available data sources,
- 17:18Speaker 2: like this index contains technical documentation for Python and Based
- 17:23Speaker 2: on the user's query, the LM picks which of the
- 17:25Speaker 2: available indexes to use. Lang chain helps ensure the LM
- 17:29Speaker 2: outputs its choice in a structured way your application can understand.
- 17:32Speaker 1: So the LLM acts like a switchboard operator kind of.
- 17:35Speaker 3: Yeah.
- 17:36Speaker 2: Alternatively, there's semantic routing.
- 17:38Speaker 3: Here.
- 17:39Speaker 2: You embed the descriptions of your data sources themselves. Then
- 17:42Speaker 2: you compare the user's query embedding to these description embeddings.
- 17:45Speaker 2: The closest match indicates the most relevant data source. This
- 17:48Speaker 2: is more dynamic, doesn't require an LLLM call for every
- 17:51Speaker 2: routing decision.
- 17:52Speaker 1: Okay, route it logically or semantically makes sense. What's the
- 17:55Speaker 1: third major strategy?
- 17:57Speaker 2: The third is query construction. This is about transforming a
- 18:00Speaker 2: natural language query into the query language of the database
- 18:04Speaker 2: or data source you were interacting with. It goes beyond
- 18:07Speaker 2: just finding similar text chunks. Oh so, well, maybe you
- 18:10Speaker 2: need to combine semantic search with traditional database filters. Text
- 18:14Speaker 2: to metadata filter is a technique where the LLM extracts
- 18:17Speaker 2: structured information like a date, a category, a price range
- 18:21Speaker 2: directly from the user's natural language query.
- 18:24Speaker 1: Ah so, if I ask for sci fi movies from
- 18:26Speaker 1: the eighties, it pulls out sci fi for semantic search
- 18:29Speaker 1: and nineteen eighties as a metadata filter exactly.
- 18:32Speaker 2: It lets you combine the power of semantic understanding with
- 18:35Speaker 2: the precision of structured filters. Another big one here is
- 18:38Speaker 2: text to seql. This involves having the LM translate a
- 18:41Speaker 2: natural language question like what were our total sales in
- 18:45Speaker 2: Q three directly into an executable SQL query to run
- 18:48Speaker 2: against a traditional relational database.
- 18:50Speaker 1: Wow, that's powerful. How do you make that reliable? SQL?
- 18:53Speaker 1: Can be tricky?
- 18:54Speaker 2: It requires careful setup. You usually need to provide the
- 18:57Speaker 2: LLM with a description of the database scheme like the
- 19:00Speaker 2: create table statements, maybe some example rows, and often some
- 19:04Speaker 2: few shot examples of natural language questions paired with their
- 19:08Speaker 2: correct SQL queries.
- 19:09Speaker 3: To guide it.
- 19:10Speaker 1: Got it? So, text to sqel translates language to database code.
- 19:14Speaker 2: If we connect this text to SQL capability to the
- 19:17Speaker 2: bigger picture. Though, while it's incredibly powerful, letting an LEBLEM
- 19:21Speaker 2: generate SQL queries directly from potentially untrusted user input is
- 19:25Speaker 2: one of the riskiest things you can do in a
- 19:27Speaker 2: production application. Ah.
- 19:29Speaker 1: Security implications, Yeah, I can see that.
- 19:31Speaker 2: Absolutely. This raise is a really important question around safety.
- 19:35Speaker 2: You must implement critical security measures, things like ensuring the
- 19:38Speaker 2: database connection has read only permissions, strictly limiting access to
- 19:42Speaker 2: only the necessary tables, maybe even views, and definitely adding
- 19:45Speaker 2: query timeouts to prevent denial of service attacks or runaway queries.
- 19:49Speaker 2: It's a capability that demands extreme caution and robust safeguards.
- 19:54Speaker 1: Absolutely crucial point. Okay, this is getting really interesting, especially
- 19:57Speaker 1: for building interactive apps. How do we tackle the fact
- 20:00Speaker 1: that lllms are inherently forgetful. How do we give them
- 20:04Speaker 1: memory to actually hold a conversation, especially as things get
- 20:07Speaker 1: more complex.
- 20:08Speaker 2: Yeah, you've hit on a fundamental aspect. Llms are stateless.
- 20:12Speaker 2: Every time you interact with them. It's like a fresh start.
- 20:14Speaker 2: There's no memory of the prior prompt or model response
- 20:17Speaker 2: built in. It's like talking to someone who forgets everything
- 20:21Speaker 2: you just said every.
- 20:22Speaker 1: Single turn, which isn't great for a chatbot.
- 20:24Speaker 3: Not at all.
- 20:26Speaker 2: The simplest way to build memory is just to literally
- 20:29Speaker 2: store the history of the chatter, all the user messages
- 20:32Speaker 2: and assistant responses as a list, and then include that
- 20:35Speaker 2: entire list in the prompt for the next turn.
- 20:37Speaker 1: Okay, just stuff the whole conversation history back in.
- 20:40Speaker 2: Basically, Yeah, yeah, but you can imagine at scale. That
- 20:43Speaker 2: gets tricky. How do you update that history reliably? How
- 20:46Speaker 2: do you manage state? When you have multiple things happening,
- 20:49Speaker 2: maybe multiple actors or steps in your application? It gets
- 20:53Speaker 2: complicated fast. And that's precisely where langgraf enters the picture.
- 20:57Speaker 2: Lang graph acts as the coordination layer these more complex,
- 21:01Speaker 2: multi step, potentially multi actor applications. It's what allows them
- 21:04Speaker 2: to remember state and coordinate actions over time.
- 21:08Speaker 1: Lang grap Okay, how does it work? Is it like
- 21:09Speaker 1: a state machine?
- 21:10Speaker 2: You think of it kind of like designing a flow
- 21:12Speaker 2: chart for your AI app. It is three core components. First,
- 21:16Speaker 2: there's the state. This is the shared data that evolves
- 21:20Speaker 2: over the course of the application run. It can include
- 21:22Speaker 2: the chat history, intermediate results, anything the application needs to remember. Second,
- 21:27Speaker 2: you have nodes. These are the individual steps or functions
- 21:30Speaker 2: in your flow chart. A node might be a call
- 21:32Speaker 2: to an LM, a call to a tool like our
- 21:36Speaker 2: calculator or search engine, or just some regular Python code
- 21:38Speaker 2: that processes the state. And Third, you have edges. These
- 21:41Speaker 2: are the connections between the nodes, determining the flow of execution.
- 21:45Speaker 2: Edges can be fixed like always go from no day
- 21:47Speaker 2: to node B, or they.
- 21:48Speaker 1: Can be conditional conditional edges, meaning.
- 21:51Speaker 2: Meaning the next step depends on the current state. Often,
- 21:55Speaker 2: an LM in one node might decide which node to
- 21:58Speaker 2: go to next, making the flow dynamic. A huge benefit
- 22:01Speaker 2: of lang graph is its built in persistence. It uses
- 22:04Speaker 2: something called a checkpointer. You can think of it like
- 22:06Speaker 2: an auto save.
- 22:07Speaker 1: Function AH, so it saves the state automatically exactly.
- 22:10Speaker 2: It saves the current state after each step. This means
- 22:13Speaker 2: that every invocation after the first doesn't start from blank slate.
- 22:18Speaker 2: If the app crashes or the user comes back later,
- 22:21Speaker 2: it can pick up right where it left off from
- 22:22Speaker 2: the last save state. Really important for long running or
- 22:25Speaker 2: stateful interactions.
- 22:27Speaker 1: That's huge for usability. What about that growing chat history though,
- 22:31Speaker 1: Does lang graph help manage that so you don't overload
- 22:33Speaker 1: the LLM?
- 22:34Speaker 3: Yes? Absolutely.
- 22:36Speaker 2: While lang graph manages the overall state persistence, you still
- 22:39Speaker 2: use lane chain's utilities within your nodes to manage the
- 22:42Speaker 2: specific chat history part of the state before passing.
- 22:45Speaker 3: It to an LLM.
- 22:46Speaker 2: You can indeligently filter messages, maybe keeping only summaries or
- 22:49Speaker 2: key turns, trim the history based on the number of
- 22:52Speaker 2: messages or total tokens, or even merge older parts of
- 22:55Speaker 2: the conversation into a concise summary, all designed to keep
- 22:58Speaker 2: the context relevant without ex eating.
- 23:00Speaker 3: Those M limits.
- 23:01Speaker 1: Okay, so lang graph orchestrates the flow in memory, and
- 23:04Speaker 1: lang chain helps manage the conversation content. That makes sense.
- 23:08Speaker 1: So we've gone from just calling an LLLM once to
- 23:10Speaker 1: chains and now to the state ful lang graph applications.
- 23:14Speaker 1: How should we think about the different levels of complexity
- 23:17Speaker 1: and I guess intelligence in these systems.
- 23:20Speaker 2: That's a great way to frame it. We can think
- 23:21Speaker 2: about a progression of cognitive architectures moving towards more sophisticated applications,
- 23:27Speaker 2: and as we move up this ladder, we constantly grapple
- 23:30Speaker 2: with that fundamental trade off we mentioned agency, the lmm's
- 23:33Speaker 2: capacity to act autonomously, and reliability the degree to which
- 23:37Speaker 2: we can trust its outputs. More autonomy often means less predictability.
- 23:41Speaker 1: Right the agency versus reliability balance.
- 23:43Speaker 3: So progression looks something like this.
- 23:45Speaker 2: At the base, you have a simple LM call, one input,
- 23:47Speaker 2: one output, like asking get to summarize text. Simple, usually
- 23:51Speaker 2: reliable for that specific task. Next level up is a chain.
- 23:54Speaker 2: This involves multiple LELLM calls or calls to tools executed
- 23:58Speaker 2: in a pre defined fixed sequence. Example, step one LLLLM
- 24:02Speaker 2: generates a SEQL query. Step two different M explains that
- 24:05Speaker 2: query in plain English. The sequence never changes.
- 24:09Speaker 1: Okay, fixed steps like an assembly.
- 24:11Speaker 2: Line pretty much. Then it gets more dynamic with the router. Here,
- 24:14Speaker 2: an LOM decides the sequence of steps. At runtime, it
- 24:17Speaker 2: chooses which pre defined path to take based on the input.
- 24:20Speaker 2: Like an earlier example, if it's a medical question, rode
- 24:23Speaker 2: to the medical index, if insurance route to the FAQ index.
- 24:27Speaker 2: The LOLLM makes a choice, but the possible paths are
- 24:29Speaker 2: still pre defined.
- 24:30Speaker 1: So it adds a decision point. And beyond writers, we
- 24:33Speaker 1: finally get to agents. That seems to be the buzzword
- 24:37Speaker 1: everyone's excited about.
- 24:38Speaker 2: Exactly an agent is quite simply something that acts. What
- 24:42Speaker 2: makes agent architectures unique and powerful is that they use
- 24:46Speaker 2: an LLLM driven loop for control. The LM isn't just
- 24:49Speaker 2: executing pre defined steps. It's deciding what to do next
- 24:53Speaker 2: based on the result of its previous actions, and critically,
- 24:55Speaker 2: it decides when to stop. The most common pattern here
- 24:58Speaker 2: is the plan do loop, often called the react to
- 25:01Speaker 2: architecture reasoning plus acting plan do loop.
- 25:04Speaker 1: How does that work in practice?
- 25:05Speaker 2: Imagine an agent needs to answer a complex question that requires, say,
- 25:09Speaker 2: searching the web and then doing a calculation. Step one,
- 25:14Speaker 2: Them gets the question, observes. Step two, it thinks, for reasons, okay,
- 25:19Speaker 2: answer this, I first need to search for X. Step three,
- 25:22Speaker 2: it plans an action, call the search tool with query X.
- 25:25Speaker 2: Step four, the system executes, the search tool does step five.
- 25:28Speaker 2: Them gets the search results back, observes again. Step six,
- 25:32Speaker 2: It thinks again, okay, based on these results, now we.
- 25:35Speaker 3: Need to calculate why using the calculator tool.
- 25:37Speaker 2: Step seven, it plans the next action, call the calculator
- 25:40Speaker 2: with inputs A and B. Step eight, the system executes
- 25:43Speaker 2: the calculator does. Step nine. The LOM gets the calculation
- 25:46Speaker 2: result observes.
- 25:47Speaker 3: Step ten.
- 25:48Speaker 2: It thinks, one last time, okay, now I have all
- 25:50Speaker 2: the pieces I can formulate the final answer. It decides
- 25:52Speaker 2: the loop is finished. Step eleven, it outputs the final
- 25:55Speaker 2: answer to the user. See how the LOM is driving
- 25:57Speaker 2: the whole process, deciding which tool to use one and
- 26:00Speaker 2: ultimately deciding when it's done. That iterative self directed loop
- 26:03Speaker 2: is the core of an agent. Plank graph is perfect
- 26:05Speaker 2: for implementing these loops using its nodes for the LLM
- 26:08Speaker 2: calls and tool executions and conditional edges to route the
- 26:12Speaker 2: flow based on the LM's decisions.
- 26:14Speaker 1: Wow, okay, that really clarifies it. The LLM is in
- 26:18Speaker 1: the driver's seat, choosing actions and deciding when the job
- 26:21Speaker 1: is done. That's a big step up in autonomy. Can
- 26:24Speaker 1: we make these agents even smarter?
- 26:26Speaker 2: Definitely? There are enhancements. For instance, you might design the
- 26:29Speaker 2: agent to always call a tool first, maybe always starting
- 26:33Speaker 2: with a search to ensure its reasoning is grounded in
- 26:35Speaker 2: current information before it even tries to answer. Another challenge
- 26:39Speaker 2: arise is when you have many possible tools, how does
- 26:42Speaker 2: the agent pick the right one? You can actually use
- 26:45Speaker 2: our rag on the tool descriptions. Store descriptions of all
- 26:48Speaker 2: your tools in a vector store, and when the agent
- 26:51Speaker 2: decides it needs a tool, it first does a semantic
- 26:53Speaker 2: search over the tool descriptions to find the most relevant
- 26:56Speaker 2: one for the.
- 26:56Speaker 1: Task at hand, using our rig to help the agent
- 26:59Speaker 1: choose its own tools. That's pretty meta. This sounds incredibly powerful,
- 27:02Speaker 1: giving models the ability to genuinely tackle multi step problems.
- 27:06Speaker 1: Can they go even further?
- 27:07Speaker 3: Like?
- 27:08Speaker 1: Can agents learn or work together or maybe even critique
- 27:11Speaker 1: their own work?
- 27:12Speaker 3: Yes? Absolutely, to all of those.
- 27:14Speaker 2: One really powerful extension is reflection or self critique. This
- 27:19Speaker 2: involves setting up a kind of loop, often using multiple
- 27:21Speaker 2: LLM calls that mimics how humans create and refine things.
- 27:25Speaker 2: You might have a creator prompt that generates a first
- 27:27Speaker 2: draft of something, say in an essay. Then you have a
- 27:30Speaker 2: separate revisor prompt with the LLLM critiques that draft based
- 27:33Speaker 2: on specific criteria like clarity, tone, fascial accuracy. Finally, the
- 27:38Speaker 2: original lam or another one revises the draft based on that.
- 27:42Speaker 1: Critique, so it acts as its own editor exactly.
- 27:44Speaker 2: It allows the LM to refine its output, maybe catch
- 27:47Speaker 2: errors or improved style. You can eat something of the
- 27:50Speaker 2: revisor LLM to adopt a different persona while critiquing, like
- 27:53Speaker 2: asking it to review the essay from the perspective of
- 27:56Speaker 2: a skeptical historian. This iterative refinement can significately boost quality.
- 28:01Speaker 1: That's amazing. What about teamwork? Can you have multiple agents collaborating?
- 28:05Speaker 2: Yes, for really complex problems that might be too much
- 28:08Speaker 2: for a single agent, maybe requiring too many different tools
- 28:11Speaker 2: or too much context, you can use multi agent architectures.
- 28:15Speaker 2: You literally build teams of LVM agents that work together.
- 28:19Speaker 2: There are different ways to coordinate these teams, but a
- 28:21Speaker 2: practical approach highlighted in the book is the supervisor architecture.
- 28:25Speaker 2: Here you have a central supervisor agent often an element self,
- 28:29Speaker 2: whose job is to manage the workflow based on the
- 28:32Speaker 2: overall goal and the current state. The supervisor decides which
- 28:35Speaker 2: agent or agents should be called next. It wrote tasks
- 28:39Speaker 2: to specialize subagents. Maybe one agent is good at research,
- 28:43Speaker 2: another at writing code, another at summarizing. Their progress and
- 28:47Speaker 2: results are often shared in a central place, like a
- 28:49Speaker 2: list of messages in the lang graft state, allowing them
- 28:52Speaker 2: to build on each other's work. It enables true collaborative
- 28:55Speaker 2: problem solving among AI agents.
- 28:57Speaker 1: So what does this all mean? We're talking about building
- 28:59Speaker 1: digital teams that can think, plan, act, reflect on their actions,
- 29:03Speaker 1: and even critique their own work. It feels like this
- 29:06Speaker 1: genuinely expands the kinds of problems we can even attempt
- 29:09Speaker 1: to solve with AI.
- 29:10Speaker 2: It really does, and it brings us right back to
- 29:12Speaker 2: the fundamental tension we keep mentioning the trade off between
- 29:15Speaker 2: agency and reliability. As these agents become more autonomous, controlling
- 29:20Speaker 2: them and trusting their output becomes even more critical. If
- 29:24Speaker 2: we zoom out again, and connect this to the bigger picture.
- 29:27Speaker 2: You can visualize this trade off as a kind of
- 29:29Speaker 2: frontier on a graph. You want to push that frontier outwards,
- 29:33Speaker 2: achieve more agency for the same level of reliability, or
- 29:36Speaker 2: achieve higher reliability for the same level of agency. Pushing
- 29:39Speaker 2: this frontier is key to building production ready applications people
- 29:43Speaker 2: can actually depend on.
- 29:44Speaker 1: Right, trust is paramount, So specifically, how do we improve
- 29:47Speaker 1: the actual user experience and maybe more importantly, the reliability
- 29:51Speaker 1: and control in these powerful, sometimes complex, agentic systems.
- 29:55Speaker 2: Great question. There are several vital techniques discussed in the book.
- 29:58Speaker 2: First off, managing latency p reception with streaming an intermediate output.
- 30:02Speaker 2: LLM calls, especially in complex agent loops, can take time.
- 30:05Speaker 2: A few seconds of waiting can feel long to a user,
- 30:08Speaker 2: so communicating progress makes that higher latency more palatable. This
- 30:13Speaker 2: includes dreaming the llm's final output token by token so
- 30:17Speaker 2: the text appears gradually like someone typing.
- 30:19Speaker 1: Makes it feel more responsive exactly.
- 30:21Speaker 2: It also includes showing intermediate steps maybe messages like okay,
- 30:25Speaker 2: searching for X or now calculating Y, so the user
- 30:28Speaker 2: sees the agent as working. Second, and absolutely critical for
- 30:32Speaker 2: reliability is ensuring structured output. You often need the LLM
- 30:36Speaker 2: to return information in a specific predictable format like Jason,
- 30:40Speaker 2: not just freeform text. Linke dams with structure output method
- 30:43Speaker 2: is designed for this. It helps reduce variants and ensures
- 30:46Speaker 2: downstream systems can reliably parse and use the llm's output.
- 30:50Speaker 2: Using a low temperature setting often helps here too.
- 30:52Speaker 1: So you get predictable data structures back, not just a
- 30:55Speaker 1: chatty response precisely.
- 30:57Speaker 2: Third, especially for high agency applications, you need human in
- 31:01Speaker 2: the loop controls. These give essential oversight to the end user,
- 31:05Speaker 2: allowing intervention and correction. One control is interrupt The user
- 31:12Speaker 2: should be able to manually stop an ongoing agent process
- 31:15Speaker 2: at any time. Ideally the state is saved, so they
- 31:18Speaker 2: can choose to resume later, restart, or just abandon it.
- 31:21Speaker 2: If the agent's going off track. A panic button basically
- 31:24Speaker 2: kind of another is authorized. The application pauses before performing
- 31:28Speaker 2: a potentially critical or irreversible action, maybe sending an email,
- 31:32Speaker 2: making a purchase, modifying a file, and ask the user
- 31:35Speaker 2: for explicit confirmation is it okay to do this?
- 31:38Speaker 1: Essential for safety absolutely.
- 31:40Speaker 2: And then there's the ability to fork and replay history.
- 31:43Speaker 2: This allows the user to effectively go back in time
- 31:45Speaker 2: to an earlier point in the conversation or workflow state,
- 31:48Speaker 2: and then start a new branch from there, trying a
- 31:49Speaker 2: different approach. It's fantastic for experimentation, debugging, and recovering from
- 31:54Speaker 2: errors without starting over completely.
- 31:56Speaker 1: Those controls sound invaluable for making these powerful systems usable
- 32:00Speaker 1: end safe in the real world. Okay, what about a
- 32:03Speaker 1: common scenario. Llms can be a bit slow. What happens
- 32:08Speaker 1: if a user sends a new message while the agent
- 32:10Speaker 1: is still thinking about the previous one. How does systems
- 32:13Speaker 1: handle that concurrency?
- 32:14Speaker 2: That's the challenge of multitasking lllms. Handling concurrent inputs lms
- 32:19Speaker 2: are often quite slow compared to traditional software responses. Users
- 32:24Speaker 2: will send follow up messages or new requests before the
- 32:26Speaker 2: first one is finished. There are different strategies. The simplest
- 32:29Speaker 2: is just to refuse concurrent input maybe disable the input
- 32:32Speaker 2: box while processing.
- 32:33Speaker 1: Not very user friendly, Yeah, frustrating.
- 32:36Speaker 3: Right.
- 32:36Speaker 2: You can handle each input independently in a new thread,
- 32:39Speaker 2: but that might lose conversational context. You could queue inputs,
- 32:42Speaker 2: processing them one after another, or you can interrupt the
- 32:45Speaker 2: current run to prioritize the new input, either abandoning the
- 32:48Speaker 2: old one or trying to save its partial state. This
- 32:51Speaker 2: raises an interesting question. If an LLM is mid computation
- 32:54Speaker 2: and you send another message, how should it respond intelligently?
- 32:58Speaker 2: The book mentions in advanced sategy called.
- 33:00Speaker 3: Fork and merge.
- 33:01Speaker 1: Fork and merge.
- 33:02Speaker 2: Yeah, The idea is the system temporarily forks the agent's
- 33:06Speaker 2: current state. When new input arrives, it processes the new
- 33:09Speaker 2: input in parallel, perhaps starting from that fork state. Then
- 33:13Speaker 2: somehow it intelligently merges the results or final states from
- 33:17Speaker 2: both the original computation and the new parallel one. It's
- 33:20Speaker 2: complex to implement correctly, requiring careful steat management, but it
- 33:24Speaker 2: could allow for very fluid interruption tolerant interactions.
- 33:28Speaker 1: Wow. Okay, that sounds complex but powerful for smooth interaction.
- 33:32Speaker 3: Yeah.
- 33:33Speaker 1: So we've designed the core logic, we've added memory with
- 33:36Speaker 1: lang graph, We've considered reliability and UX controls. Now, how
- 33:39Speaker 1: do we actually get this thing out of our development
- 33:41Speaker 1: environment and deployed for external users, making sure it's stable
- 33:45Speaker 1: and can handle real.
- 33:46Speaker 2: Traffic Right the production leak? This is where things get serious.
- 33:49Speaker 2: The book highlights lang graph platform as a solution here.
- 33:53Speaker 2: It's essentially a managed service for deploying and hosting lang
- 33:56Speaker 2: graph agents at scale. Its goal is to handle the
- 33:58Speaker 2: operational headachesction. It provides things like horizontally scaling task queues
- 34:04Speaker 2: and servers to handle many concurrent users, plus a robust
- 34:08Speaker 2: postgress checkpointer for efficiently storing potentially large states and conversation threads.
- 34:13Speaker 2: The aim is fault tolerant scalability, so.
- 34:16Speaker 1: It takes care of the scaling and reliability infrastructure.
- 34:19Speaker 3: That's the idea.
- 34:20Speaker 2: Now, before you deploy there, you'll need a few prerequisite
- 34:23Speaker 2: setup your apikeys from your LLM provider like OpenAI, a
- 34:27Speaker 2: configured vector store if you're using RWI. The book mentioned
- 34:31Speaker 2: Superbase with its pg vector extension is a good option,
- 34:35Speaker 2: and you'll need a langsmith account because lang graft platform
- 34:38Speaker 2: is tightly integrated with langsmith for monitoring and debugging.
- 34:41Speaker 1: Langsmith. What's that?
- 34:42Speaker 2: Langsmith is another part of the lang sching ecosystem focus
- 34:45Speaker 2: specifically on observability, debugging, testing and monitoring for LLLM applications.
- 34:50Speaker 2: It's pretty crucial for the whole life cycle.
- 34:52Speaker 1: Okay, got it, So you set up prerequisites, then how
- 34:55Speaker 1: do you deploy to lang graph platform.
- 34:57Speaker 2: The process is designed to be fairly straightforward. You typically
- 35:00Speaker 2: define your lang graph application structure in a configuration file,
- 35:04Speaker 2: often the langgraph dot json. You can test it locally
- 35:07Speaker 2: using the lang graph command line interface the CLI with
- 35:10Speaker 2: a command like lang grafh dev, and then deployment to
- 35:13Speaker 2: the managed platform is often done via one click submissions
- 35:16Speaker 2: directly from the langsmith user interface.
- 35:18Speaker 1: Okay, seems streamlined, but deployment isn't the end, right. We
- 35:23Speaker 1: keep coming back to the fact that llms are non
- 35:25Speaker 1: deterministic and prone to hallucination. How do we build and
- 35:29Speaker 1: maintain trust after launch? How does continuous improvement work in
- 35:33Speaker 1: this AI world?
- 35:34Speaker 2: This is absolutely critical. Deployment is just the beginning of
- 35:37Speaker 2: the journey. You need that continuous improvement cycle. Design, test
- 35:40Speaker 2: data is deployed on monitor and fixed JAD redesign. Even
- 35:43Speaker 2: in the design stage, you can build in defensiveness like
- 35:46Speaker 2: that self corrective our gag idea we touched on earlier.
- 35:49Speaker 2: You can have an LLLM within your agent's flow whose
- 35:51Speaker 2: job is to grade retrieval relevance. Did we find good
- 35:54Speaker 2: documents and check the answer for hallucinations before showing it
- 35:58Speaker 2: to the user.
- 35:59Speaker 1: The LM double checks itself yeah.
- 36:01Speaker 2: And if it decides the retrieval was poor or the
- 36:03Speaker 2: answer looks suspicious, it could trigger a fallback. Maybe try
- 36:07Speaker 2: a web search instead, or ask the user for clarification.
- 36:10Speaker 2: Building self correction right into the design. Then comes pre
- 36:14Speaker 2: production testing. This is all about measuring accuracy, latency, cost,
- 36:18Speaker 2: whatever metrics matter to you before you expose the app
- 36:21Speaker 2: to real users. For this, you need good data sets.
- 36:24Speaker 1: Where do those data sets come from?
- 36:26Speaker 2: Several sources. You can have manually curated examples humans carefully
- 36:30Speaker 2: writing good questions and ideal answers. You can use application
- 36:33Speaker 2: logs from early internal testing or beta users, or you
- 36:36Speaker 2: can even generate synthetic data using other lolms to create
- 36:40Speaker 2: diverse examples of inputs and outputs. Langsmith actually has tools
- 36:43Speaker 2: specifically for creating and managing these test data sets. Once
- 36:47Speaker 2: you have data, you need evaluation criteria. You compare your
- 36:50Speaker 2: app's output against some ground truth references.
- 36:52Speaker 3: How do you evaluate? You can use human evaluators people.
- 36:55Speaker 2: Giving quolitative feedback on nuance, tone correctness, very valuable, but
- 37:00Speaker 2: slow and expensive. You can use heuristic evaluators basically simple
- 37:04Speaker 2: hard code of checks like does the output contain the
- 37:06Speaker 2: specific keyword? Is a below a certain length? Quick, but
- 37:09Speaker 2: limited increasingly popular lmms is a judge evaluators. Here, you
- 37:13Speaker 2: use another LM, give it a real quick and ask
- 37:16Speaker 2: it to score or critique your application's output based.
- 37:19Speaker 3: On that rubric.
- 37:19Speaker 1: Using an LM to judge another LLLM exactly.
- 37:23Speaker 2: And what's really fascinating here, Lanksmith has this clever feedback loop.
- 37:27Speaker 2: If a human corrects or disagrees with the LM as
- 37:30Speaker 2: a judge's assessment, lank Smith captures that correction and automatically
- 37:34Speaker 2: turns it into a fu shot example that gets added
- 37:37Speaker 2: back into the judge's prompt for future evaluations.
- 37:40Speaker 1: Wow, so the judging LLM actually learns from human corrections
- 37:44Speaker 1: over time.
- 37:44Speaker 2: Precisely, it helps the automated evaluation along better with human preferences,
- 37:49Speaker 2: reducing the need for constant manual prompt tweaking for the judge.
- 37:53Speaker 2: It's a really smart self improving mechanism. You also need
- 37:56Speaker 2: rigorous regression testing. As you update your code or even
- 38:00Speaker 2: the underlying LLLM models change model drift, you need to
- 38:04Speaker 2: constantly rerun your tests to prevent regression and sure you
- 38:07Speaker 2: haven't accidentally made things worse. Langsmith's comparison view is designed
- 38:11Speaker 2: to help spot these performance changes over time, and for
- 38:14Speaker 2: complex agents, evaluation needs to happen on multiple levels the
- 38:17Speaker 2: final response, but also individuals single step decisions like did
- 38:21Speaker 2: it pick the right tool, and even the entire trajectory,
- 38:24Speaker 2: the sequence of actions it took.
- 38:25Speaker 1: Okay, that's a lot of testing before launch.
- 38:27Speaker 2: What about after production? Monitoring is crucial for catching bugs
- 38:30Speaker 2: and weird edge cases that only emerge with real users
- 38:33Speaker 2: and real world data. Lang Smith is key here again
- 38:37Speaker 2: providing tracing to track exactly what happened inside your agent
- 38:40Speaker 2: when it error occurred or user gave bad feedback. You
- 38:43Speaker 2: need mechanisms for collecting feedback and production, maybe simple thumbs
- 38:47Speaker 2: updown buttons, annotation ques where users or internal teams can
- 38:50Speaker 2: flag issues, or even running those LMM as a judge
- 38:53Speaker 2: evaluators on live traffic samples. You can also implement classification
- 38:57Speaker 2: and tagging on inputs and outputs, checking for things like toxicity,
- 39:01Speaker 2: personally identifiable information, or even trying to detect prompt injection attacks.
- 39:05Speaker 2: These act as safety guardrails and a really important practical tip.
- 39:09Speaker 2: Release your app in phases. Start with a small group
- 39:12Speaker 2: of Beata users, gather feedback, fix issues, then gradually expand
- 39:16Speaker 2: the rollout. Don't just flip the switch for everyone on
- 39:18Speaker 2: day one.
- 39:19Speaker 1: So what this all really means, this continuous cycle of design, testing, evaluation, monitoring, fixing.
- 39:27Speaker 1: It's not just about squashing bugs, is it. It feels
- 39:29Speaker 1: like it's about systematically building confidence and trust in these
- 39:33Speaker 1: incredibly powerful but inherently probabilistic systems. It's about making them
- 39:37Speaker 1: reliable enough for the real world. Okay, thinking bigger picture, now,
- 39:41Speaker 1: let's unpack this idea. Llms are amazing because they're so intuitive, right,
- 39:46Speaker 1: They often understand what we mean, even with typos or
- 39:48Speaker 1: slightly vague questions. That's fantastic. But that same flexibility means
- 39:53Speaker 1: their output isn't always perfectly predictable. It can be slightly off,
- 39:56Speaker 1: and that challenges our traditional software interfaces, which we usually
- 39:59Speaker 1: build expecting very precise, deterministic results. How is this fundamental
- 40:04Speaker 1: difference going to change the way we actually interact with software.
- 40:06Speaker 3: That's a really profound question. You're right.
- 40:08Speaker 2: Traditionally UIs think Microsoft Word, Figma spreadsheets. They have fixed
- 40:13Speaker 2: tool pallettes, predictable menus canvases where actions have precise, repeatable
- 40:18Speaker 2: outcomes because the underlying logic is deterministic LLLM powered applications
- 40:23Speaker 2: are just different. They are more forgiving of messy input,
- 40:27Speaker 2: which is great, but their output does have that inherent variability.
- 40:31Speaker 2: This mismatch is pushing us to think about new interaction patterns.
- 40:34Speaker 2: New UIs designed for this LLM native world. The book
- 40:38Speaker 2: outlines three really interesting emerging patterns. The first and probably
- 40:43Speaker 2: the easiest lift to integrate into existing apps is the
- 40:46Speaker 2: interactive chatbot. Think of this as an AI sidekick living
- 40:49Speaker 2: within your application, like get up copilot, chat within your
- 40:52Speaker 2: code editor, or a similar chat interface within a design
- 40:55Speaker 2: tool or document editor. This chatbi can see the main
- 40:59Speaker 2: application content, the code, the design, the document and interact.
- 41:03Speaker 1: With it so you can talk to it about the
- 41:04Speaker 1: thing you're working.
- 41:05Speaker 2: On, exactly, explain this code, suggest a different layout. Summarize
- 41:09Speaker 2: this section. It's conversational collaboration. The key components are a
- 41:13Speaker 2: good dialogue tune chat model obviously, conversation history, streaming outputs
- 41:18Speaker 2: so it feels responsive, tool calling so the chatbot can
- 41:21Speaker 2: actually invoke application functions, change the font size, refactor this code,
- 41:25Speaker 2: and probably human in the loop controls for safety.
- 41:28Speaker 1: Okay, the AI sidekick makes sense. What's the next pattern?
- 41:31Speaker 2: The second pattern pushes the collaboration idea further collaborative editing
- 41:34Speaker 2: with lms. Here the LLM agent isn't just a sidekick
- 41:38Speaker 2: you talked to. It becomes one of those users contributing
- 41:41Speaker 2: to this shared document or shared state, right alongside human collaborators.
- 41:46Speaker 2: Think Google docs, but one of the cursors belongs to
- 41:49Speaker 2: an AI.
- 41:49Speaker 1: Whoa in AI is a real time teammate.
- 41:52Speaker 2: Potentially, Yes, what's fascinating here is how this could work.
- 41:57Speaker 2: Maybe the LM acts as an asynchronous drafter, pharing sections
- 42:00Speaker 2: for you overnight, or maybe it's an always on copilot
- 42:04Speaker 2: subjecting improvements or cleaning up formatting in real time. If
- 42:08Speaker 2: we connect this to the bigger picture, it raises really
- 42:11Speaker 2: important questions about how we design systems Where human edits
- 42:14Speaker 2: and AI edits merge seamlessly, how do you handle conflicts
- 42:18Speaker 2: whose changes take precedence?
- 42:19Speaker 1: Yeah, the merging in conflict resolution sounds tricky.
- 42:22Speaker 3: Definitely.
- 42:23Speaker 2: Key components here involve managing that shared state carefully, maybe
- 42:27Speaker 2: using sophisticated techniques like conflict free replicated data types crdts,
- 42:31Speaker 2: or just robust merging logic. You need task managers, ways
- 42:35Speaker 2: to handle concurrency, and definitely a good under.
- 42:37Speaker 1: Redos stack an AI teammate directly editing alongside you. That's
- 42:41Speaker 1: a huge paradigm shift. What's the third emerging pattern?
- 42:44Speaker 2: The third and perhaps the most futuristic feeling is ambient computing.
- 42:49Speaker 2: This is where the LLM is continuously doing some kind
- 42:52Speaker 2: of work in the background while you, the user, are
- 42:54Speaker 2: presumably doing something else.
- 42:56Speaker 3: Entirely.
- 42:57Speaker 2: It's not waiting for your explicit command, proactively working on your.
- 43:01Speaker 1: Behalf as silent, always on assistant kind of Think about
- 43:05Speaker 1: how LLM reasoning could transform this.
- 43:07Speaker 2: Old ambient computing often required setting up lots of manual rules.
- 43:11Speaker 2: If I get an email from X, notify me tedious.
- 43:15Speaker 2: The fascinating question now is can elms use their understanding
- 43:19Speaker 2: and reasoning to proactively identify what's genuinely interesting or important
- 43:23Speaker 2: to you without needing endless configuration.
- 43:25Speaker 1: So it learns what matters to me and surfaces just that.
- 43:28Speaker 2: That's the potential. Key components here would include triggers detecting
- 43:33Speaker 2: new information like emails, news, calendar, updates, long term memory
- 43:38Speaker 2: to build context about you and your priorities, reflection, the
- 43:42Speaker 2: agent actively learning and updating its internal model of what
- 43:45Speaker 2: you find interesting, and crucially summarized output. It doesn't bombard you.
- 43:50Speaker 2: It intelligently summarizes its findings and surfaces only the noteworthy stuff.
- 43:54Speaker 2: It needs a task manager too, to keep track of
- 43:56Speaker 2: his background processes.
- 43:58Speaker 1: So what does this all really mean for how we'll
- 44:01Speaker 1: interact with tech? Could lms truly become these quiet, proactive assistants,
- 44:05Speaker 1: maybe to drafting replies, summarizing reports, alerting us to opportunities
- 44:09Speaker 1: all happening in the background without constant manual setup. That
- 44:12Speaker 1: feels like a fundamentally different way to experience software.
- 44:16Speaker 2: It really does point towards a potential future where software
- 44:19Speaker 2: is less a collection of static tools we actively wield
- 44:22Speaker 2: and more of an intelligent environment that it anticipates and assists.
- 44:26Speaker 1: We have covered an incredible amount of ground today, haven't we.
- 44:29Speaker 1: It feels like a whirlwind.
- 44:30Speaker 3: Tourth It really does.
- 44:31Speaker 1: From the absolute fundamentals of llms, how they predict text,
- 44:35Speaker 1: what tokens are, and how prompting is our way to
- 44:37Speaker 1: steer them, then diving deep into retrieval augmented generation our RAG,
- 44:42Speaker 1: that crucial technique for grounding them in real world specific
- 44:45Speaker 1: data to fight hallucinations.
- 44:47Speaker 2: Yeah, and then moving into land graph enabling these complex
- 44:51Speaker 2: multi step agents that can actually remember conversations, plan sequences
- 44:56Speaker 2: of actions using tools, and even reflect and critique their own.
- 44:59Speaker 1: Out puts exactly. And then tackling the really practical side
- 45:03Speaker 1: making these things production ready, ensuring reliability with structured output,
- 45:08Speaker 1: giving users control with human in the loop features, and
- 45:11Speaker 1: mastering that whole deployment, testing, monitoring, and continuous improvement cycle.
- 45:16Speaker 2: It's a lot, It is a lot, but it's clear
- 45:18Speaker 2: that llms, combined with powerful frameworks like line chain and
- 45:21Speaker 2: lang graph are genuinely giving us well thing building superpowers.
- 45:25Speaker 3: As the book puts it, they're.
- 45:26Speaker 2: Making previously hard things easy and previously impossible things possible.
- 45:30Speaker 2: This deep dive hopefully has equipped you, the listener, with
- 45:33Speaker 2: the core knowledge to not just watch this revolution unfold,
- 45:36Speaker 2: but to potentially participate.
- 45:38Speaker 1: In it absolutely. And as we wrap up, maybe a
- 45:41Speaker 1: final thought to chew on. As these llms become more capable,
- 45:45Speaker 1: more edgentic, and more deeply integrated into our digital lives.
- 45:48Speaker 1: Imagine that world where software isn't just a static toolbox anymore.
- 45:52Speaker 1: Imagine it as a dynamic, intelligent collaborator, always learning, always adapting.
- 45:58Speaker 1: How will that fundamental shift I packed our creativity, our productivity,
- 46:02Speaker 1: even our very understanding of what it means to be
- 46:04Speaker 1: well informed or in control in an age of potentially
- 46:08Speaker 1: ambient AI constantly working around us.
- 46:10Speaker 2: That's a fascinating future to contemplate.
- 46:11Speaker 1: It really is. We definitely encourage you to continue your
- 46:14Speaker 1: own deep dive. Explore the open source Langschaine library, check
- 46:17Speaker 1: out lang graph, maybe look into langsmith. There's so much happening,
- 46:21Speaker 1: and the joy of discovery in this field right now
- 46:23Speaker 1: is truly immense.