Skip to product information
Teddy Note's RAG Secret Note Using Lang Chain [Advanced Edition]
Teddy Note's RAG Secret Note Using Lang Chain [Advanced Edition]
Description
Book Introduction
From optimizing the pipeline to creating agents and deploying them as services.
The secret to upgrading a 90-point RAG to a 100-point advanced RAG


Now that you've mastered RAG, which searches data and generates answers, it's time to move on to Advanced RAG, which extracts information more precisely and designs flexible processing flows.
This book covers how to improve response quality by configuring the RAG system to select more accurate and relevant documents, implementing a structure that allows free design of execution flow according to input conditions and processing purposes, and identifying problems based on quantitative indicators and improving performance through repeated experiments.
It also includes the process of configuring LLM to use tools to automatically perform practical tasks and making the developed system available as a service to external users.
  • You can preview some of the book's contents.
    Preview

index
prolog
Recommendation
Readers' Praise
Code reviewers' reviews
Download and Inquiry
Structure of this book

PART 01 ADVANCED RAG

CHAPTER 01 Adjusting the Ranking of Documents Searched with Reranker
01 Cross Encoder Reranker
02 Cohere Reranker
03 Jina Reranker
04 FlashRank Reranker

CHAPTER 02 RAG Pipeline
01 QA system based on Naver News articles
02 RAPTOR
03 Document-based QA system implemented as a free open model

CHAPTER 03 Predefined Chains
01 Stuff Summary
02 Map-Reduce Summary
03 Map-Refine Summary
04 Chain of Density (CoD) Summary
05 Clustering-Map-Refine Summary
06 SQL Query Generator

PART 02 LCEL Advanced Grammar

CHAPTER 04 Using Runnable with Advanced LCEL Grammar
01 RunnablePassthrough
02 Reviewing the Runnable Structure
03 RunnableLambda
04 Routing using RunnableBranch and RunnableLambda
05 RunnableParallel
06 Dynamically changing LLM or prompt with config
07 Setting up Runnable with @chain decorator

PART 03 RAG Evaluation and Improvement

CHAPTER 05 Evaluating Answers with RAGAS
01 Creating a synthetic test dataset
02 Rating with RAGAS
03 Managing Test Dataset Translation and Upload

CHAPTER 06 Prompt Optimization Using the LangSmith API
01 Building a test dataset for evaluation
02 Evaluate with LLM-as-a-judge
03 Creating a Custom Evaluator
04 Evaluating using a heuristic approach
05 Comparative analysis by experiment
06 Assessing the overall level with a summary evaluator
07 Checking Hallucinations with the Groundedness Evaluator
08 Comparative Analysis of Experiments with Pairwise Evaluation
09 Repeat evaluation
Automating Assessments with 10 Online LLM Assessors
11 Evaluating RAG using RAGAS

PART 04 AGENT

CHAPTER 07 Tools and Toolkits
01 Tools provided by LangChain
02 Creating a Custom Tool

CHAPTER 08 AGENT KEY FUNCTIONS
01 Binding tools to LLM
02 Creating an Agent and AgentExecutor
03 Streaming the intermediate stage of the agent
04 Creating an agent that remembers previous conversations
05 Creating agents using various LLMs
06 Output and check step by step with iter() function

CHAPTER 09 AGENT USE
01 Agentic RAG
02 CSV, Excel Data Analysis Agent
03 File Management Task Automation Agent
04 Report writing task automation agent
05 CSV File-Based Data Analysis Agent

PART 05 SERVICE DISTRIBUTION

CHAPTER 10: Service Deployment Practice Using Streamlit
01 Setting up config for distribution
02 Preparing GitHub and other configuration files for deployment
03 Deployment and Operation Testing
04 Check service modifications and changes

CHAPTER 11 LangServe
01 Serving a Model with LangServe
02 Exposing the model to the public using NGROK

Epilogue
Search

Detailed image
Detailed Image 1

Into the book
In the existing RAG system we learned, the loaded document is divided into small chunks and the chunks with high similarity are searched.
Searching short, continuous chunks of text like this reduces the ability to understand the content structure of the entire document.
If you only extract part of the whole content, you are bound to miss out on necessary information.
For example, let's say we ask the question in the story of Cinderella, "How did Cinderella get her happy ending?"
To address such broad, abstract questions, you need to know the overall flow of the entire plot from beginning to end.
To solve these problems, RAPTOR… …
--- p.038

When evaluating RAG, manually checking the quality of each RAG response is time-consuming and labor-intensive. RAGAS (Retrieval Augmented Generation Assessment) uses LLM to create a dataset for RAG evaluation.
This is called a synthetic test dataset.
Of course, you can also use LangChain to randomly generate questions and answers for specific documents and use them as a test dataset.
In such cases, useless questions may be generated and hallucinations may occur in the answers.
On the other hand, RAGAS… …
--- p.134

A Korean morphological analyzer is important for rule-based heuristic evaluation of Korean sentences.
If you are new to natural language processing, you may be unfamiliar with the Korean morphological analyzer.
A Korean morphological analyzer is a tool that separates Korean sentences into morphemes, the smallest units of meaning, and determines the part of speech of each morpheme.
--- p.182

Publisher's Review
★ More sophisticated: Extract the information you need with advanced RAG.

The basic RAG retriever has limitations in extracting actually important documents based solely on vector similarity.
At this time, introducing a reranker (CrossEncoder, Cohere, Jina, FlashRank, etc.) that readjusts the ranking of retriever search documents can extract more accurate and relevant information.
You can also use RAPTOR, which summarizes documents into a hierarchical structure, to effectively answer questions ranging from specific to abstract, and experiment with the process of obtaining dense summaries using various techniques such as Stuff, Map-Reduce, Map-Refine, CoD (Chain of Density), and Clustering-Map-Refine.


★ More flexible: Construct complex chains using LCEL advanced syntax

It implements parallel processing, conditional branching, routing, dynamic prompt configuration, etc. by utilizing several Runnable classes (RunnableLambda, RunnableParallel, RunnableBranch, RunnablePassthrough, etc.) that make up the LCEL-based chain.
You can even practice advanced designs that selectively change prompts and models based on user input, or branch the chain flow.

★ More precisely: Evaluate and improve the response quality of RAG systems

This book covers how to quantify and evaluate the relevance, reliability, and contextual consistency of LLM responses using RAGAS, and systematically guides various evaluation methods for actual quality experiments, such as creating evaluation datasets with the LangSmith API, LLM-as-a-judge-based evaluation, implementing custom evaluators, heuristic-based evaluation, automating online evaluation, and comparative evaluation of responses.
The exercises are code-based and include a method for comparing and analyzing experimental results.

★ More convenient: Configure agents with LangChain and integrate external tools.

LLM deals with agent architectures that directly call external tools to perform complex tasks.
We will implement automation tasks at a real-world business level by binding various tools such as Python REPL, Tavily search tool, and DALL·E, and through hands-on practice including memory functions and intermediate response streaming.
You can learn how to design an extensible LLM system that goes beyond simple QA through practical examples such as AgentExecutor, Agentic RAG, file analysis, and automated report generation.

★ More Completely: Deploy services that can be provided to real users.

We will use Streamlit to build a web UI that connects user input and chain execution results, and practice post-deployment code modification and testing through configuration files and GitHub integration.
Use LangServe to serve chains or agents as APIs and configure an environment accessible externally through NGROK.


Code reviewers' reviews

“This is a practical guide that focuses on learning concepts through hands-on practice and can be applied directly to actual projects.
Its value is even greater when it is reflected in modern tools such as LangSmith.”
_Jeon Chang-won_ LG CNS

“I hesitated whether I, a non-specialist, could dare to write a review, but I did so with the hope that it would be of some help to readers who, like me, are starting to learn about AI after feeling the need for it while working in a different field.
“Thanks to the hands-on structure and friendly explanations, anyone can get started without any pressure.”
_Kim Moo-sang_ Samsung Electronics

“『RAG Secret Note Using Teddy Note’s Lang Chain』 is a beautiful code that makes LLM jump around.
“As I continued to review, I could feel how much of the author’s blood, sweat, and tears had seeped into this code.”
_Kim Jung-wook_ Brain Crew

▶Praise for this book

“It will be the best choice for anyone who had a difficult time getting started.”
_Kim Jae-ho_Suwon University Graduate School, Department of Computer Science

“This unique Korean example helped me understand everything and grow quickly.”
_Park Jeong-gi_JCH SYSTEMS / AI Senior Researcher / n8n Korea Ambassador

“Follow step by step without complicated explanations! It’s really fascinating.
“It’s true.”
Shin Jeong-ho, Ipsos Korea / Data Science

“You’re not buying a book, you’re buying a compass.”
_Oh Joo-young_ Freelancer

"The Bible for Beginners to LangChain"
_Jeong Gwang-won_, Development Team Leader, Studio M Co., Ltd.

“I no longer have to search for what a Langchain is or how to develop it.”
_Jo Young-jun_STG

“As I followed the code, I soon became a Langchain master.”
_Heo Su-young_Wind Care

▶ Readers who need this book

- Developers who know the basics of the RAG system but need to improve their practical skills
- Developers who want to build a service-level RAG
- Developers interested in improving search quality and optimizing performance
- Corporate personnel who want to build an in-house document search, FAQ system, and knowledge management system.
- People in charge of tasks that require large-volume document processing and accuracy improvement
- Person in charge of establishing a quality management and evaluation system after the introduction of AI
- People who need to build an agent system for work automation

▶ What this book covers

_PART 01 Advanced RAG
After document retrieval, we will re-rank the answers using a reranker to improve the quality of RAG's answers, and explain how to implement it using a QA system based on Naver News and an open-source LLM.
We also introduce five methods for dense summarization.

_PART 02 LCEL Advanced Grammar
LangChain uses various Runnable classes of LCEL, an expression language for efficiently connecting and executing models and data, to perform parallel processing, data transformation, routing, etc.

_PART 03 RAG Evaluation and Improvement
We use RAGAS to assess the quality of responses without the need for a correct answer, and we cover the process of experimenting with and improving the RAG system in various ways, from dataset creation in LangSmith to LLM-based automatic evaluation, heuristic evaluation, and online evaluation.

_PART 04 Agent
We cover how LangChain agents enable LLM to perform complex tasks such as search, computation, and image generation by leveraging external tools.
We will practice tool binding, memory, and streaming output features, and introduce various use cases from Agentic RAG to task automation.

_PART 05 Service Distribution
We cover how to scale LangChain agents into real-world services.
We deploy agents using LangServe and build a web UI that displays user input and execution process using Streamlit.
GOODS SPECIFICS
- Date of issue: June 20, 2025
- Page count, weight, size: 344 pages | 718g | 188*257*17mm
- ISBN13: 9791194084174
- ISBN10: 1194084176

You may also like

카테고리