Skip to content

Commit b3bbd02

Browse files
committed
fix: Use model name instead of local path for AutoProcessor.from_pretrained
Fixes AttributeError when do_formula_enrichment=True. When a local Path is passed to AutoProcessor.from_pretrained(), transformers loads the config as a dict but then tries to access .model_type as an attribute. Using the model name ('docling-project/CodeFormulaV2') allows transformers to properly load the config as an object, while still using the cached model automatically. Fixes #2681
1 parent 1344362 commit b3bbd02

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

docling/models/code_formula_model.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,11 @@ def __init__(
105105
else:
106106
artifacts_path = artifacts_path / self._model_repo_folder
107107

108+
# Use model name instead of local path to avoid transformers bug where
109+
# config is loaded as dict but accessed as object attribute
110+
# Transformers will automatically use the cached model from artifacts_path
108111
self._processor = AutoProcessor.from_pretrained(
109-
artifacts_path,
112+
"docling-project/CodeFormulaV2",
110113
)
111114
self._model_max_length = self._processor.tokenizer.model_max_length
112115
self._model = AutoModelForImageTextToText.from_pretrained(

0 commit comments

Comments
 (0)