响应模式
目前,我们支持以下选项:
-
refine: create and refine an answer by sequentially going through each retrieved text chunk. This makes a separate LLM call per Node/retrieved chunk.详情:第一个数据块通过
text_qa_template提示词用于查询。随后将答案与下一个数据块(以及原始问题)通过refine_template提示词用于另一个查询。依此类推直至所有数据块解析完成。If a chunk is too large to fit within the window (considering the prompt size), it is split using a
TokenTextSplitter(allowing some text overlap between chunks) and the (new) additional chunks are considered as chunks of the original chunks collection (and thus queried with therefine_templateas well).适合更详细的回答。
-
compact(default): similar torefinebut compact (concatenate) the chunks beforehand, resulting in less LLM calls.详细信息:尽可能将检索到的文本块拼接/打包,使其能够容纳在上下文窗口内 (需考虑
text_qa_template和refine_template之间的最大提示尺寸)。 如果文本过长无法放入单个提示中,则按需分割成多个部分 (使用TokenTextSplitter并允许文本块之间存在部分重叠)。Each text part is considered a “chunk” and is sent to the
refinesynthesizer.In short, it is like
refine, but with less LLM calls. -
tree_summarize: 根据需要多次使用summary_template提示查询LLM,直到所有连接的块都被查询完毕,产生多个答案,这些答案本身又作为块在tree_summarizeLLM调用中被递归使用,依此类推,直到只剩下一个块,从而得到一个最终答案。详细信息:尽可能将文本块拼接以适应上下文窗口,使用
summary_template提示, 并在需要时进行分割(同样使用TokenTextSplitter并保留部分文本重叠)。然后,对每个生成的块/分割执行summary_template查询(注意:没有优化查询!)并获取尽可能多的答案。如果只有一个答案(因为只有一个数据块),那么这就是最终答案。
If there are more than one answer, these themselves are considered as chunks and sent recursively to the
tree_summarizeprocess (concatenated/splitted-to-fit/queried).适用于摘要总结目的。
-
simple_summarizesimple_summarize: 将所有文本块截断以适应单个LLM提示。适用于快速摘要目的,但可能因截断而丢失细节。 -
no_text: 仅运行检索器以获取本应发送给LLM的节点,但实际并不发送。随后可通过检查response.source_nodes进行查看。 -
accumulateaccumulate:给定一组文本片段和查询,将查询应用于每个文本片段,同时将响应累积到数组中。返回所有响应的连接字符串。适用于需要对每个文本片段分别运行相同查询的场景。 -
compact_accumulate:与 accumulate 相同,但会对每个LLM提示进行“压缩”处理,类似于compact,并对每个文本块运行相同的查询。
查看响应合成器了解更多。