无法联系上下文

**AI回答:

你的 embeddings 不同模型导致无法匹配!(使用英文测试发现不成立)**

你用的是:

存储时用的 embedding:

SentenceTransformer("all-MiniLM-L6-v2")

检索时用的 embedding:

SentenceTransformer("all-MiniLM-L6-v2")

这看起来没问题,但 你的 query 是中文!

MiniLM-L6-v2 中文能力极差!!!

复制代码
通过查找输入输出,结果发现从文件读取上文的函数根本没起作用
def retrieve(query, k=3):
    query_vector = get_embedding(query)
    results = collection.query(
        query_embeddings=[query_vector],
        n_results=k
    )
    docs = results["documents"]
    print(docs)
    if not docs or not docs[0]:
        return []
    return docs[0]   # 返回 list[string]
相关推荐
共享家95274 小时前
搭建 AI 聊天机器人:”我的人生我做主“
前端·javascript·css·python·pycharm·html·状态模式
Hgfdsaqwr5 小时前
Python在2024年的主要趋势与发展方向
jvm·数据库·python
一晌小贪欢5 小时前
Python 测试利器:使用 pytest 高效编写和管理单元测试
python·单元测试·pytest·python3·python测试
小文数模5 小时前
2026年美赛数学建模C题完整参考论文(含模型和代码)
python·数学建模·matlab
Halo_tjn5 小时前
基于封装的专项 知识点
java·前端·python·算法
Hgfdsaqwr6 小时前
掌握Python魔法方法(Magic Methods)
jvm·数据库·python
weixin_395448916 小时前
export_onnx.py_0130
pytorch·python·深度学习
s1hiyu6 小时前
使用Scrapy框架构建分布式爬虫
jvm·数据库·python
2301_763472466 小时前
使用Seaborn绘制统计图形:更美更简单
jvm·数据库·python
无垠的广袤6 小时前
【VisionFive 2 Lite 单板计算机】边缘AI视觉应用部署:缺陷检测
linux·人工智能·python·opencv·开发板