็™ป้Œฒใ—ใฆๆ‹›ๅพ…ใƒชใƒณใ‚ฏใ‚’ๅ…ฑๆœ‰ใ™ใ‚‹ใจใ€ๅ‹•็”ปๅ†็”Ÿๅ ฑ้…ฌใจ็ดนไป‹ๅ ฑ้…ฌใ‚’็ฒๅพ—ใงใใพใ™ใ€‚

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture ๆŠ•็จฟใฏๅ€‹ไบบใฎๆ„่ฆ‹ใงใ™ใ€‚
ๅ‚ๅŠ  May 2026
284 ใƒ•ใ‚ฉใƒญใƒผไธญ    433 ใƒ•ใ‚กใƒณ
# Decision Points in AI Agent Development ๐ŸŽฏ The Hook RAG, fine-tuning, or long context? When giving your LLM domain knowledge, the default answer of "just use RAG" is not always right. Each approach stores, updates, and retrieves knowledge in fundamentally different ways, and picking the wrong one leads to stale answers, missing citations, or runaway token costs. Let's break down how to choose. ๐Ÿ“‹ Overview There are three primary methods for equipping AI agents with domain-specific knowledge. RAG (Retrieval-Augmented Generation) searches an external knowledge base and injects relevant information into the prompt at inference time. Fine-tuning (FT) adjusts model weights through additional training, baking knowledge into the model itself. Long context feeds entire documents directly into a large context window. Because each method differs in where knowledge lives, how it updates, and what it costs, you need to pick a primary approach for each use case. ๐Ÿ” Decision Points The core question is: how often does the knowledge change, and do you need to cite your sources? ๐Ÿ“Œ Knowledge changes frequently โ†’ RAG. FAQ entries, pricing, inventory data: just re-index and you're current. FT requires days-to-weeks of retraining -- impractical for volatile information. ๐Ÿ“Œ Source attribution is required โ†’ RAG again. Only RAG can point to "page 12 of document X" as the basis for an answer. FT-baked knowledge becomes "the model just knows," with no way to trace it back. This is a dealbreaker in high-accountability environments. ๐Ÿ“Œ Output style and tone must be consistent โ†’ FT. "Always respond in legal-document format" is hard to enforce through RAG-injected examples. FT embeds the behavior at the model level, eliminating the need for in-context demonstrations and saving context window space. ๐Ÿ“Œ Few documents, full structure matters โ†’ Long context. For tasks like interpreting an entire contract where cross-section references matter, chunking destroys context. Feeding the whole document into a large window preserves structural relationships. ๐Ÿ’ก Key Details ๐Ÿ”น RAG's fundamental strength is the separation of knowledge from the model. Knowledge lives in an index; reasoning lives in the model. This decoupling means knowledge updates never require retraining. The trade-off: output quality depends heavily on retrieval quality -- chunk splitting, embedding model choice, and reranking strategy all need tuning. ๐Ÿ”น FT's fundamental strength is stable behavioral transformation. For tasks requiring consistent output format, it can actually be cheaper per request than RAG (no retrieval cost, no prompt injection tokens). The trade-off: updating knowledge requires the full dataset-preparation, training, and validation cycle. ๐Ÿ”น Long context's fundamental strength is implementation simplicity. No vector DB, no retrieval pipeline, no chunking, no training infrastructure. The trade-off: token-based pricing makes costs scale linearly with document size, and the "Lost in the Middle" phenomenon (attention weakening for mid-window content) limits reliability as input grows. โš–๏ธ Trade-offs RAG excels at freshness and attribution but requires building and maintaining a retrieval pipeline. FT excels at stylistic consistency but is slow to update and opaque about sources. Long context is the simplest to implement but constrained in cost and scalability. ๐Ÿ† The production playbook is often a hybrid: FT for style, RAG for facts. Fine-tune the model for output format, tone, and terminology. Use RAG to inject up-to-date factual information at inference time. Use long context as a complement to RAG when chunk splitting would destroy important document structure. ๐Ÿ› ๏ธ Use Cases ๐Ÿข Internal knowledge base Q&A โ†’ RAG. Documents update daily, and answers need source citations. โš–๏ธ Legal document review โ†’ FT + RAG. FT unifies legal tone and format; RAG injects current case law and regulations. ๐Ÿ“„ Full contract interpretation โ†’ Long context. Feed the entire contract in and let the model reason across clauses. ๐Ÿฅ Medical information โ†’ RAG is mandatory. Source attribution is non-negotiable, and information freshness is critical. Medical knowledge baked in via FT is indistinguishable from hallucination -- dangerous. When in doubt, start with RAG. In most business systems, knowledge is a living thing, and the ability to cite sources is the foundation of trust. #AIAgents# #SoftwareArchitecture#
ใ‚‚ใฃใจ่ฆ‹ใ‚‹