get_sequence_length() — pytorch Function Reference
Architecture documentation for the get_sequence_length() function in huggingface.py from the pytorch codebase.
Entity Profile
Dependency Diagram
graph TD 19c1813c_4f26_3218_718c_6182fe70675d["get_sequence_length()"] 179ecd7f_27e8_48db_95f4_85c2cda45c18["generate_inputs_for_model()"] 179ecd7f_27e8_48db_95f4_85c2cda45c18 -->|calls| 19c1813c_4f26_3218_718c_6182fe70675d style 19c1813c_4f26_3218_718c_6182fe70675d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
benchmarks/dynamo/huggingface.py lines 149–187
def get_sequence_length(model_cls, model_name):
if model_name.startswith(("Blenderbot",)):
seq_length = 128
elif model_name.startswith(("GPT2", "Bart", "T5", "PLBart", "MBart")):
seq_length = 1024
elif model_name in ("AllenaiLongformerBase", "BigBird"):
seq_length = 1024
elif model_name.startswith("OPT"):
seq_length = 2048
elif "Reformer" in model_name:
seq_length = 4096
elif model_name.startswith(
(
"Albert",
"Deberta",
"Layout",
"Electra",
"XLNet",
"MegatronBert",
"Bert",
"Roberta",
)
) or model_name in ("DistillGPT2", "GoogleFnet", "YituTechConvBert"):
seq_length = 512
elif model_name in ("TrOCRForCausalLM"):
seq_length = 256
elif model_name.startswith("MobileBert"):
seq_length = 128
elif model_name.startswith("Wav2Vec2"):
# If too short, will fail with something like
# ValueError: `mask_length` has to be smaller than `sequence_length`,
# but got `mask_length`: 10 and `sequence_length`: 9`
seq_length = 10000 # NB: a more realistic size is 155136
else:
log.info(
f"Sequence Length not defined for {model_name}. Choosing 128 arbitrarily" # noqa: G004
)
seq_length = 128
return seq_length
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does get_sequence_length() do?
get_sequence_length() is a function in the pytorch codebase.
What calls get_sequence_length()?
get_sequence_length() is called by 1 function(s): generate_inputs_for_model.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free