TRF009
modeling_<name>.py should avoid importing implementation code from another model package.
| Default | Enabled |
| Scope | All models |
| Source | mlinter/trf009.py |
| Show in terminal | mlinter --rule TRF009 |
What it does
Checks modeling files for cross-model imports such as transformers.models.other_model.* or from ..other_model.* imports.
Why is this bad?
Cross-model implementation imports violate the single-file policy and make model behavior harder to inspect and maintain.
Example
-from transformers.models.llama.modeling_llama import LlamaAttention
+# Keep implementation local to this file.
+# If reusing code, copy it with a # Copied from comment.
Suppressing this rule
Add a # trf-ignore: TRF009 comment on the flagged line or the line directly above it. See Suppressing rules for whole-file directives and when a suppression is the wrong answer.
Allowlisted models
4 models are exempt from TRF009 in mlinter/rules.toml, because they predate the convention and cannot be changed without breaking backward compatibility.
Show the 4 allowlisted models
dprmaskformersam3_videovision_text_dual_encoder
