差别
这里会显示出您选择的修订版和当前版本之间的差别。
| 两侧同时换到之前的修订记录前一修订版 | |||
| en:大模型:白话综述:0-大模型白话综述学习 [2026/07/10 12:12] – 修正翻译中残留的中文词汇 ctbots | en:大模型:白话综述:0-大模型白话综述学习 [2026/07/10 16:17] (当前版本) – Delete old English page, moved to en:large-language-model:plain-language-review:0-plain-language-review-learning ctbots | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | {{htmlmetatags> | ||
| - | metatag-keywords=(Large Language Model, LLM, Machine Learning, AI) | ||
| - | metatag-description=(Explaining LLM concepts, techniques and practices using the Feynman learning method) | ||
| - | metatag-media-og: | ||
| - | metatag-og: | ||
| - | metatag-og: | ||
| - | }} | ||
| - | [中文版](大模型: | ||
| - | |||
| - | I am a beginner in large language models, gradually learning and understanding them. But in the process, I've encountered quite a few confusions. Here I adopt the Feynman learning method, hoping to explain some basic concepts, development history, technical solutions, and engineering practices of LLMs in plain language, to consolidate knowledge and fill in gaps. The following is a comprehensive overview. | ||
| - | |||
| - | ## 1. What is a Large Language Model | ||
| - | |||
| - | - A Large Language Model (LLM) is an intelligent program trained on massive amounts of internet text data. | ||
| - | - Core working principle: Generate text responses by " | ||
| - | - Typical representatives: | ||
| - | |||
| - | When a user inputs: 【I drank a cup of ___ before going out this morning】, the model, based on the language patterns learned during training, calculates the " | ||
| - | |||
| - | When a user inputs something like 【I drank before going out this morning】, during actual generation the model doesn' | ||
| - | |||
| - | After filtering to a reasonable candidate pool, the model randomly samples within this range according to probability to select the final next word. Temperature is used to adjust the randomness of this sampling: | ||
| - | |||
| - | - The lower the temperature, | ||
| - | - The higher the temperature, | ||
| - | |||
| - | That's how LLMs work. Through the simple mechanism of predicting the next word, the entire edifice is built. | ||
| - | |||
| - | Key technical details: | ||
| - | |||
| - | - Top-K and Top-P | ||
| - | - Temperature control | ||
| - | - Tokenizer: In reality, in 【I drank a cup of soy milk before going out this morning】, the model doesn' | ||
| - | - EOS Token (End-of-Sequence Token): When does the word-guessing game end? When the LLM sees the EOS token, it knows it doesn' | ||
| - | |||
| - | ## 2. The Most Basic Operation Mode: Single-turn Interaction | ||
| - | |||
| - | Single-turn interaction is the most fundamental way LLMs operate, and it's the foundation for all subsequent complex interaction capabilities. | ||
| - | |||
| - | Many people think of LLMs as " | ||
| - | |||
| - | This single-turn mode is inherently stateless; each interaction is completely independent. The model only processes the current input and won't actively remember information from the previous round of conversation. It's like handing it a fresh piece of scratch paper each time — it writes, clears it, and absolutely won't remember what was on the previous sheet. | ||
| - | |||
| - | Don't directly conflate this with mature complex products like【Doubao, | ||
| - | |||
| - | This also brings the most direct limitation: inability to handle multi-turn context. If you split the conversation into two rounds — first telling the model your name and age, then separately asking "How old am I?" — the model simply can't answer. Continuous conversation easily leads to " | ||
| - | |||
| - | Key technical details: | ||
| - | |||
| - | - Role | ||
| - | - System Prompt | ||
| - | - Prompt injection: Similar to SQL injection and XSS injection attacks | ||
| - | |||
| - | ## 3. The Emergence of Context: The Foundation of Multi-turn Dialogue | ||
| - | |||
| - | Since LLMs are " | ||
| - | |||
| - | Actually, this is entirely an engineering " | ||
| - | |||
| - | So, the LLM can answer your follow-up questions not because it " | ||
| - | |||
| - | Now, you sharp-minded folks surely see several serious problems: | ||
| - | |||
| - | - Does the " | ||
| - | - According to previous chapters, the LLM infers the next word based on the entire existing text each time. So as context grows, it becomes increasingly difficult to compute. Isn't this like MySQL' | ||
| - | |||
| - | Key technical details: | ||
| - | |||
| - | - Sliding Window Attention | ||
| - | - KV Cache (caching intermediate attention results to avoid redundant computation) | ||
| - | - Context Compact (context compression) | ||
| - | - Context Cache (intelligent caching) | ||
| - | |||
| - | ## 4. Giving LLMs Hands and Feet | ||
| - | |||
| - | A Doubao that can only chat has significant limitations. We can't keep copy-pasting code text into 【Doubao】 and then copy-pasting the results back into our editor. That's way too tedious!! Is there a way to let the LLM directly modify files itself? But here at least a few problems exist: | ||
| - | |||
| - | - How does a text-continuation LLM understand a code project, locate bugs, and continue writing code? | ||
| - | - How does the LLM interact with the outside world to truly grow hands and feet? | ||
| - | |||
| - | Function Calling emerged, but always remember: LLMs will only ever do one thing — " | ||
| - | |||
| - | So-called function execution is essentially a " | ||
| - | |||
| - | 1. Suppose our LLM supports weather querying, allowing users to input a city for the forecast. | ||
| - | 2. Before processing the user's input, the backend secretly prepends this text: "I have a function called `get_weather` that can query city weather. If you want to use it, you must output a JSON-formatted result like: `{\" | ||
| - | 3. The model makes a decision and writes the " | ||
| - | 4. The backend intercepts the secret code: When the backend detects that the model' | ||
| - | 5. It stuffs the result back into the conversation, | ||
| - | 6. | ||
| - | |||
| - | You smartly realize there might be several problems here: | ||
| - | |||
| - | - In multi-turn conversations, | ||
| - | - As an all-powerful 【Doubao】 assistant, how could it possibly know in advance that the user wants to ask about weather? If all function capabilities are stuffed before the user's input, wouldn' | ||
| - | - When the backend intercepts secret codes, if everything is hardcoded like this, the code would become very bloated. How to handle this? | ||
| - | |||
| - | We'll discuss strategies for solving these problems later. | ||
| - | |||
| - | Key timeline and technologies: | ||
| - | |||
| - | - Code Interpreter | ||
| - | - JSON Schema (tool definition description) | ||
| - | - ReAct pattern: In the early stage, LLM capabilities were imperfect, requiring the ReAct paradigm for tool invocation | ||
| - | - Function Calling emerges | ||
| - | - LangChain, LlamaIndex emerge, solving Tool RAG | ||
| - | - LangGraph emerges | ||
| - | - Tool Call and post-training enhancement | ||
| - | - MCP protocol emerges | ||
| - | |||
| - | ## 5. LLM Hallucinations | ||
| - | |||
| - | LLMs only ever do one thing — " | ||
| - | |||
| - | Typical hallucinations: | ||
| - | |||
| - | - Sounds plausible but is entirely fabricated. | ||
| - | - Cites websites that don't exist. | ||
| - | - References papers that don't exist. | ||
| - | - Even cites historical allusions that don't exist. | ||
| - | |||
| - | One reason for hallucinations is insufficient training data in the relevant domain, so when continuing text, there' | ||
| - | |||
| - | - Data is finite; you can't have infinitely large data for the model to learn everything. | ||
| - | - Data processing involves lossy compression. The knowledge the model learns is lossy-compressed and can't be perfectly reconstructed. | ||
| - | - Data has a time limit. Train with 2024 knowledge, and the model' | ||
| - | |||
| - | This makes LLMs difficult to use in certain scenarios: | ||
| - | |||
| - | - When data is private and confidential. Private data means open-source LLMs can't easily train on this knowledge. | ||
| - | - When data is changeable. For example, manuals and standards can change; internal knowledge bases can be updated. | ||
| - | - When accuracy is required and lossy compression isn't allowed. For instance, laws and regulations can't be freely extended; scenarios requiring high data accuracy like electricity, | ||
| - | |||
| - | Key technologies: | ||
| - | |||
| - | - RLHF (Reinforcement Learning from Human Feedback) | ||
| - | - Decoding Strategy optimization | ||
| - | - RAG (Retrieval-Augmented Generation) | ||
| - | |||
| - | ## 6. LLM Open-Book Exams | ||
| - | |||
| - | An LLM is a " | ||
| - | |||
| - | Suppose you're building a historical archive decryption assistant. You have various electronic historical materials, and you want the LLM to answer questions about historical materials accurately and comprehensively, | ||
| - | |||
| - | The LLM's context can't fit all historical materials. Even if you could barely stuff in a copy of "WWII Declassified Archives," | ||
| - | |||
| - | Enter RAG (Retrieval-Augmented Generation). In a nutshell: it solves problems like an open-book exam, rather than memorizing the entire textbook. | ||
| - | |||
| - | ### 6.1 The Four Steps of " | ||
| - | |||
| - | When someone asks: "On the eve of the Normandy landings in 1944, how did the Allies use false intelligence to deceive the Germans?" | ||
| - | |||
| - | - Chunking: Before the system goes live, engineers use an " | ||
| - | - Embedding & Vector DB: These fragments go through a "magic translator" | ||
| - | - Retrieval: When the user hits enter, the system' | ||
| - | - Generation: The page turner packages these 3 "cheat sheets" | ||
| - | |||
| - | The LLM doesn' | ||
| - | |||
| - | ### 6.2 Open-Book Exams Can Also Fail | ||
| - | |||
| - | - Terminology trap (semantic mismatch): A scholar asks about "the smoke screen of Operation Overlord," | ||
| - | - Page turning problem: Paragraph 45 states "The Germans firmly believed the Allies would land at Calais," | ||
| - | - Clues too scattered, cheat sheet too short: The scholar asks " | ||
| - | |||
| - | To solve these open-book exam failures, the industry has evolved more complex patch technologies. | ||
| - | |||
| - | Key technical details: | ||
| - | |||
| - | - Embedding: Converting historical jargon and modern language into spatial coordinates, | ||
| - | - Chunking Strategy: Using overlap when slicing archives to ensure context isn't "cut in two." | ||
| - | - Rerank (reranking model): After the page turner roughly selects 20 archives, an expert model performs a second pass to pick only the 3 most precise cheat sheets for the LLM. | ||
| - | - Graph RAG (Graph Retrieval-Augmented Generation): | ||
| - | |||
| - | ## 7. LLM Self-Reflection | ||
| - | |||
| - | LLMs have long been criticized as "fast talkers lacking deep thinking." | ||
| - | |||
| - | This " | ||
| - | |||
| - | To teach LLMs to "think before they act" like humans, engineering and algorithmic techniques for letting LLMs " | ||
| - | |||
| - | ### 7.1 The Subtext Behind "Deep Thought" | ||
| - | |||
| - | When a user inputs a tricky problem: " | ||
| - | |||
| - | A traditional " | ||
| - | |||
| - | But in the new reasoning era (represented by Reasoning models), before presenting the final answer to the user, the LLM conducts a lengthy self-continuation on its " | ||
| - | |||
| - | > Model' | ||
| - | > | ||
| - | > 1. First clarify initial state: Xiaoming = 3, Xiaohong = 3 * 2 = 6. | ||
| - | > 2. Process the first change: Xiaoming eats 1, Xiaoming = 3 - 1 = 2. | ||
| - | > 3. Process the second change: Xiaohong gives Xiaoming 4. Wait, Xiaohong gives away 4, so Xiaohong decreases! Xiaohong = 6 - 4 = 2; Xiaoming receives 4, Xiaoming = 2 + 4 = 6. | ||
| - | > 4. Re-compare results: Now Xiaoming has 6, Xiaohong has 2. Xiaoming has more. | ||
| - | > 5. Calculate the difference: 6 - 2 = 4. Check passed, ready to output. | ||
| - | |||
| - | Finally, the user sees the concise and elegant final answer on screen: " | ||
| - | |||
| - | The LLM hasn't changed its "text continuation" | ||
| - | |||
| - | ### 7.2 Admitting Mistakes, Pruning, and Self-Correction | ||
| - | |||
| - | You smartly realize: if the LLM makes a mistake in the second step of " | ||
| - | |||
| - | In the latest post-training techniques, LLMs have been trained with a " | ||
| - | |||
| - | This mechanism of continuously evaluating the current path during generation, and backtracking to retry when something' | ||
| - | |||
| - | Key technical details: | ||
| - | |||
| - | - CoT (Chain of Thought): Guiding the model to output intermediate reasoning steps like " | ||
| - | - System 2 Thinking (Slow Thinking): Borrowing from human psychology, distinguishing intuitive fast response (System 1) from deliberate logical reasoning (System 2). The core of reasoning models is activating the latter capability. | ||
| - | - MCTS (Monte Carlo Tree Search): During inference, the model generates multiple possible next steps behind the scenes, scores and evaluates them, and selects the optimal solution. Commonly used in reinforcement learning for math and code LLMs. | ||
| - | - Reinforcement Learning for Reasoning: Instead of directly feeding the model correct answers, reward rules are set for " | ||
| - | |||
| - | ## 8. LLM Agents — Qualified Workhorses | ||
| - | |||
| - | Because we keep saying LLMs are " | ||
| - | |||
| - | But if you've actually used Claude Code, OpenAI Codex, or Cursor, you must be amazed: how can they sit there for hours continuously modifying code, compiling, debugging, and re-modifying until bugs are completely fixed, just like a real programmer? | ||
| - | |||
| - | They haven' | ||
| - | |||
| - | ### 8.1 What Are the " | ||
| - | |||
| - | If we compare an LLM to a "wise person" | ||
| - | |||
| - | To make this "wise person" | ||
| - | |||
| - | 1. Brain (LLM): Still the sage responsible only for text continuation. | ||
| - | 2. Tools: Giving the sage hands. For example, an API to read local files, a command-line terminal to run `npm run dev` or `pytest`. | ||
| - | 3. Planning: Giving the sage a task list. Facing a big task, what to do first, what to do next. | ||
| - | 4. Memory: Giving the sage a notebook that never gets lost, recording what was just done. | ||
| - | |||
| - | ### 8.2 The Secret Behind Hours of Continuous Programming: | ||
| - | |||
| - | Tools like Claude Code can work continuously for hours because the core mechanism is trapping the LLM in a carefully designed "Think → Act → Observe → Think again" infinite loop (technically called the ReAct pattern). | ||
| - | |||
| - | Let's break it down in plain language. When you type `claude-code fix the login bug` in the terminal, here's what's actually happening behind the scenes in this crazy " | ||
| - | |||
| - | - Minute 1【Think】: | ||
| - | - Minute 2【Act】: The LLM spits out the secret code (JSON format): `{\" | ||
| - | - Minute 3【Observe】: | ||
| - | - Minute 4【Think】: | ||
| - | - Minute 5【Act】: Spits out the code: `{\" | ||
| - | - Minute 6【Observe】: | ||
| - | - …… | ||
| - | - Minute 30【Failure & Retry】: The LLM modified the code and proactively called `run_command(cmd=\" | ||
| - | - In a regular Q&A scenario, the LLM would just dump the error on the user. | ||
| - | - But in the Agent loop, the LLM sees this Error (Observe), and in the next round of【Think】, | ||
| - | |||
| - | This is the truth behind its ability to code continuously for hours: It doesn' | ||
| - | |||
| - | ### 8.3 What's the Biggest Engineering Pain Point of This " | ||
| - | |||
| - | You cleverly recall what we discussed in Chapter 3 — the " | ||
| - | |||
| - | Letting Claude Code run for hours means this " | ||
| - | |||
| - | 1. The ledger fills up quickly: If the project is large, after reading a dozen files, the LLM hits its physical vision ceiling (e.g., 200k Tokens), and it starts forgetting what the user originally asked it to do. | ||
| - | 2. Gets more expensive and slower with each turn: Each cycle requires the LLM to read through the thick stack of " | ||
| - | |||
| - | To solve this, top-tier code Agents like Claude Code invest heavily in " | ||
| - | |||
| - | Key technical details: | ||
| - | |||
| - | - ReAct (Reason-Action). | ||
| - | - State Machine: An engineering framework that controls Agent behavior, defining when the model can freely think and when it must force-invoke tools. | ||
| - | - Context Dynamic Pruning: How to let the model maintain a big-picture view without being overwhelmed by massive code details, while using the fewest Tokens possible. | ||
| - | |||
| - | ## 9. Taming and Conquering LLMs | ||
| - | |||
| - | We've been saying that LLMs are essentially " | ||
| - | |||
| - | Behind this lies the most crucial " | ||
| - | |||
| - | ### 9.1 Triple Jump: From " | ||
| - | |||
| - | To transform a machine that only blindly continues text into the empathetic, format-rigorous AI assistant we see in 【Doubao】, | ||
| - | |||
| - | - Stage 1: Pre-training (Wild State) | ||
| - | - What it does: The model frantically performs "next word prediction" | ||
| - | - Result: It becomes a " | ||
| - | - Stage 2: Supervised Fine-tuning (SFT, Learning to Understand Human Speech) | ||
| - | - What it does: Engineers spent big money hiring thousands of professional human annotators to write hundreds of thousands of high-quality Q&A pairs. The format is rigidly fixed: `【Input: Tell me what giant pandas eat?】 → 【Output: Giant pandas mainly eat bamboo.】`. These standard cheat sheets are fed to the model for retraining. | ||
| - | - Result: The monkey puts on a Daoist robe. It finally dawns on the model that when it sees words like " | ||
| - | - Stage 3: Reinforcement Learning from Human Feedback (RLHF, Understanding Good from Bad) | ||
| - | - What it does: Is obedience enough? Not enough. If a user asks: 【How can I perfectly withdraw money that doesn' | ||
| - | - Result: The wild monkey finally becomes a " | ||
| - | |||
| - | If you often use Grok or Gemini, you'll notice that multiple options often pop up simultaneously, | ||
| - | |||
| - | ### 9.2 Why Can't LLMs " | ||
| - | |||
| - | Earlier we mentioned that LLM knowledge is often stuck at the year it was trained (e.g., 2024), and it can't "learn online." | ||
| - | |||
| - | This is very intuitive from an engineering standpoint, but in practice, it's a huge disaster. | ||
| - | |||
| - | An LLM's knowledge is stored in the form of digital weights, distributed uniformly and vaguely across billions or tens of billions of parameters, like salt dissolved in water. This brings two fatal technical limitations: | ||
| - | |||
| - | 1. Catastrophic Forgetting: When you forcefully feed 100,000 of your company' | ||
| - | 2. Lossy Compression and " | ||
| - | |||
| - | > Industry consensus: | ||
| - | > | ||
| - | > - Use Fine-tuning to change the model' | ||
| - | > - Use RAG (Retrieval-Augmented Generation, i.e., open-book exam) to provide the model with the latest, most accurate hard facts and private data that cannot tolerate any lossy compression. | ||
| - | |||
| - | Treating fine-tuning as a hard drive to store new knowledge is like expecting a college student to memorize a medical dictionary and then immediately perform surgery — both inefficient and dangerous. This is also why, in current engineering practice, RAG and Agent have become mainstream for deployment, while fine-tuning has stepped back, specifically used for " | ||
| - | |||
| - | Key technical details: | ||
| - | |||
| - | - SFT (Supervised Fine-tuning): | ||
| - | - RLHF (Reinforcement Learning from Human Feedback): Using human preference data to train a reward model, and adjusting the LLM through algorithms like PPO to make its output meet human safety and practical standards. | ||
| - | - LoRA (Low-Rank Adaptation): | ||
| - | |||
| - | # 10. Giving LLMs Eyes and Ears | ||
| - | |||
| - | We've been repeatedly emphasizing: | ||
| - | |||
| - | But when you open the latest 【Doubao】 and casually take a photo of a dense code screen or a complex circuit board logic diagram, throw it at the model and ask: "Which line of code in here is wrong?" | ||
| - | |||
| - | Don't LLMs only recognize text? How can they recognize images, even audio and video? | ||
| - | |||
| - | Behind this, the LLM hasn't changed its brain. Rather, engineers have installed a " | ||
| - | |||
| - | ## 10.1 The Game of Chopping Up Images for Continuation | ||
| - | |||
| - | Since LLMs only eat Tokens, we force images to also masquerade as Tokens. | ||
| - | |||
| - | When you upload a screenshot of code in the chat and ask "how to fix it," the entire backend process is a " | ||
| - | |||
| - | 1. Patching: The vision processing program, before the LLM even sees the image, uses an invisible knife to chop the image into a bunch of 16x16 pixel "small tiles." | ||
| - | 2. Vision Encoder: These small tiles are sent to a model specifically for understanding images (like CLIP's vision part). This translator doesn' | ||
| - | 3. Projection: Here's the crucial step. Engineers use a mathematical method to forcefully map the "image coordinates" | ||
| - | 4. Big Platter Continuation: | ||
| - | | ||
| - | |||
| - | To the LLM, it doesn' | ||
| - | |||
| - | So it fires up its only trick — text continuation — and naturally spits out: "The image shows a giant panda eating bamboo." | ||
| - | |||
| - | ## 10.2 When LLMs Meet Robots | ||
| - | |||
| - | You immediately think: Since LLMs can " | ||
| - | |||
| - | The answer is: absolutely yes, and this is exactly the field of Embodied AI. | ||
| - | |||
| - | Traditional robot control requires complex mathematical formulas to calculate joint angles, torque, and Cartesian coordinates for robotic arms. But what if we treat the robotic arm's actions as a kind of " | ||
| - | |||
| - | In cutting-edge embodied AI engineering practice, engineers have done something very radical: they' | ||
| - | |||
| - | When you input to an LLM connected to a robotic arm: 【Help me pick up the red block on the table.】 | ||
| - | |||
| - | 1. The LLM uses the camera (visual Tokens) to see the tabletop layout. | ||
| - | 2. It starts frantically continuing in its underlying brain, but this time it doesn' | ||
| - | 3. The robot' | ||
| - | |||
| - | This transforms the originally tedious mechanical control problem into a pure, cross-modal " | ||
| - | |||
| - | ## 10.3 The Pain Points of This Crossover | ||
| - | |||
| - | But there' | ||
| - | |||
| - | - The "black hole" of context consumption: | ||
| - | - The " | ||
| - | |||
| - | To solve these visual and physical control failures, the industry is currently moving comprehensively from early " | ||
| - | |||
| - | *Key technical details:* | ||
| - | |||
| - | * Vision Transformer (ViT): The standard front-end network for vision multimodal, responsible for chopping coherent image pixels and converting them into high-dimensional vector matrices. | ||
| - | * Linear Projector / Perceiver Resampler: The " | ||
| - | * VLA Model (Vision-Language-Action Model): The ultimate brain for embodied AI, not only capable of looking at images and speaking but also directly continuing visual input into robot motion control commands (Action Sequence). | ||
| - | |||
| - | # 11. The Assembly Pipeline for LLM Applications | ||
| - | |||
| - | In previous chapters, we've learned how to make LLMs work like workhorses performing various simple tasks. | ||
| - | |||
| - | But if you're asked to write an enterprise-level system, you'll find that just writing "glue code" to stick these parts together can exhaust you. That's when the LLM engineering world evolved specialized " | ||
| - | |||
| - | ## 11.1 LangChain' | ||
| - | |||
| - | The earliest behemoth to appear was LangChain. Its core idea was to encapsulate common patterns in LLM application development into standard "Lego bricks." | ||
| - | |||
| - | But when people brought LangChain into serious production environments, | ||
| - | |||
| - | - Horrifying over-encapsulation: | ||
| - | - Loose string hell: Data flow between bricks relies entirely on implicit dictionaries and plain strings. If the LLM, due to probability issues, misses a comma in a JSON array, the entire system crashes mysteriously at runtime, and you can't even find which line of code caused the error. If you've written Java or JS code, imagine what it feels like when all parameters are Map structures. | ||
| - | |||
| - | ## 11.2 The Rise of PydanticAI | ||
| - | |||
| - | Then PydanticAI emerged. It borrowed design philosophies from modern backend development (like FastAPI) and proposed two weapons against the uncontrollability of LLMs: | ||
| - | |||
| - | 1. Type Safety: Programmers strictly define output structures in code (e.g., user ID must be an integer, risk level must be a fixed enum). If the LLM outputs incorrectly, | ||
| - | 2. Dependency Injection: Completely eliminates global variables. Each user request gets an independent, | ||
| - | |||
| - | # 12. LLM Memory Systems | ||
| - | |||
| - | An LLM is a stateless text continuation machine. We discussed earlier that multi-turn dialogue relies on the backend frantically stacking " | ||
| - | |||
| - | To give Agents long-term memory similar to humans, engineering has installed a layered " | ||
| - | |||
| - | ## 12.1 The Symphony of Short-term and Long-term Memory | ||
| - | |||
| - | - Short-term memory (running ledger): Records the most recent rounds of current conversation. This part is still stored in memory or Redis, using a sliding window mechanism — only the freshest content is kept, and older content is periodically " | ||
| - | - Long-term memory (diary): When the day's conversation ends, the backend runs an asynchronous " | ||
| - | |||
| - | ## 12.2 Entity Memory | ||
| - | |||
| - | More advanced memory is the entity relationship graph. As AI communicates with you, it secretly draws a network about you in its backpack: `[User] -- likes --> [Black Coffee]`, `[User] -- profession --> [Software Development]`. | ||
| - | |||
| - | This memory is no longer fragmented text snippets but structured state, making the LLM feel like an old friend every time it interacts with you. | ||
| - | |||
| - | # 13. AI Skills Package | ||
| - | |||
| - | We've given LLMs "hands and feet" (Tool Call), letting them check weather and modify files. But imagine, in a large enterprise, there are thousands of internal microservice APIs (check finances, approve leave requests, search employees, modify permissions...). | ||
| - | |||
| - | If we cram all the " | ||
| - | |||
| - | Thus, the Dynamic Skills system emerged. It turns tool usage into a " | ||
| - | |||
| - | 1. Skills bundle encapsulation: | ||
| - | 2. On-demand credential retrieval: When the user inputs "Help me reimburse last month' | ||
| - | 3. Dynamic feeding: The LLM can only see these 3 tools in this interaction. This reduces the " | ||
| - | |||
| - | # 14. The Ultimate Efficiency of LLMs | ||
| - | |||
| - | When we've used PydanticAI to set the standards, Memory to give it memory, and Skills to give it unlimited capabilities, | ||
| - | |||
| - | Now we have an extremely ambitious idea: Can I create an omniscient and omnipotent "Super Single Agent"? | ||
| - | |||
| - | In engineering practice, if you actually do this, the LLM will slap you awake with reality. As you cram more and more prompts and hundreds of tools into this single Agent, it quickly falls into "deep confusion" | ||
| - | |||
| - | To solve this " | ||
| - | |||
| - | ## 14.1 The Self-Decoupling at the Model Level | ||
| - | |||
| - | First, we must peel back the physical shell of LLMs and see how their underlying hardware and compute power are squeezed out. In today' | ||
| - | |||
| - | ### 1. Dense Models | ||
| - | |||
| - | Early classic models (like early Llama series, or various small standalone models with tens of billions of parameters) are almost all "dense models." | ||
| - | |||
| - | - Plain-language principle: Suppose this model has 720 billion parameters (72B). When a user inputs an extremely simple " | ||
| - | - Hardware despair: This is like a company keeping 720 versatile geniuses. Whether it's cleaning toilets, photocopying documents, or deriving quantum mechanics, every time a task comes up, all 720 people must show up in unison and think together. In reality, this means even if you buy two top-of-the-line NVIDIA RTX 5090 D GPUs (64GB VRAM total), facing this fully-computed dense LLM, its token throughput will be as slow as an old ox pulling a cart because all GPU compute units (Tensor Cores) are fully occupied. And the compute cost will be so expensive you'd want to call the police. | ||
| - | |||
| - | ### 2. Mixture of Experts Models | ||
| - | |||
| - | To break through the physical limits of dense models, today' | ||
| - | |||
| - | - Plain-language principle: The model' | ||
| - | - Real compute ledger: When you input a code question, the Router glances at it, instantly recognizes the intent, and internally only activates the "code expert" | ||
| - | - Current state and limits: This architecture brings the compute miracle of the 2026 LLM era — its intelligence has the depth of hundreds of billions of parameters, but its per-token speed and cost are as cheap and fast as a 30B small model. But you smartly notice the hardware pain point: although MoE models only use a small portion of parameters per computation, | ||
| - | |||
| - | ## 14.2 Sociological Decoupling at the Application Layer | ||
| - | |||
| - | After hearing about the hardware situation, you might think: "Since MoE models like DeepSeek are already this smart and cheap, if I write all my company' | ||
| - | |||
| - | Sorry, it still fails. Because the underlying MoE can only solve " | ||
| - | |||
| - | Suppose you want to build a "fully automated R&D expense reimbursement audit assistant." | ||
| - | |||
| - | > "You need to be both a warm and friendly customer service representative guiding users to upload invoices, AND a strict rigorous code auditor checking users' code for security vulnerabilities, | ||
| - | |||
| - | When the LLM sees this massive chunk of prompt, its attention mechanism gets completely confused. When the user inputs: *"Help me check if the code for this login interface is done, and also reimburse the 5000 yuan overspent last week due to fixing this bug."* This single Agent immediately falls into identity schizophrenia: | ||
| - | |||
| - | When human society faces complex tasks, it never relies on a lone hero but on departmental collaboration. When LLMs are deployed in business, they must also move toward Multi-Agent systems. The core is: completely dismantle a complex all-powerful Agent into a " | ||
| - | |||
| - | Let's use the failure case above to see how a modern multi-agent system (e.g., built on LangGraph or PydanticAI Graph) flows smoothly behind the scenes: | ||
| - | |||
| - | 1. Application Router: It's the administrative front desk of the office. It doesn' | ||
| - | 2. Security Auditor (Agent A): The front desk throws the first work order to Agent A, the security auditor. This Agent' | ||
| - | 3. Accountant (Agent B): The front desk throws the second work order to Agent B, the accountant. Its prompt: "You are a shrewd accountant." | ||
| - | 4. State Machine Merge: After the two experts finish their work in their respective unidirectional tracks (state machines), they throw their standard, type-safe Pydantic reports back to the front desk. The front desk manager neatly combines "code security" | ||
| - | |||
| - | In this application-layer decoupling process, the LLM doesn' | ||
| - | |||
| - | [中文版](大模型: | ||