用 chromadb.Client()(内存模式)建 collection 写数据,重启 Python 进程后 get_collection 报 Collection not found,根因是 Client() 不落盘、数据只在内存。改 PersistentClient(path=...) 后重启数据仍在。
同一 collection 换 embedding 模型后 add/query 报 InvalidDimensionException 维度不匹配,根因是 collection 维度在首次写入时锁定且不可改,需删库重建并全程用同一 embedding 函数。
SentenceTransformerEmbeddingFunction 首次加载模型时 huggingface.co 连接超时报错,根因是 HuggingFace 直连不通。设 HF_ENDPOINT=https://hf-mirror.com(或 modelscope 下载到本地)即可,无需梯子。