GitHub Actions commited on
Commit ·
da3ca2c
1
Parent(s): fb17651
fix(llm): add trust_remote_code=True to HF Transformers backend
Browse filesMiniCPM3-4B and other OpenBMB models contain custom modeling code and require
trust_remote_code=True when loaded via transformers.from_pretrained().
The pipeline() API passes kwargs via model_kwargs and tokenizer_kwargs, so
add trust_remote_code=True to both to ensure the model and tokenizer load
correctly without 'custom code must be executed' errors.
hearthnet/services/llm/backends/hf_local.py
CHANGED
|
@@ -126,7 +126,9 @@ class HfLocalBackend:
|
|
| 126 |
model=self._model_name,
|
| 127 |
device=device,
|
| 128 |
# Disable auto device_map to keep explicit CPU/GPU control
|
| 129 |
-
|
|
|
|
|
|
|
| 130 |
)
|
| 131 |
|
| 132 |
def _build_prompt(self, messages: list[dict]) -> str:
|
|
|
|
| 126 |
model=self._model_name,
|
| 127 |
device=device,
|
| 128 |
# Disable auto device_map to keep explicit CPU/GPU control
|
| 129 |
+
# Add trust_remote_code=True for models with custom modeling code (e.g. MiniCPM3-4B)
|
| 130 |
+
model_kwargs={"low_cpu_mem_usage": True, "trust_remote_code": True},
|
| 131 |
+
tokenizer_kwargs={"trust_remote_code": True},
|
| 132 |
)
|
| 133 |
|
| 134 |
def _build_prompt(self, messages: list[dict]) -> str:
|