[Bug]: IntelEmbedding RuntimeError
Author: idkSethCreated Jul 6, 2025Updated Sep 17, 2026
LabelsbugP2
Bug Description
Running the example code results in the error.
Version
0.12.46
Steps to Reproduce
from llama_index.embeddings.huggingface_optimum_intel import IntelEmbedding
embed_model = IntelEmbedding(
"Intel/bge-small-en-v1.5-rag-int8-static",
)
Relevant Logs/Tracbacks
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File /media/seth/Main/LlamaIndex/lib/python3.12/site-packages/transformers/modeling_utils.py:556, in load_state_dict(checkpoint_file, is_quantized, map_location, weights_only)
555 extra_args = {"mmap": True}
--> 556 return torch.load(
557 checkpoint_file,
558 map_location=map_location,
559 weights_only=weights_only,
560 **extra_args,
561 )
562 except Exception as e:
File /media/seth/Main/LlamaIndex/lib/python3.12/site-packages/torch/serialization.py:1495, in load(f, map_location, pickle_module, weights_only, mmap, **pickle_load_args)
1494 if weights_only:
-> 1495 raise RuntimeError(
1496 "Cannot use ``weights_only=True`` with TorchScript archives passed to "
1497 "``torch.load``. " + UNSAFE_MESSAGE
1498 )
1499 opened_file.seek(orig_position)
RuntimeError: Cannot use ``weights_only=True`` with TorchScript archives passed to ``torch.load``. In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
During handling of the above exception, another exception occurred:
UnicodeDecodeError Traceback (most recent call last)
File /media/seth/Main/LlamaIndex/lib/python3.12/site-packages/transformers/modeling_utils.py:565, in load_state_dict(checkpoint_file, is_quantized, map_location, weights_only)
564 with open(checkpoint_file) as f:
--> 565 if f.read(7) == "version":
566 raise OSError(
567 "You seem to have cloned a repository without having git-lfs installed. Please install "
568 "git-lfs and run `git lfs install` followed by `git lfs pull` in the folder "
569 "you cloned."
570 )
File <frozen codecs>:322, in decode(self, input, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 64: invalid start byte
During handling of the above exception, another exception occurred:
OSError Traceback (most recent call last)
Cell In[8], line 2
1 # Create index with HuggingFace embeddings
----> 2 embed_model = IntelEmbedding(
3 "Intel/bge-small-en-v1.5-rag-int8-static",
4 )
6 index = VectorStoreIndex.from_documents(
7 docs,
8 storage_context=storage_context,
9 embed_model=embed_model
10 )
12 # Save the index for later use
File /media/seth/Main/LlamaIndex/lib/python3.12/site-packages/llama_index/embeddings/huggingface_optimum_intel/base.py:56, in IntelEmbedding.__init__(self, folder_name, pooling, max_length, normalize, query_instruction, text_instruction, model, tokenizer, embed_batch_size, callback_manager, device)
49 except ImportError:
50 raise ImportError(
51 "Optimum-Intel requires the following dependencies; please install with "
52 "`pip install optimum[exporters] "
53 "optimum-intel neural-compressor intel_extension_for_pytorch`"
54 )
---> 56 model = model or IPEXModel.from_pretrained(folder_name)
57 tokenizer = tokenizer or AutoTokenizer.from_pretrained(folder_name)
58 device = device or infer_torch_device()
File /media/seth/Main/LlamaIndex/lib/python3.12/site-packages/optimum/intel/ipex/modeling_base.py:182, in IPEXModel.from_pretrained(cls, model_id, **kwargs)
165 @classmethod
166 def from_pretrained(
167 cls,
168 model_id: Union[str, Path],
169 **kwargs,
170 ):
171 """
172 Loads a model and its configuration file from a directory or the HF Hub.
173
(...) 179 - The path to a directory containing the model weights.
180 """
--> 182 model = cls.auto_model_class.from_pretrained(model_id, **kwargs)
183 if getattr(model.config, "torchscript", False):
184 raise ValueError("IPEXModel is no longer support torchscript models.")
File /media/seth/Main/LlamaIndex/lib/python3.12/site-packages/transformers/models/auto/auto_factory.py:571, in _BaseAutoModelClass.from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
569 if model_class.config_class == config.sub_configs.get("text_config", None):
570 config = config.get_text_config()
--> 571 return model_class.from_pretrained(
572 pretrained_model_name_or_path, *model_args, config=config, **hub_kwargs, **kwargs
573 )
574 raise ValueError(
575 f"Unrecognized configuration class {config.__class__} for this kind of AutoModel: {cls.__name__}.\n"
576 f"Model type should be one of {', '.join(c.__name__ for c in cls._model_mapping.keys())}."
577 )
File /media/seth/Main/LlamaIndex/lib/python3.12/site-packages/transformers/modeling_utils.py:279, in restore_default_torch_dtype.<locals>._wrapper(*args, **kwargs)
277 old_dtype = torch.get_default_dtype()
278 try:
--> 279 return func(*args, **kwargs)
280 finally:
281 torch.set_default_dtype(old_dtype)
File /media/seth/Main/LlamaIndex/lib/python3.12/site-packages/transformers/modeling_utils.py:4399, in PreTrainedModel.from_pretrained(cls, pretrained_model_name_or_path, config, cache_dir, ignore_mismatched_sizes, force_download, local_files_only, token, revision, use_safetensors, weights_only, *model_args, **kwargs)
4389 if dtype_orig is not None:
4390 torch.set_default_dtype(dtype_orig)
4392 (
4393 model,
4394 missing_keys,
4395 unexpected_keys,
4396 mismatched_keys,
4397 offload_index,
4398 error_msgs,
-> 4399 ) = cls._load_pretrained_model(
4400 model,
4401 state_dict,
4402 checkpoint_files,
4403 pretrained_model_name_or_path,
4404 ignore_mismatched_sizes=ignore_mismatched_sizes,
4405 sharded_metadata=sharded_metadata,
4406 device_map=device_map,
4407 disk_offload_folder=offload_folder,
4408 offload_state_dict=offload_state_dict,
4409 dtype=torch_dtype,
4410 hf_quantizer=hf_quantizer,
4411 keep_in_fp32_regex=keep_in_fp32_regex,
4412 device_mesh=device_mesh,
4413 key_mapping=key_mapping,
4414 weights_only=weights_only,
4415 )
4417 # make sure token embedding weights are still tied if needed
4418 model.tie_weights()
File /media/seth/Main/LlamaIndex/lib/python3.12/site-packages/transformers/modeling_utils.py:4638, in PreTrainedModel._load_pretrained_model(cls, model, state_dict, checkpoint_files, pretrained_model_name_or_path, ignore_mismatched_sizes, sharded_metadata, device_map, disk_offload_folder, offload_state_dict, dtype, hf_quantizer, keep_in_fp32_regex, device_mesh, key_mapping, weights_only)
4635 original_checkpoint_keys = list(state_dict.keys())
4636 else:
4637 original_checkpoint_keys = list(
-> 4638 load_state_dict(checkpoint_files[0], map_location="meta", weights_only=weights_only).keys()
4639 )
4641 # Check if we are in a special state, i.e. loading from a state dict coming from a different architecture
4642 prefix = model.base_model_prefix
File /media/seth/Main/LlamaIndex/lib/python3.12/site-packages/transformers/modeling_utils.py:577, in load_state_dict(checkpoint_file, is_quantized, map_location, weights_only)
572 raise ValueError(
573 f"Unable to locate the file {checkpoint_file} which is necessary to load this pretrained "
574 "model. Make sure you have saved the model properly."
575 ) from e
576 except (UnicodeDecodeError, ValueError):
--> 577 raise OSError(
578 f"Unable to load weights from pytorch checkpoint file for '{checkpoint_file}' "
579 f"at '{checkpoint_file}'. "
580 "If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True."
581 )
OSError: Unable to load weights from pytorch checkpoint file for '/media/seth/Second/huggingface/cache/hub/models--Intel--bge-small-en-v1.5-rag-int8-static/snapshots/48f830c1bbf12857661626982f2d4f43601b48a5/pytorch_model.bin' at '/media/seth/Second/huggingface/cache/hub/models--Intel--bge-small-en-v1.5-rag-int8-static/snapshots/48f830c1bbf12857661626982f2d4f43601b48a5/pytorch_model.bin'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
Source: run-llama/llama_index