-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: add processor_kwargs YAML field forwarded to from_pretrained #3612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
winglian
merged 4 commits into
axolotl-ai-cloud:main
from
thad0ctor:feat/processor-kwargs
Apr 23, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
576ab3a
feat: add processor_kwargs YAML field forwarded to from_pretrained
thad0ctor b8eaeb9
feat: enforce reserved-key rejection in processor_kwargs schema
thad0ctor 964a471
chore: lint
winglian 96d8536
reject processor_kwargs with tokenizer_use_mistral_common
thad0ctor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,12 @@ class ModelInputConfig(BaseModel): | |
| processor_type: str | None = Field( | ||
| default=None, json_schema_extra={"description": "transformers processor class"} | ||
| ) | ||
| processor_kwargs: dict[str, Any] | None = Field( | ||
| default=None, | ||
| json_schema_extra={ | ||
| "description": "kwargs forwarded to the processor's from_pretrained(), overriding processor config (e.g. image_seq_length, min_pixels, etc.)." | ||
| }, | ||
| ) | ||
|
thad0ctor marked this conversation as resolved.
|
||
| tokenizer_save_jinja_files: bool | None = Field( | ||
| default=True, # match the default behavior from transformers | ||
| json_schema_extra={ | ||
|
|
@@ -107,6 +113,22 @@ def hint_trust_remote_code(cls, trust_remote_code): | |
| ) | ||
| return trust_remote_code | ||
|
|
||
| @field_validator("processor_kwargs") | ||
| @classmethod | ||
| def reject_reserved_processor_kwargs(cls, processor_kwargs): | ||
| if not processor_kwargs: | ||
| return processor_kwargs | ||
| reserved = {"revision", "trust_remote_code"} | ||
| conflicts = reserved.intersection(processor_kwargs) | ||
| if conflicts: | ||
| raise ValueError( | ||
| "Do not set reserved keys " | ||
| f"{sorted(conflicts)} inside `processor_kwargs`; " | ||
| "use the top-level `revision_of_model` / `trust_remote_code` " | ||
| "config keys instead." | ||
| ) | ||
| return processor_kwargs | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should also add a check that this is not compatible with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added via 96d8536 |
||
|
|
||
|
|
||
| class ModelOutputConfig(BaseModel): | ||
| """model save configuration subset""" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.