Langchain-Chatchat
Langchain-Chatchat copied to clipboard
执行python init_database.py --recreate-vs 命令报错,ERROR: init() got an unexpected keyword argument '_name_or_path' AttributeError: 'NoneType' object has no attribute 'conjugate'
2024-03-06 17:28:41,134 - SentenceTransformer.py[line:66] - INFO: Load pretrained SentenceTransformer: embeddings 2024-03-06 17:28:41,469 - embeddings_api.py[line:40] - ERROR: init() got an unexpected keyword argument '_name_or_path' AttributeError: 'NoneType' object has no attribute 'conjugate'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/hduser/langchainchatchat/init_database.py", line 107, in
执行python init_database.py --recreate-vs 命令报错
复现问题的步骤 / Steps to Reproduce python init_database.py --recreate-vs
环境信息 / Environment Information
- langchain-ChatGLM 版本/commit 号:0.2.10
- 是否使用 Docker 部署(是/否):否
- 使用的模型(ChatGLM2-6B / Qwen-7B 等):ChatGLM3-6B
- 使用的 Embedding 模型(moka-ai/m3e-base 等):moka-ai/m3e-base / Embedding model used (moka-ai/m3e-base, etc.): moka-ai/m3e-base
- 使用的向量库类型 (faiss / milvus / pg_vector 等): milvus
- 操作系统及版本 / Operating system and version: Linux algo 5.4.0-171-generic #189-Ubuntu SMP Fri Jan 5 14:23:02 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
- Python 版本 / Python version:3.9.18
- 其他相关环境信息 / Other relevant environment information:
附加信息 / Additional Information 添加与问题相关的任何其他信息 / Add any other information related to the issue.
Based on the error message you provided, it seems like there are two main issues: init() got an unexpected keyword argument '_name_or_path'
and AttributeError: 'NoneType' object has no attribute 'conjugate'
.
The first error suggests that there's an issue with how the embedding model is being initialized. The unexpected keyword argument _name_or_path
implies that the function or class constructor being called does not accept this argument, or it's being passed incorrectly. Ensure that the version of the embedding model or library you are using in EMBEDDING_MODEL
(specified in configs/model_config.py
) supports the arguments being passed during its initialization.
The second error, AttributeError: 'NoneType' object has no attribute 'conjugate'
, suggests that an operation is being attempted on a None
object instead of a numerical array or a similar object that supports the conjugate
method. This could happen if the embeddings are not correctly loaded or generated, resulting in None
being passed to the normalize
function.
The normalize
function in base.py
has the following signature:
def normalize(embeddings: List[List[float]]) -> np.ndarray:
It expects a list of lists of floats as input, where each inner list represents a vector of embeddings. If None
is passed to this function, it will result in the AttributeError
you're seeing.
To resolve these issues, you can follow these steps:
-
Check the Embedding Model Initialization: Verify the initialization of the embedding model and ensure it supports the arguments being passed.
-
Review the
normalize
Function: Verify the implementation of thenormalize
function inbase.py
to ensure it correctly handles cases where embeddings might not be loaded or generated as expected. -
Verify Embedding Model Compatibility: Ensure that the embedding model specified by
EMBEDDING_MODEL
is compatible with the version of the library or framework you are using. -
Update Dependencies: Make sure all relevant Python packages are updated to their latest versions that support the functionality you are using.
-
Debug Initialization Parameters: Temporarily modify the code where the embedding model is initialized to print or log the parameters being passed to the model's constructor.
-
Consult Documentation: Review the documentation for the embedding model and the library or framework it's part of.
If you continue to encounter issues, please provide more details about the steps leading up to the error, and any additional error messages or logs that might help diagnose the problem.
For more information, you can refer to the following issues in the Langchain-Chatchat repository that discuss similar problems:
- 创建知识库出错
- 英文版bge-large-en-v1.5 embeddings 向量无法加载
- [BUG] 简洁阐述问题 / 运行python init_database.py --recreate-vs错误
- [BUG] 简洁阐述问题 / Concise description of the issue
- python init_database.py --recreate-vs提示CUDA没有启用
I hope this helps! If you have any other questions, feel free to ask.
Sources
- 创建知识库出错
- 英文版bge-large-en-v1.5 embeddings 向量无法加载
- [BUG] 简洁阐述问题 / 运行python init_database.py --recreate-vs错误
- [BUG] 简洁阐述问题 / Concise description of the issue
- python init_database.py --recreate-vs提示CUDA没有启用
- init_database.py
- server/knowledge_base/kb_service/base.py
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
@dosu-bot
同样的问题