Hugging Face Transformers 5.20
Last reviewed Oct 26, 2026
Prompt Details
Prompt Composition
2prompts
- Python 3155 lines · 3.8K tokens
- Hugging Face Transformers 5.2066 lines · 2.6K tokens
Total221 lines · 6.4K tokens
CWE Coverage
- 20
- 23
- 36
- 59
- 73
- 78
- 79
- 89
- 95
- 117
- 201
- 208
- 209
- 214
- 250
- 295
- 306
- 319
- 328
- 338
- 347
- 367
- 379
- 409
- 416
- 426
- 427
- 470
- 488
- 502
- 522
- 532
- 611
- 674
- 732
- 770
- 772
- 776
- 807
- 829
- 862
- 916
- 918
- 942
- 1104
- 1333
- 1395
- 1426
- 1427
Prompt Preview
Apply to applications that load, train, or serve models with Transformers 5.20. Treat model repositories, local checkpoints, processors, adapters, templates, media, and generated text as separate trust boundaries. The Python prompt covers language-wide controls.
Models and checkpoints
- Select model repository IDs and immutable commit revisions in trusted configuration, not from user input. Review the model's configuration, weights, tokenizer or processor, generation configuration, adapters, and referenced repositories as one deployment artifact.
- Pass the approved
revisiontofrom_pretrained()andpipeline()loading paths. If custom code resides in a different repository, independently approve and fixcode_revision; a weight revision alone does not freeze that code. - Use
local_files_only=TrueorHF_HUB_OFFLINE=1for an offline deployment after staging and verifying the exact approved artifacts. A cache hit with online loading can still contact the Hub. - Require
use_safetensors=Truewhenfrom_pretrained()loads external PyTorch-format weights; review GGUF and other formats separately. The default prefers safetensors but can fall back to PyTorch pickle files;weights_only=Trueand Hub scanning do not make arbitrary third-party checkpoint content trustworthy. - Before calling
from_pretrained()on a local model directory, validate every filename inmodel.safetensors.index.jsonorpytorch_model.bin.index.jsonweight_map: require a simple expected shard name whose resolved path stays inside the approved model directory; reject absolute paths,