chore(dialog): 调整相似度阈值以优化匹配效果

- 在 dialog_service.py 中设置更小的相似度阈值(从 0.1 调整到 0.01)
- 更新 docker-compose.yml 和 docker-compose_gpu.yml,挂载 dialog_service.py 文件
This commit is contained in:
zstar 2025-06-09 18:46:51 +08:00
parent 7ea1b7bbe8
commit cd2f479bb4
3 changed files with 5 additions and 1 deletions

View File

@ -495,8 +495,10 @@ def ask(question, kb_ids, tenant_id):
max_tokens = chat_mdl.max_length
# 获取所有知识库的租户ID并去重
tenant_ids = list(set([kb.tenant_id for kb in kbs]))
# 设置更小的相似度阈值以适配更好的效果(原始值0.1)
similarity_threshold = 0.01
# 调用检索器检索相关文档片段
kbinfos = retriever.retrieval(question, embd_mdl, tenant_ids, kb_ids, 1, 12, 0.1, 0.3, aggs=False, rank_feature=label_question(question, kbs))
kbinfos = retriever.retrieval(question, embd_mdl, tenant_ids, kb_ids, 1, 12, similarity_threshold, 0.3, aggs=False, rank_feature=label_question(question, kbs))
# 将检索结果格式化为提示词并确保不超过模型最大token限制
knowledges = kb_prompt(kbinfos, max_tokens)
prompt = """

View File

@ -18,6 +18,7 @@ services:
- ./nginx/proxy.conf:/etc/nginx/proxy.conf
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ../api/db/services/database.py:/ragflow/api/db/services/database.py
- ../api/db/services/dialog_service.py:/ragflow/api/db/services/dialog_service.py
env_file: .env
environment:
- TZ=${TIMEZONE}

View File

@ -18,6 +18,7 @@ services:
- ./nginx/proxy.conf:/etc/nginx/proxy.conf
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ../api/db/services/database.py:/ragflow/api/db/services/database.py
- ../api/db/services/dialog_service.py:/ragflow/api/db/services/dialog_service.py
env_file: .env
environment:
- TZ=${TIMEZONE}