跳转到内容

响应模式

目前,我们支持以下选项:

  • 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 the refine_template as well).

    适合更详细的回答。

  • compact (default): similar to refine but compact (concatenate) the chunks beforehand, resulting in less LLM calls.

    详细信息:尽可能将检索到的文本块拼接/打包,使其能够容纳在上下文窗口内 (需考虑text_qa_templaterefine_template之间的最大提示尺寸)。 如果文本过长无法放入单个提示中,则按需分割成多个部分 (使用TokenTextSplitter并允许文本块之间存在部分重叠)。

    Each text part is considered a “chunk” and is sent to the refine synthesizer.

    In short, it is like refine, but with less LLM calls.

  • tree_summarize: 根据需要多次使用 summary_template 提示查询LLM,直到所有连接的块都被查询完毕,产生多个答案,这些答案本身又作为块在 tree_summarize LLM调用中被递归使用,依此类推,直到只剩下一个块,从而得到一个最终答案。

    详细信息:尽可能将文本块拼接以适应上下文窗口,使用summary_template提示, 并在需要时进行分割(同样使用TokenTextSplitter并保留部分文本重叠)。然后,对每个生成的块/分割执行 summary_template查询(注意:没有优化查询!)并获取尽可能多的答案。

    如果只有一个答案(因为只有一个数据块),那么这就是最终答案。

    If there are more than one answer, these themselves are considered as chunks and sent recursively to the tree_summarize process (concatenated/splitted-to-fit/queried).

    适用于摘要总结目的。

  • simple_summarizesimple_summarize: 将所有文本块截断以适应单个LLM提示。适用于快速摘要目的,但可能因截断而丢失细节。

  • no_text: 仅运行检索器以获取本应发送给LLM的节点,但实际并不发送。随后可通过检查response.source_nodes进行查看。

  • accumulateaccumulate:给定一组文本片段和查询,将查询应用于每个文本片段,同时将响应累积到数组中。返回所有响应的连接字符串。适用于需要对每个文本片段分别运行相同查询的场景。

  • compact_accumulate:与 accumulate 相同,但会对每个LLM提示进行“压缩”处理,类似于 compact,并对每个文本块运行相同的查询。

查看响应合成器了解更多。