Skip to content

[docs] modular transformers#45327

Draft
stevhliu wants to merge 1 commit intohuggingface:mainfrom
stevhliu:model-addition
Draft

[docs] modular transformers#45327
stevhliu wants to merge 1 commit intohuggingface:mainfrom
stevhliu:model-addition

Conversation

@stevhliu
Copy link
Copy Markdown
Member

@stevhliu stevhliu commented Apr 8, 2026

refactors the how to add a model with modular transformers doc:

  • structure:

    • flipped the order so you learn how to write the modular file first before generating it
    • remove the motivator examples with BERT/RoBERTa
    • merge the two super() sections with context on when to use each
    • replace full code blocks with diffs so its easier to see whats actually changing
  • missing features:

    • @strict, __post_init__, __all__, AttributeError(), base_model_tp_plan, base_model_pp_plan
  • updates:

    • update the### Config section with new patterns like __post_init__, AttributeError() and class-level type annotations for new attributes
    • super_kwargs example references GemmaForCausalLM now
    • adds the modular-detector-v2 Space

let me know if there are other commonly missed modular practices!

todo:

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Comment on lines +55 to +59
-@auto_docstring(checkpoint="allenai/OLMo-7B-hf")
+@auto_docstring(checkpoint="allenai/Olmo2-7B-1124-hf")
+@strict
-class OlmoConfig(PreTrainedConfig):
+class Olmo2Config(OlmoConfig):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, i was pointed out just recently that docs aren;t up-to-date with config changes 😄

@casinca
Copy link
Copy Markdown
Contributor

casinca commented Apr 9, 2026

Hi @stevhliu , if I may, would it be possible to add somewhere what Matt said in #45141 (comment).
I believe this would help others that might end up in the same situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants