RuntimeError
After configuring the environment as required, execute the example code and report an error:
Traceback (most recent call last):
File "/workspace/QZhou-Embedding-Zh/run_infer.py", line 10, in
model = SentenceTransformer(
File "/workspace/envs/QZhou-Embedding-Zh/lib/python3.10/site-packages/sentence_transformers/SentenceTransformer.py", line 308, in init
modules, self.module_kwargs = self._load_sbert_model(
File "/workspace/envs/QZhou-Embedding-Zh/lib/python3.10/site-packages/sentence_transformers/SentenceTransformer.py", line 1755, in _load_sbert_model
module = module_class.load(module_path)
File "/workspace/envs/QZhou-Embedding-Zh/lib/python3.10/site-packages/sentence_transformers/models/Dense.py", line 87, in load
load_safetensors_model(model, os.path.join(input_path, "model.safetensors"))
File "/workspace/envs/QZhou-Embedding-Zh/lib/python3.10/site-packages/safetensors/torch.py", line 271, in load_model
raise RuntimeError(error)
RuntimeError: Error(s) in loading state_dict for Dense:
Invalid key(s) in state_dict: "linear.bias", "linear.weight", mismatched dtypes or shape.
Please make sure that the following versions of the dependent libraries are installed in your environment:
Python: 3.10.12
Sentence Transformers: 3.4.1
Transformers: 4.51.1
The parameters 'linear.bias' and 'linear.weight' should belong to the MRL projection layer. We previously encountered saving failures during model training in this component as well. Your current issue appears to be related to model loading. Please verify your environment versions, we will conduct further root cause analysis.