如何进行检索
检索是一种常见的技术,聊天机器人使用它来利用聊天模型训练数据之外的信息增强其回复。本节将介绍如何在聊天机器人中实现检索,但值得注意的是,检索是一个非常微妙且深奥的主题。
环境准备
您需要安装一些包,并设置所需的 LLM API 密钥:
- npm
- yarn
- pnpm
npm i @langchain/openai @langchain/core cheerio
yarn add @langchain/openai @langchain/core cheerio
pnpm add @langchain/openai @langchain/core cheerio
接下来,我们还需要设置一个聊天模型,用于以下示例。
Pick your chat model:
- Groq
- OpenAI
- Anthropic
- Google Gemini
- FireworksAI
- MistralAI
- VertexAI
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/groq
yarn add @langchain/groq
pnpm add @langchain/groq
Add environment variables
GROQ_API_KEY=your-api-key
Instantiate the model
import { ChatGroq } from "@langchain/groq";
const llm = new ChatGroq({
model: "llama-3.3-70b-versatile",
temperature: 0
});
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/openai
yarn add @langchain/openai
pnpm add @langchain/openai
Add environment variables
OPENAI_API_KEY=your-api-key
Instantiate the model
import { ChatOpenAI } from "@langchain/openai";
const llm = new ChatOpenAI({
model: "gpt-4o-mini",
temperature: 0
});
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/anthropic
yarn add @langchain/anthropic
pnpm add @langchain/anthropic
Add environment variables
ANTHROPIC_API_KEY=your-api-key
Instantiate the model
import { ChatAnthropic } from "@langchain/anthropic";
const llm = new ChatAnthropic({
model: "claude-3-5-sonnet-20240620",
temperature: 0
});
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/google-genai
yarn add @langchain/google-genai
pnpm add @langchain/google-genai
Add environment variables
GOOGLE_API_KEY=your-api-key
Instantiate the model
import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
const llm = new ChatGoogleGenerativeAI({
model: "gemini-2.0-flash",
temperature: 0
});
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/community
yarn add @langchain/community
pnpm add @langchain/community
Add environment variables
FIREWORKS_API_KEY=your-api-key
Instantiate the model
import { ChatFireworks } from "@langchain/community/chat_models/fireworks";
const llm = new ChatFireworks({
model: "accounts/fireworks/models/llama-v3p1-70b-instruct",
temperature: 0
});
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/mistralai
yarn add @langchain/mistralai
pnpm add @langchain/mistralai
Add environment variables
MISTRAL_API_KEY=your-api-key
Instantiate the model
import { ChatMistralAI } from "@langchain/mistralai";
const llm = new ChatMistralAI({
model: "mistral-large-latest",
temperature: 0
});
Install dependencies
- npm
- yarn
- pnpm
npm i @langchain/google-vertexai
yarn add @langchain/google-vertexai
pnpm add @langchain/google-vertexai
Add environment variables
GOOGLE_APPLICATION_CREDENTIALS=credentials.json
Instantiate the model
import { ChatVertexAI } from "@langchain/google-vertexai";
const llm = new ChatVertexAI({
model: "gemini-1.5-flash",
temperature: 0
});
创建一个检索器
我们将使用LangSmith 文档作为源材料,并将内容存储在向量数据库中以供后续检索。请注意,此示例将略过有关解析和存储数据源的一些具体细节——你可以在此处查看有关创建检索系统的深入文档。
让我们使用文档加载器从文档中提取文本:
import "cheerio";
import { CheerioWebBaseLoader } from "@langchain/community/document_loaders/web/cheerio";
const loader = new CheerioWebBaseLoader(
"https://docs.smith.langchain.com/user_guide"
);
const rawDocs = await loader.load();
rawDocs[0].pageContent.length;
36687
接下来,我们将其拆分为较小的块,以便 LLM 的上下文窗口可以处理,并将其存储在向量数据库中:
import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";
const textSplitter = new RecursiveCharacterTextSplitter({
chunkSize: 500,
chunkOverlap: 0,
});
const allSplits = await textSplitter.splitDocuments(rawDocs);
然后我们将这些块嵌入并存储在向量数据库中:
import { OpenAIEmbeddings } from "@langchain/openai";
import { MemoryVectorStore } from "langchain/vectorstores/memory";
const vectorstore = await MemoryVectorStore.fromDocuments(
allSplits,
new OpenAIEmbeddings()
);
最后,让我们从初始化的向量存储中创建一个检索器:
const retriever = vectorstore.asRetriever(4);
const docs = await retriever.invoke("how can langsmith help with testing?");
console.log(docs);
[
Document {
pageContent: "These test cases can be uploaded in bulk, created on the fly, or exported from application traces. L"... 294 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: { from: 7, to: 7 } }
}
},
Document {
pageContent: "We provide native rendering of chat messages, functions, and retrieve documents.Initial Test SetWhi"... 347 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: { from: 6, to: 6 } }
}
},
Document {
pageContent: "will help in curation of test cases that can help track regressions/improvements and development of "... 393 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: { from: 11, to: 11 } }
}
},
Document {
pageContent: "that time period — this is especially handy for debugging production issues.LangSmith also allows fo"... 396 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: { from: 11, to: 11 } }
}
}
]
我们可以看到,调用上面的检索器会返回一些 LangSmith 文档的部分内容,这些内容包含有关测试的信息,我们的聊天机器人可以在回答问题时用作上下文。现在我们有了一个可以从 LangSmith 文档中返回相关数据的检索器!
文档链
既然我们已经有了一个可以返回 LangChain 文档的检索器,那么我们现在来创建一个链,使其能够使用这些文档作为上下文来回答问题。我们将使用一个createStuffDocumentsChain辅助函数,将所有输入文档“填充”到提示词中。它还将负责将文档格式化为字符串。
除了聊天模型外,该函数还需要提供一个包含context变量的提示词,以及一个名为messages的聊天历史消息占位符。我们将创建一个合适的提示词并按如下方式传递:
import { createStuffDocumentsChain } from "langchain/chains/combine_documents";
import {
ChatPromptTemplate,
MessagesPlaceholder,
} from "@langchain/core/prompts";
const SYSTEM_TEMPLATE = `Answer the user's questions based on the below context.
If the context doesn't contain any relevant information to the question, don't make something up and just say "I don't know":
<context>
{context}
</context>
`;
const questionAnsweringPrompt = ChatPromptTemplate.fromMessages([
["system", SYSTEM_TEMPLATE],
new MessagesPlaceholder("messages"),
]);
const documentChain = await createStuffDocumentsChain({
llm,
prompt: questionAnsweringPrompt,
});
我们可以单独调用此 documentChain
来回答问题。让我们使用上面检索到的文档和相同的问题
langsmith 如何帮助测试?:
import { HumanMessage, AIMessage } from "@langchain/core/messages";
await documentChain.invoke({
messages: [new HumanMessage("Can LangSmith help test my LLM applications?")],
context: docs,
});
"Yes, LangSmith can help test your LLM applications. It allows developers to create datasets, which a"... 229 more characters
看起来不错!作为对比,我们可以尝试不使用上下文文档并比较结果:
await documentChain.invoke({
messages: [new HumanMessage("Can LangSmith help test my LLM applications?")],
context: [],
});
"I don't know."
我们可以看到,LLM 未返回任何结果。
检索链
让我们将此文档链与检索器结合。以下是一种可能的实现方式:
import type { BaseMessage } from "@langchain/core/messages";
import {
RunnablePassthrough,
RunnableSequence,
} from "@langchain/core/runnables";
const parseRetrieverInput = (params: { messages: BaseMessage[] }) => {
return params.messages[params.messages.length - 1].content;
};
const retrievalChain = RunnablePassthrough.assign({
context: RunnableSequence.from([parseRetrieverInput, retriever]),
}).assign({
answer: documentChain,
});
给定一个输入消息列表,我们提取列表中最后一条消息的内容,并将其传递给检索器以获取一些文档。然后,我们将这些文档作为上下文传递给我们的文档链以生成最终响应。 调用此链将合并上述两个步骤:
await retrievalChain.invoke({
messages: [new HumanMessage("Can LangSmith help test my LLM applications?")],
});
{
messages: [
HumanMessage {
lc_serializable: true,
lc_kwargs: {
content: "Can LangSmith help test my LLM applications?",
additional_kwargs: {},
response_metadata: {}
},
lc_namespace: [ "langchain_core", "messages" ],
content: "Can LangSmith help test my LLM applications?",
name: undefined,
additional_kwargs: {},
response_metadata: {}
}
],
context: [
Document {
pageContent: "These test cases can be uploaded in bulk, created on the fly, or exported from application traces. L"... 294 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: [Object] }
}
},
Document {
pageContent: "this guide, we’ll highlight the breadth of workflows LangSmith supports and how they fit into each s"... 343 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: [Object] }
}
},
Document {
pageContent: "We provide native rendering of chat messages, functions, and retrieve documents.Initial Test SetWhi"... 347 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: [Object] }
}
},
Document {
pageContent: "The ability to rapidly understand how the model is performing — and debug where it is failing — is i"... 138 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: [Object] }
}
}
],
answer: "Yes, LangSmith can help test your LLM applications. It allows developers to create datasets, which a"... 297 more characters
}
看起来不错!
查询转换
我们的检索链能够回答有关 LangSmith 的问题,但存在一个问题——聊天机器人以对话方式与用户交互,因此必须处理后续问题。
当前形式的链将难以应对这种情况。例如,对于我们最初的问题的一个后续问题
告诉我更多!。如果我们直接使用该查询调用检索器,我们将得到与 LLM
应用测试无关的文档:
await retriever.invoke("Tell me more!");
[
Document {
pageContent: "Oftentimes, changes in the prompt, retrieval strategy, or model choice can have huge implications in"... 40 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: { from: 8, to: 8 } }
}
},
Document {
pageContent: "This allows you to quickly test out different prompts and models. You can open the playground from a"... 37 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: { from: 10, to: 10 } }
}
},
Document {
pageContent: "We provide native rendering of chat messages, functions, and retrieve documents.Initial Test SetWhi"... 347 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: { from: 6, to: 6 } }
}
},
Document {
pageContent: "together, making it easier to track the performance of and annotate your application across multiple"... 244 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: { from: 11, to: 11 } }
}
}
]
这是因为检索器没有内在的状态概念,只会提取与给定查询最相似的文档。为了解决这个问题,我们可以利用 LLM 将查询转换为一个不包含任何外部引用的独立查询。
以下是一个示例:
const queryTransformPrompt = ChatPromptTemplate.fromMessages([
new MessagesPlaceholder("messages"),
[
"user",
"Given the above conversation, generate a search query to look up in order to get information relevant to the conversation. Only respond with the query, nothing else.",
],
]);
const queryTransformationChain = queryTransformPrompt.pipe(llm);
await queryTransformationChain.invoke({
messages: [
new HumanMessage("Can LangSmith help test my LLM applications?"),
new AIMessage(
"Yes, LangSmith can help test and evaluate your LLM applications. It allows you to quickly edit examples and add them to datasets to expand the surface area of your evaluation sets or to fine-tune a model for improved quality or reduced costs. Additionally, LangSmith can be used to monitor your application, log all traces, visualize latency and token usage statistics, and troubleshoot specific issues as they arise."
),
new HumanMessage("Tell me more!"),
],
});
AIMessage {
lc_serializable: true,
lc_kwargs: {
content: '"LangSmith LLM application testing and evaluation features"',
tool_calls: [],
invalid_tool_calls: [],
additional_kwargs: { function_call: undefined, tool_calls: undefined },
response_metadata: {}
},
lc_namespace: [ "langchain_core", "messages" ],
content: '"LangSmith LLM application testing and evaluation features"',
name: undefined,
additional_kwargs: { function_call: undefined, tool_calls: undefined },
response_metadata: {
tokenUsage: { completionTokens: 11, promptTokens: 144, totalTokens: 155 },
finish_reason: "stop"
},
tool_calls: [],
invalid_tool_calls: []
}
太棒了!这个转换后的查询将提取与 LLM 应用测试相关的上下文文档。
让我们将其添加到检索链中。我们可以按如下方式封装检索器:
import { RunnableBranch } from "@langchain/core/runnables";
import { StringOutputParser } from "@langchain/core/output_parsers";
const queryTransformingRetrieverChain = RunnableBranch.from([
[
(params: { messages: BaseMessage[] }) => params.messages.length === 1,
RunnableSequence.from([parseRetrieverInput, retriever]),
],
queryTransformPrompt.pipe(llm).pipe(new StringOutputParser()).pipe(retriever),
]).withConfig({ runName: "chat_retriever_chain" });
然后,我们可以使用此查询转换链来改进检索链,使其更能处理此类后续问题:
const conversationalRetrievalChain = RunnablePassthrough.assign({
context: queryTransformingRetrieverChain,
}).assign({
answer: documentChain,
});
太棒了!让我们用与之前相同的输入来调用这个新链:
await conversationalRetrievalChain.invoke({
messages: [new HumanMessage("Can LangSmith help test my LLM applications?")],
});
{
messages: [
HumanMessage {
lc_serializable: true,
lc_kwargs: {
content: "Can LangSmith help test my LLM applications?",
additional_kwargs: {},
response_metadata: {}
},
lc_namespace: [ "langchain_core", "messages" ],
content: "Can LangSmith help test my LLM applications?",
name: undefined,
additional_kwargs: {},
response_metadata: {}
}
],
context: [
Document {
pageContent: "These test cases can be uploaded in bulk, created on the fly, or exported from application traces. L"... 294 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: [Object] }
}
},
Document {
pageContent: "this guide, we’ll highlight the breadth of workflows LangSmith supports and how they fit into each s"... 343 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: [Object] }
}
},
Document {
pageContent: "We provide native rendering of chat messages, functions, and retrieve documents.Initial Test SetWhi"... 347 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: [Object] }
}
},
Document {
pageContent: "The ability to rapidly understand how the model is performing — and debug where it is failing — is i"... 138 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: [Object] }
}
}
],
answer: "Yes, LangSmith can help test your LLM applications. It allows developers to create datasets, which a"... 297 more characters
}
await conversationalRetrievalChain.invoke({
messages: [
new HumanMessage("Can LangSmith help test my LLM applications?"),
new AIMessage(
"Yes, LangSmith can help test and evaluate your LLM applications. It allows you to quickly edit examples and add them to datasets to expand the surface area of your evaluation sets or to fine-tune a model for improved quality or reduced costs. Additionally, LangSmith can be used to monitor your application, log all traces, visualize latency and token usage statistics, and troubleshoot specific issues as they arise."
),
new HumanMessage("Tell me more!"),
],
});
{
messages: [
HumanMessage {
lc_serializable: true,
lc_kwargs: {
content: "Can LangSmith help test my LLM applications?",
additional_kwargs: {},
response_metadata: {}
},
lc_namespace: [ "langchain_core", "messages" ],
content: "Can LangSmith help test my LLM applications?",
name: undefined,
additional_kwargs: {},
response_metadata: {}
},
AIMessage {
lc_serializable: true,
lc_kwargs: {
content: "Yes, LangSmith can help test and evaluate your LLM applications. It allows you to quickly edit examp"... 317 more characters,
tool_calls: [],
invalid_tool_calls: [],
additional_kwargs: {},
response_metadata: {}
},
lc_namespace: [ "langchain_core", "messages" ],
content: "Yes, LangSmith can help test and evaluate your LLM applications. It allows you to quickly edit examp"... 317 more characters,
name: undefined,
additional_kwargs: {},
response_metadata: {},
tool_calls: [],
invalid_tool_calls: []
},
HumanMessage {
lc_serializable: true,
lc_kwargs: {
content: "Tell me more!",
additional_kwargs: {},
response_metadata: {}
},
lc_namespace: [ "langchain_core", "messages" ],
content: "Tell me more!",
name: undefined,
additional_kwargs: {},
response_metadata: {}
}
],
context: [
Document {
pageContent: "These test cases can be uploaded in bulk, created on the fly, or exported from application traces. L"... 294 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: [Object] }
}
},
Document {
pageContent: "We provide native rendering of chat messages, functions, and retrieve documents.Initial Test SetWhi"... 347 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: [Object] }
}
},
Document {
pageContent: "this guide, we’ll highlight the breadth of workflows LangSmith supports and how they fit into each s"... 343 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: [Object] }
}
},
Document {
pageContent: "will help in curation of test cases that can help track regressions/improvements and development of "... 393 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: [Object] }
}
}
],
answer: "LangSmith supports a variety of workflows to aid in the development of your applications, from creat"... 607 more characters
}
你可以查看 这个 LangSmith 跟踪,亲自了解内部查询转换步骤。
流式传输
由于此链是使用 LCEL 构建的,因此你可以使用熟悉的 .stream() 方法:
const stream = await conversationalRetrievalChain.stream({
messages: [
new HumanMessage("Can LangSmith help test my LLM applications?"),
new AIMessage(
"Yes, LangSmith can help test and evaluate your LLM applications. It allows you to quickly edit examples and add them to datasets to expand the surface area of your evaluation sets or to fine-tune a model for improved quality or reduced costs. Additionally, LangSmith can be used to monitor your application, log all traces, visualize latency and token usage statistics, and troubleshoot specific issues as they arise."
),
new HumanMessage("Tell me more!"),
],
});
for await (const chunk of stream) {
console.log(chunk);
}
{
messages: [
HumanMessage {
lc_serializable: true,
lc_kwargs: {
content: "Can LangSmith help test my LLM applications?",
additional_kwargs: {},
response_metadata: {}
},
lc_namespace: [ "langchain_core", "messages" ],
content: "Can LangSmith help test my LLM applications?",
name: undefined,
additional_kwargs: {},
response_metadata: {}
},
AIMessage {
lc_serializable: true,
lc_kwargs: {
content: "Yes, LangSmith can help test and evaluate your LLM applications. It allows you to quickly edit examp"... 317 more characters,
tool_calls: [],
invalid_tool_calls: [],
additional_kwargs: {},
response_metadata: {}
},
lc_namespace: [ "langchain_core", "messages" ],
content: "Yes, LangSmith can help test and evaluate your LLM applications. It allows you to quickly edit examp"... 317 more characters,
name: undefined,
additional_kwargs: {},
response_metadata: {},
tool_calls: [],
invalid_tool_calls: []
},
HumanMessage {
lc_serializable: true,
lc_kwargs: {
content: "Tell me more!",
additional_kwargs: {},
response_metadata: {}
},
lc_namespace: [ "langchain_core", "messages" ],
content: "Tell me more!",
name: undefined,
additional_kwargs: {},
response_metadata: {}
}
]
}
{
context: [
Document {
pageContent: "These test cases can be uploaded in bulk, created on the fly, or exported from application traces. L"... 294 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: [Object] }
}
},
Document {
pageContent: "We provide native rendering of chat messages, functions, and retrieve documents.Initial Test SetWhi"... 347 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: [Object] }
}
},
Document {
pageContent: "this guide, we’ll highlight the breadth of workflows LangSmith supports and how they fit into each s"... 343 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: [Object] }
}
},
Document {
pageContent: "will help in curation of test cases that can help track regressions/improvements and development of "... 393 more characters,
metadata: {
source: "https://docs.smith.langchain.com/user_guide",
loc: { lines: [Object] }
}
}
]
}
{ answer: "" }
{ answer: "Lang" }
{ answer: "Smith" }
{ answer: " offers" }
{ answer: " a" }
{ answer: " comprehensive" }
{ answer: " suite" }
{ answer: " of" }
{ answer: " tools" }
{ answer: " and" }
{ answer: " workflows" }
{ answer: " to" }
{ answer: " support" }
{ answer: " the" }
{ answer: " development" }
{ answer: " and" }
{ answer: " testing" }
{ answer: " of" }
{ answer: " L" }
{ answer: "LM" }
{ answer: " applications" }
{ answer: "." }
{ answer: " Here" }
{ answer: " are" }
{ answer: " some" }
{ answer: " key" }
{ answer: " features" }
{ answer: " and" }
{ answer: " functionalities" }
{ answer: ":\n\n" }
{ answer: "1" }
{ answer: "." }
{ answer: " **" }
{ answer: "Test" }
{ answer: " Case" }
{ answer: " Management" }
{ answer: "**" }
{ answer: ":\n" }
{ answer: " " }
{ answer: " -" }
{ answer: " **" }
{ answer: "Bulk" }
{ answer: " Upload" }
{ answer: " and" }
{ answer: " Creation" }
{ answer: "**" }
{ answer: ":" }
{ answer: " You" }
{ answer: " can" }
{ answer: " upload" }
{ answer: " test" }
{ answer: " cases" }
{ answer: " in" }
{ answer: " bulk" }
{ answer: "," }
{ answer: " create" }
{ answer: " them" }
{ answer: " on" }
{ answer: " the" }
{ answer: " fly" }
{ answer: "," }
{ answer: " or" }
{ answer: " export" }
{ answer: " them" }
{ answer: " from" }
{ answer: " application" }
{ answer: " traces" }
{ answer: ".\n" }
{ answer: " " }
{ answer: " -" }
{ answer: " **" }
{ answer: "Datas" }
{ answer: "ets" }
{ answer: "**" }
{ answer: ":" }
{ answer: " Lang" }
{ answer: "Smith" }
{ answer: " allows" }
{ answer: " you" }
{ answer: " to" }
{ answer: " create" }
{ answer: " datasets" }
{ answer: "," }
{ answer: " which" }
{ answer: " are" }
{ answer: " collections" }
{ answer: " of" }
{ answer: " inputs" }
{ answer: " and" }
{ answer: " reference" }
{ answer: " outputs" }
{ answer: "." }
{ answer: " These" }
{ answer: " datasets" }
{ answer: " can" }
{ answer: " be" }
{ answer: " used" }
{ answer: " to" }
{ answer: " run" }
{ answer: " tests" }
{ answer: " on" }
{ answer: " your" }
{ answer: " L" }
{ answer: "LM" }
{ answer: " applications" }
{ answer: ".\n\n" }
{ answer: "2" }
{ answer: "." }
{ answer: " **" }
{ answer: "Custom" }
{ answer: " Evalu" }
{ answer: "ations" }
{ answer: "**" }
{ answer: ":\n" }
{ answer: " " }
{ answer: " -" }
{ answer: " **" }
{ answer: "LL" }
{ answer: "M" }
{ answer: " and" }
{ answer: " He" }
{ answer: "uristic" }
{ answer: " Based" }
{ answer: "**" }
{ answer: ":" }
{ answer: " You" }
{ answer: " can" }
{ answer: " run" }
{ answer: " custom" }
{ answer: " evaluations" }
{ answer: " using" }
{ answer: " both" }
{ answer: " L" }
{ answer: "LM" }
{ answer: "-based" }
{ answer: " and" }
{ answer: " heuristic" }
{ answer: "-based" }
{ answer: " methods" }
{ answer: " to" }
{ answer: " score" }
{ answer: " test" }
{ answer: " results" }
{ answer: ".\n\n" }
{ answer: "3" }
{ answer: "." }
{ answer: " **" }
{ answer: "Comparison" }
{ answer: " View" }
{ answer: "**" }
{ answer: ":\n" }
{ answer: " " }
{ answer: " -" }
{ answer: " **" }
{ answer: "Pro" }
{ answer: "tot" }
{ answer: "yp" }
{ answer: "ing" }
{ answer: " and" }
{ answer: " Regression" }
{ answer: " Tracking" }
{ answer: "**" }
{ answer: ":" }
{ answer: " When" }
{ answer: " prot" }
{ answer: "otyping" }
{ answer: " different" }
{ answer: " versions" }
{ answer: " of" }
{ answer: " your" }
{ answer: " applications" }
{ answer: "," }
{ answer: " Lang" }
{ answer: "Smith" }
{ answer: " provides" }
{ answer: " a" }
{ answer: " comparison" }
{ answer: " view" }
{ answer: " to" }
{ answer: " see" }
{ answer: " if" }
{ answer: " there" }
{ answer: " have" }
{ answer: " been" }
{ answer: " any" }
{ answer: " regress" }
{ answer: "ions" }
{ answer: " with" }
{ answer: " respect" }
{ answer: " to" }
{ answer: " your" }
{ answer: " initial" }
{ answer: " test" }
{ answer: " cases" }
{ answer: ".\n\n" }
{ answer: "4" }
{ answer: "." }
{ answer: " **" }
{ answer: "Native" }
{ answer: " Rendering" }
{ answer: "**" }
{ answer: ":\n" }
{ answer: " " }
{ answer: " -" }
{ answer: " **" }
{ answer: "Chat" }
{ answer: " Messages" }
{ answer: "," }
{ answer: " Functions" }
{ answer: "," }
{ answer: " and" }
{ answer: " Documents" }
{ answer: "**" }
{ answer: ":" }
{ answer: " Lang" }
{ answer: "Smith" }
{ answer: " provides" }
{ answer: " native" }
{ answer: " rendering" }
{ answer: " of" }
{ answer: " chat" }
{ answer: " messages" }
{ answer: "," }
{ answer: " functions" }
{ answer: "," }
{ answer: " and" }
{ answer: " retrieved" }
{ answer: " documents" }
{ answer: "," }
{ answer: " making" }
{ answer: " it" }
{ answer: " easier" }
{ answer: " to" }
{ answer: " visualize" }
{ answer: " and" }
{ answer: " understand" }
{ answer: " the" }
{ answer: " outputs" }
{ answer: ".\n\n" }
{ answer: "5" }
{ answer: "." }
{ answer: " **" }
{ answer: "Pro" }
{ answer: "tot" }
{ answer: "yp" }
{ answer: "ing" }
{ answer: " Support" }
{ answer: "**" }
{ answer: ":\n" }
{ answer: " " }
{ answer: " -" }
{ answer: " **" }
{ answer: "Quick" }
{ answer: " Experiment" }
{ answer: "ation" }
{ answer: "**" }
{ answer: ":" }
{ answer: " The" }
{ answer: " platform" }
{ answer: " supports" }
{ answer: " quick" }
{ answer: " experimentation" }
{ answer: " with" }
{ answer: " different" }
{ answer: " prompts" }
{ answer: "," }
{ answer: " model" }
{ answer: " types" }
{ answer: "," }
{ answer: " retrieval" }
{ answer: " strategies" }
{ answer: "," }
{ answer: " and" }
{ answer: " other" }
{ answer: " parameters" }
{ answer: ".\n\n" }
{ answer: "6" }
{ answer: "." }
{ answer: " **" }
{ answer: "Feedback" }
{ answer: " Capture" }
{ answer: "**" }
{ answer: ":\n" }
{ answer: " " }
{ answer: " -" }
{ answer: " **" }
{ answer: "Human" }
{ answer: " Feedback" }
{ answer: "**" }
{ answer: ":" }
{ answer: " When" }
{ answer: " launching" }
{ answer: " your" }
{ answer: " application" }
{ answer: " to" }
{ answer: " an" }
{ answer: " initial" }
{ answer: " set" }
{ answer: " of" }
{ answer: " users" }
{ answer: "," }
{ answer: " Lang" }
{ answer: "Smith" }
{ answer: " allows" }
{ answer: " you" }
{ answer: " to" }
{ answer: " gather" }
{ answer: " human" }
{ answer: " feedback" }
{ answer: " on" }
{ answer: " the" }
{ answer: " responses" }
{ answer: "." }
{ answer: " This" }
{ answer: " helps" }
{ answer: " identify" }
{ answer: " interesting" }
{ answer: " runs" }
{ answer: " and" }
{ answer: " highlight" }
{ answer: " edge" }
{ answer: " cases" }
{ answer: " causing" }
{ answer: " problematic" }
{ answer: " responses" }
{ answer: ".\n" }
{ answer: " " }
{ answer: " -" }
{ answer: " **" }
{ answer: "Feedback" }
{ answer: " Scores" }
{ answer: "**" }
{ answer: ":" }
{ answer: " You" }
{ answer: " can" }
{ answer: " attach" }
{ answer: " feedback" }
{ answer: " scores" }
{ answer: " to" }
{ answer: " logged" }
{ answer: " traces" }
{ answer: "," }
{ answer: " often" }
{ answer: " integrated" }
{ answer: " into" }
{ answer: " the" }
{ answer: " system" }
{ answer: ".\n\n" }
{ answer: "7" }
{ answer: "." }
{ answer: " **" }
{ answer: "Monitoring" }
{ answer: " and" }
{ answer: " Troubles" }
{ answer: "hooting" }
{ answer: "**" }
{ answer: ":\n" }
{ answer: " " }
{ answer: " -" }
{ answer: " **" }
{ answer: "Logging" }
{ answer: " and" }
{ answer: " Visualization" }
{ answer: "**" }
{ answer: ":" }
{ answer: " Lang" }
{ answer: "Smith" }
{ answer: " logs" }
{ answer: " all" }
{ answer: " traces" }
{ answer: "," }
{ answer: " visual" }
{ answer: "izes" }
{ answer: " latency" }
{ answer: " and" }
{ answer: " token" }
{ answer: " usage" }
{ answer: " statistics" }
{ answer: "," }
{ answer: " and" }
{ answer: " helps" }
{ answer: " troubleshoot" }
{ answer: " specific" }
{ answer: " issues" }
{ answer: " as" }
{ answer: " they" }
{ answer: " arise" }
{ answer: ".\n\n" }
{ answer: "Overall" }
{ answer: "," }
{ answer: " Lang" }
{ answer: "Smith" }
{ answer: " is" }
{ answer: " designed" }
{ answer: " to" }
{ answer: " support" }
{ answer: " the" }
{ answer: " entire" }
{ answer: " lifecycle" }
{ answer: " of" }
{ answer: " L" }
{ answer: "LM" }
{ answer: " application" }
{ answer: " development" }
{ answer: "," }
{ answer: " from" }
{ answer: " initial" }
{ answer: " prot" }
{ answer: "otyping" }
{ answer: " to" }
{ answer: " deployment" }
{ answer: " and" }
{ answer: " ongoing" }
{ answer: " monitoring" }
{ answer: "," }
{ answer: " making" }
{ answer: " it" }
{ answer: " a" }
{ answer: " powerful" }
{ answer: " tool" }
{ answer: " for" }
{ answer: " developers" }
{ answer: " looking" }
{ answer: " to" }
{ answer: " build" }
{ answer: " and" }
{ answer: " maintain" }
{ answer: " high" }
{ answer: "-quality" }
{ answer: " L" }
{ answer: "LM" }
{ answer: " applications" }
{ answer: "." }
{ answer: "" }
下一步
你现在已经学习了一些将个人数据作为上下文添加到聊天机器人中的技术。
本指南仅涉及检索技术的表面内容。如需了解更多关于数据摄入、准备和检索最相关数据的不同方法,请查看我们的检索指南。