llama_index [问题]:聊天引擎返回的过多内容,如何让它不匹配那么多?

e5njpo68  于 2个月前  发布在  其他
关注(0)|答案(6)|浏览(31)

问题验证

  • 我已经在文档和discord上寻找答案。

问题

chat_engine = index.as_chat_engine(
chat_mode='condense_plus_context', use_async=True, system_prompt=SYSTEM_PROMPT,
)
返回的内容太长了,我该如何让它只返回前1或2个匹配项?

oxf4rvwz

oxf4rvwz1#

已经是默认的前两名了?

kqqjbcuj

kqqjbcuj2#

它已经是默认的前两名了?👀
但是通过verbose=True,我看到了8个匹配的结果(跟随file_path: / / )

dl5txlt9

dl5txlt93#

啊。我猜我以为你使用了向量索引,但你创建了哪种索引?

v1uwarro

v1uwarro4#

我猜我假设你使用了向量索引,但是你创建了哪种索引?
DocumentSummaryIndex
这是我如何使用它的:
storage_context = StorageContext.from_defaults(persist_dir=persist_dir)
index = load_index_from_storage(storage_context)

disbfnqx

disbfnqx5#

我猜我假设你使用了向量索引,但是你创建了哪种索引?
DocumentSummaryIndex
这是我如何使用它的:storage_context = StorageContext.from_defaults(persist_dir=persist_dir) index = load_index_from_storage(storage_context)
这是我如何创建索引的:
splitter = SentenceSplitter(chunk_size=1024)
response_synthesizer = get_response_synthesizer(
response_mode="tree_summarize", use_async=True
)
doc_summary_index = DocumentSummaryIndex.from_documents(
docs,
llm=OurLLM(), #自定义本地模型
transformations=[splitter],
response_synthesizer=response_synthesizer,
show_progress=True,
)
doc_summary_index.storage_context.persist(persist_dir)

gzszwxb4

gzszwxb46#

@yuyu990116 文档摘要索引通过生成文档摘要来工作,并使用这些摘要来决定将哪些文档发送给LLM。
这将把与所选文档相关的所有节点发送到LLM。
实际上没有方法限制使用此索引发送的节点数量,因为它会从所选文档中提取所有节点。

相关问题