You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Google Colab部署personal-assistant项目遇多类报错求助

问题与解决方案:personal-assistant在Colab部署的报错处理

一、retrievalQA.py模型加载失败(AssertionError)

错误信息

Loading the Manticore-13B.ggmlv2.q5_1.bin model...
llama.cpp: loading model from models/manticore-13b/Manticore-13B.ggmlv2.q5_1.bin
error loading model: unknown (magic, version) combination: 4f44213c, 50595443; is this really a GGML file?
llama_init_from_file: failed to load model
Traceback (most recent call last):
File "/content/personal-assistant/retrievalQA.py", line 61, in
main()
File "/content/personal-assistant/retrievalQA.py", line 40, in main
llm = load_local_model(model_path, provider='llamacpp')
File "/content/personal-assistant/retrievalQA.py", line 28, in load_local_model
llm = LlamaLLM(model_path, n_gpu_layers=n_gpu_layers,
File "/content/personal-assistant/pa/llm/llamacpp.py", line 20, in init
self.model = Llama(model_path=model_path,
File "/usr/local/lib/python3.10/dist-packages/llama_cpp/llama.py", line 162, in init
assert self.ctx is not None
AssertionError

解决步骤

  • 核心原因是llama-cpp-python新版本已切换到GGUF格式,不再支持旧GGMLv2/v3格式
  1. 下载Manticore-13B模型的GGUF格式版本
  2. 升级llama-cpp-python到最新稳定版:
    pip install --upgrade llama-cpp-python
    
  3. 修改代码中模型路径为GGUF文件的路径,确保加载逻辑匹配新格式

二、旧版llama-cpp-python的参数错误(TypeError)

错误信息

TypeError: Llama.init() got an unexpected keyword argument 'n_gpu_layers'

解决步骤

  • n_gpu_layers是llama-cpp-python较新版本新增参数,旧版本(如0.1.25)不支持
  1. 优先选择升级llama-cpp-python到支持该参数的版本(参考上面的升级命令),保留GPU加速能力
  2. 若必须用旧版本,删除代码中n_gpu_layers参数(但Colab CPU运行13B模型会极慢)

三、inject.py的Embedding编码错误(IndexError)

错误信息

load INSTRUCTOR_Transformer
max_seq_length 512
Traceback (most recent call last):
File "/content/personal-assistant/inject.py", line 66, in
main()
File "/content/personal-assistant/inject.py", line 59, in main
db = Chroma.from_documents(texts, instructor_embeddings,
File "/usr/local/lib/python3.10/dist-packages/langchain/vectorstores/chroma.py", line 435, in from_documents
return cls.from_texts(
File "/usr/local/lib/python3.10/dist-packages/langchain/vectorstores/chroma.py", line 403, in from_texts
chroma_collection.add_texts(texts=texts, metadatas=metadatas, ids=ids)
File "/usr/local/lib/python3.10/dist-packages/langchain/vectorstores/chroma.py", line 148, in add_texts
embeddings = self._embedding_function.embed_documents(list(texts))
File "/usr/local/lib/python3.10/dist-packages/langchain/embeddings/huggingface.py", line 158, in embed_documents
embeddings = self.client.encode(instruction_pairs, **self.encode_kwargs)
File "/usr/local/lib/python3.10/dist-packages/InstructorEmbedding/instructor.py", line 524, in encode
if isinstance(sentences[0],list):
IndexError: list index out of range

解决步骤

  • 核心原因是传入的texts列表为空,无有效文档可处理
  1. 检查inject.py中数据源的路径、读取逻辑,确保能加载到有效文本内容
  2. 在生成texts后添加空值判断,提前终止流程避免报错:
    if not texts:
        raise ValueError("No documents found to process. Check your data source.")
    
  3. 确保Langchain与InstructorEmbedding版本兼容,建议安装指定版本:
    pip install langchain==0.0.300 InstructorEmbedding==1.0.1
    

内容的提问来源于stack exchange,提问作者eclipt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 07:44:59