{"course":{"slug":"hugging-face","title":"Hugging Face, End to End","url":"https://addaly.com/learn/hugging-face","level":"intermediate","track":"create"},"lesson":{"slug":"inside-a-repository","title":"What the files in a model repository are for","url":"https://addaly.com/learn/hugging-face/inside-a-repository","position":5,"of":75,"minutes":10,"answer":"Inspect the configuration, tokenizer, weight files and generation settings before downloading. Check the model card and the exact revision for assumptions about context and loading.","keyIdea":"Inspect the configuration, tokenizer, weight files and generation settings before downloading. Check the model card and the exact revision for assumptions about context and loading."},"body":{"format":"markdown","text":"## Open Files and versions before you open anything else\n\nOpen the file listing and look for the model configuration, tokenizer files, weights and generation settings. Some repositories omit or combine them. Reading these files in a browser can tell you what to check before installing software or downloading weights.\n\nHere is what you are looking at.\n\n## `config.json`: the model's shape\n\nThis is the architecture, in JSON. A trimmed example:\n\n> Figure: Five files, and the question each one answers. Layers, top to bottom: config.json (Architecture, positional setting, dtype hint and vocabulary size); tokenizer_config.json (The chat template, the padding side, the special tokens); model.safetensors.index.json (Size estimate for the indexed tensor data; check other files separately); generation_config.json (The temperature and do_sample you did not choose); adapter_config.json (Adapter settings and the required base model). Browse these metadata files when present. They give clues to the architecture, tokenizer, weights, defaults and whether the repository holds an adapter. No weight download is needed for this inspection.\n\n```json\n{\n  \"architectures\": [\"LlamaForCausalLM\"],\n  \"hidden_size\": 4096,\n  \"num_hidden_layers\": 32,\n  \"num_attention_heads\": 32,\n  \"max_position_embeddings\": 131072,\n  \"vocab_size\": 128256,\n  \"torch_dtype\": \"bfloat16\",\n  \"rope_theta\": 500000.0\n}\n```\n\nFour fields earn your attention:\n\n- **`architectures`** lists the architecture name reported by the repository. An Auto class also uses the model configuration to choose a compatible implementation. `LlamaForCausalLM` tells you this is a text generator; `BertForSequenceClassification` tells you it is a classifier with a fixed number of labels. If your library cannot load the model, compare its supported classes and version with the model card. Upgrading may help for a recently added architecture; a custom architecture is a different case.\n- **`max_position_embeddings`** reports a positional limit or setting for architectures that use it. Verify the documented usable context for the model, including tokenizer, scaling and runtime limits, before relying on this field alone.\n- **`torch_dtype`** may appear as `dtype` or `torch_dtype` depending on the library and model revision. Treat it as a hint. Check the actual loaded dtype and memory use; the loader, requested dtype and quantization settings can change what is held in memory.\n- **`vocab_size`** helps describe embedding capacity. Every token ID emitted by the tokenizer must be covered by the model’s embedding table; the table may have extra rows for padding. When adding tokens, check whether you need to resize the embeddings.\n\nYou can read it without a browser:\n\n```bash\nrevision=169d4a4341b33bc18d8881c4b69c2e104e1cc0af\nurl=https://huggingface.co/openai/whisper-tiny\ncurl -fLsS \"$url/resolve/$revision/config.json\" | head -40\n```\n\n## The tokenizer files: three of them, doing different jobs\n\n- **`tokenizer.json`** is the fast tokenizer: the full vocabulary and merge rules in one file, loaded by the Rust implementation. Its presence is why `AutoTokenizer` is fast.\n- **`tokenizer_config.json`** holds the settings around it: padding side, maximum length, the special token names, and sometimes the **`chat_template`**. The Jinja template may also be in a separate `chat_template.jinja` file. It formats user and assistant turns in the representation the model expects.\n- **`special_tokens_map.json`** maps roles like `bos_token`, `eos_token`, `pad_token` onto actual strings.\n\nOlder repositories carry `vocab.txt`, `merges.txt` or `spiece.model` instead. The supported loader can sometimes convert these to a fast tokenizer or use a library-specific implementation. Check the model instructions.\n\n## The weights, and why there are several files\n\n`model.safetensors` is the whole thing when the model is small. Above a few gigabytes it is sharded:\n\n```\nmodel-00001-of-00004.safetensors\nmodel-00002-of-00004.safetensors\nmodel-00003-of-00004.safetensors\nmodel-00004-of-00004.safetensors\nmodel.safetensors.index.json\n```\n\nThe index is a map from every parameter name to the shard that holds it, and often includes a `total_size` for the tensor data. That is a useful estimate for one set of weights. Include shard headers, other required files and cache overhead in the disk budget.\n\nMany repositories carry **both** `.safetensors` and `.bin` copies of the same weights. Downloading both formats uses extra disk and bandwidth. Choose the needed files for your supported loader. The next lesson explains why you want the safetensors ones specifically.\n\n## `generation_config.json`: the defaults you did not choose\n\nFor generative models this file sets `temperature`, `top_p`, `do_sample`, `max_new_tokens`, `eos_token_id` and friends. When people compare two models and one seems wilder, the cause is frequently that their published generation defaults differ, not that the model does. If you are benchmarking, set these explicitly rather than inheriting them.\n\n## `.gitattributes`, and files with no purpose\n\n`.gitattributes` tells git which patterns go to large-file storage. Inspect its rules if you are maintaining the repository. Do not change tracking as part of a download exercise. Beyond that you will find `README.md`, which is the model card, plus example images, an `onnx/` folder, and sometimes a `runs/` directory full of training logs somebody forgot to exclude. That last one is occasionally the most informative thing in the repository.\n\n## A repository can also be an adapter\n\nIf you see `adapter_config.json` and an `adapter_model.safetensors` of a few dozen megabytes, this is not a model. It is a LoRA adapter: a small set of extra matrices that must be applied on top of the base model named inside `adapter_config.json`. Downloading it alone and wondering why nothing loads is a rite of passage.\n\n## Do this now\n\nOpen any chat model's `tokenizer_config.json` and find `chat_template` there or look for `chat_template.jinja`. Read the template. You are looking at the exact strings the model was trained to expect around a user turn; and once you have seen them, the whole category of \"the model ignores my system prompt\" bugs becomes legible."},"check":{"question":"A repository lists ten files totalling 46 GB, but its `model.safetensors.index.json` reports a `total_size` of about 16 GB. What is the most likely explanation?","options":[{"text":"The index records the size after compression, and the listing shows the uncompressed files that will land on disk.","correct":false,"tempting":"Assumes safetensors files are compressed; they store raw tensor bytes with a JSON header and no compression."},{"text":"It may contain duplicate weight formats or other files; the index only describes its safetensors shards. Check the listing to confirm.","correct":true},{"text":"The index is stale because it was written before the final training shards were uploaded.","correct":false,"tempting":"Treats a routine duplicate-format layout as corruption, when a stale index would cause load failures rather than a size discrepancy."},{"text":"The extra 30 GB is the optimiser state, which the index deliberately excludes because it is not needed for inference.","correct":false,"tempting":"Plausible-sounding but rare in published inference repositories, and optimiser state would be named as such rather than as model weights."}]},"prev":{"slug":"reading-a-model-name","title":"A model's name is a specification, if you can read it","url":"https://addaly.com/learn/hugging-face/reading-a-model-name"},"next":{"slug":"safetensors-and-pickle","title":"Loading a model can run someone else's code","url":"https://addaly.com/learn/hugging-face/safetensors-and-pickle"},"authorship":"Founder and series editor: Dr Mustafa Mun. Written by AI models to a written standard. Source and assessment review continues. Academic review invited.","review":{"status":"Draft, open for academic review"},"cite":"Addaly (2026) 'What the files in a model repository are for', in Hugging Face, End to End. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/hugging-face/inside-a-repository (Accessed: 29 November 2026).","licence":{"name":"CC BY-NC-SA 4.0","url":"https://creativecommons.org/licenses/by-nc-sa/4.0/"},"reader":{"schema":1,"title":"What the files in a model repository are for","courseTitle":"Hugging Face, End to End","module":{"index":1,"slug":"the-hub-as-a-repository-host","title":"The Hub, read properly"},"answer":null,"keyIdea":"Inspect the configuration, tokenizer, weight files and generation settings before downloading. Check the model card and the exact revision for assumptions about context and loading.","hero":{"kind":"figure","figure":{"t":"figure","label":"Figure","figure":{"type":"stack","title":"Five files, and the question each one answers","caption":"Browse these metadata files when present. They give clues to the architecture, tokenizer, weights, defaults and whether the repository holds an adapter. No weight download is needed for this inspection.","layers":[{"label":"config.json","detail":"Architecture, positional setting, dtype hint and vocabulary size"},{"label":"tokenizer_config.json","detail":"The chat template, the padding side, the special tokens"},{"label":"model.safetensors.index.json","detail":"Size estimate for the indexed tensor data; check other files separately"},{"label":"generation_config.json","detail":"The temperature and do_sample you did not choose"},{"label":"adapter_config.json","detail":"Adapter settings and the required base model"}]},"alt":"Figure: Five files, and the question each one answers. Layers, top to bottom: config.json (Architecture, positional setting, dtype hint and vocabulary size); tokenizer_config.json (The chat template, the padding side, the special tokens); model.safetensors.index.json (Size estimate for the indexed tensor data; check other files separately); generation_config.json (The temperature and do_sample you did not choose); adapter_config.json (Adapter settings and the required base model). Browse these metadata files when present. They give clues to the architecture, tokenizer, weights, defaults and whether the repository holds an adapter. No weight download is needed for this inspection."}},"blocks":[{"t":"h2","id":"open-files-and-versions-before-you-open-anything-else","runs":[{"text":"Open Files and versions before you open anything else"}]},{"t":"p","runs":[{"text":"Open the file listing and look for the model configuration, tokenizer files, weights and generation settings. Some repositories omit or combine them. Reading these files in a browser can tell you what to check before installing software or downloading weights."}]},{"t":"p","runs":[{"text":"Here is what you are looking at."}]},{"t":"h2","id":"config-json-the-model-s-shape","runs":[{"text":"config.json","code":true},{"text":": the model’s shape"}]},{"t":"p","runs":[{"text":"This is the architecture, in JSON. A trimmed example:"}]},{"t":"code","lang":"json","label":"JSON","text":"{\n  \"architectures\": [\"LlamaForCausalLM\"],\n  \"hidden_size\": 4096,\n  \"num_hidden_layers\": 32,\n  \"num_attention_heads\": 32,\n  \"max_position_embeddings\": 131072,\n  \"vocab_size\": 128256,\n  \"torch_dtype\": \"bfloat16\",\n  \"rope_theta\": 500000.0\n}"},{"t":"p","runs":[{"text":"Four fields earn your attention:"}]},{"t":"ul","items":[[{"text":"architectures","b":true,"code":true},{"text":" lists the architecture name reported by the repository. An Auto class also uses the model configuration to choose a compatible implementation. "},{"text":"LlamaForCausalLM","code":true},{"text":" tells you this is a text generator; "},{"text":"BertForSequenceClassification","code":true},{"text":" tells you it is a classifier with a fixed number of labels. If your library cannot load the model, compare its supported classes and version with the model card. Upgrading may help for a recently added architecture; a custom architecture is a different case."}],[{"text":"max_position_embeddings","b":true,"code":true},{"text":" reports a positional limit or setting for architectures that use it. Verify the documented usable context for the model, including tokenizer, scaling and runtime limits, before relying on this field alone."}],[{"text":"torch_dtype","b":true,"code":true},{"text":" may appear as "},{"text":"dtype","code":true},{"text":" or "},{"text":"torch_dtype","code":true},{"text":" depending on the library and model revision. Treat it as a hint. Check the actual loaded dtype and memory use; the loader, requested dtype and quantization settings can change what is held in memory."}],[{"text":"vocab_size","b":true,"code":true},{"text":" helps describe embedding capacity. Every token ID emitted by the tokenizer must be covered by the model’s embedding table; the table may have extra rows for padding. When adding tokens, check whether you need to resize the embeddings."}]]},{"t":"p","runs":[{"text":"You can read it without a browser:"}]},{"t":"code","lang":"bash","label":"Bash","text":"revision=169d4a4341b33bc18d8881c4b69c2e104e1cc0af\nurl=https://huggingface.co/openai/whisper-tiny\ncurl -fLsS \"$url/resolve/$revision/config.json\" | head -40"},{"t":"h2","id":"the-tokenizer-files-three-of-them-doing-different-jobs","runs":[{"text":"The tokenizer files: three of them, doing different jobs"}]},{"t":"ul","items":[[{"text":"tokenizer.json","b":true,"code":true},{"text":" is the fast tokenizer: the full vocabulary and merge rules in one file, loaded by the Rust implementation. Its presence is why "},{"text":"AutoTokenizer","code":true},{"text":" is fast."}],[{"text":"tokenizer_config.json","b":true,"code":true},{"text":" holds the settings around it: padding side, maximum length, the special token names, and sometimes the "},{"text":"chat_template","b":true,"code":true},{"text":". The Jinja template may also be in a separate "},{"text":"chat_template.jinja","code":true},{"text":" file. It formats user and assistant turns in the representation the model expects."}],[{"text":"special_tokens_map.json","b":true,"code":true},{"text":" maps roles like "},{"text":"bos_token","code":true},{"text":", "},{"text":"eos_token","code":true},{"text":", "},{"text":"pad_token","code":true},{"text":" onto actual strings."}]]},{"t":"p","runs":[{"text":"Older repositories carry "},{"text":"vocab.txt","code":true},{"text":", "},{"text":"merges.txt","code":true},{"text":" or "},{"text":"spiece.model","code":true},{"text":" instead. The supported loader can sometimes convert these to a fast tokenizer or use a library-specific implementation. Check the model instructions."}]},{"t":"h2","id":"the-weights-and-why-there-are-several-files","runs":[{"text":"The weights, and why there are several files"}]},{"t":"p","runs":[{"text":"model.safetensors","code":true},{"text":" is the whole thing when the model is small. Above a few gigabytes it is sharded:"}]},{"t":"code","lang":"","label":"Text","text":"model-00001-of-00004.safetensors\nmodel-00002-of-00004.safetensors\nmodel-00003-of-00004.safetensors\nmodel-00004-of-00004.safetensors\nmodel.safetensors.index.json"},{"t":"p","runs":[{"text":"The index is a map from every parameter name to the shard that holds it, and often includes a "},{"text":"total_size","code":true},{"text":" for the tensor data. That is a useful estimate for one set of weights. Include shard headers, other required files and cache overhead in the disk budget."}]},{"t":"p","runs":[{"text":"Many repositories carry "},{"text":"both","b":true},{"text":" "},{"text":".safetensors","code":true},{"text":" and "},{"text":".bin","code":true},{"text":" copies of the same weights. Downloading both formats uses extra disk and bandwidth. Choose the needed files for your supported loader. The next lesson explains why you want the safetensors ones specifically."}]},{"t":"h2","id":"generationconfig-json-the-defaults-you-did-not-choose","runs":[{"text":"generation_config.json","code":true},{"text":": the defaults you did not choose"}]},{"t":"p","runs":[{"text":"For generative models this file sets "},{"text":"temperature","code":true},{"text":", "},{"text":"top_p","code":true},{"text":", "},{"text":"do_sample","code":true},{"text":", "},{"text":"max_new_tokens","code":true},{"text":", "},{"text":"eos_token_id","code":true},{"text":" and friends. When people compare two models and one seems wilder, the cause is frequently that their published generation defaults differ, not that the model does. If you are benchmarking, set these explicitly rather than inheriting them."}]},{"t":"h2","id":"gitattributes-and-files-with-no-purpose","runs":[{"text":".gitattributes","code":true},{"text":", and files with no purpose"}]},{"t":"p","runs":[{"text":".gitattributes","code":true},{"text":" tells git which patterns go to large-file storage. Inspect its rules if you are maintaining the repository. Do not change tracking as part of a download exercise. Beyond that you will find "},{"text":"README.md","code":true},{"text":", which is the model card, plus example images, an "},{"text":"onnx/","code":true},{"text":" folder, and sometimes a "},{"text":"runs/","code":true},{"text":" directory full of training logs somebody forgot to exclude. That last one is occasionally the most informative thing in the repository."}]},{"t":"h2","id":"a-repository-can-also-be-an-adapter","runs":[{"text":"A repository can also be an adapter"}]},{"t":"p","runs":[{"text":"If you see "},{"text":"adapter_config.json","code":true},{"text":" and an "},{"text":"adapter_model.safetensors","code":true},{"text":" of a few dozen megabytes, this is not a model. It is a LoRA adapter: a small set of extra matrices that must be applied on top of the base model named inside "},{"text":"adapter_config.json","code":true},{"text":". Downloading it alone and wondering why nothing loads is a rite of passage."}]},{"t":"h2","id":"do-this-now","runs":[{"text":"Do this now"}],"role":"try"},{"t":"p","runs":[{"text":"Open any chat model’s "},{"text":"tokenizer_config.json","code":true},{"text":" and find "},{"text":"chat_template","code":true},{"text":" there or look for "},{"text":"chat_template.jinja","code":true},{"text":". Read the template. You are looking at the exact strings the model was trained to expect around a user turn; and once you have seen them, the whole category of “the model ignores my system prompt” bugs becomes legible."}]}],"check":{"question":[{"text":"A repository lists ten files totalling 46 GB, but its "},{"text":"model.safetensors.index.json","code":true},{"text":" reports a "},{"text":"total_size","code":true},{"text":" of about 16 GB. What is the most likely explanation?"}],"options":[{"text":[{"text":"The index records the size after compression, and the listing shows the uncompressed files that will land on disk."}],"correct":false,"tempting":[{"text":"Assumes safetensors files are compressed; they store raw tensor bytes with a JSON header and no compression."}]},{"text":[{"text":"It may contain duplicate weight formats or other files; the index only describes its safetensors shards. Check the listing to confirm."}],"correct":true,"tempting":null},{"text":[{"text":"The index is stale because it was written before the final training shards were uploaded."}],"correct":false,"tempting":[{"text":"Treats a routine duplicate-format layout as corruption, when a stale index would cause load failures rather than a size discrepancy."}]},{"text":[{"text":"The extra 30 GB is the optimiser state, which the index deliberately excludes because it is not needed for inference."}],"correct":false,"tempting":[{"text":"Plausible-sounding but rare in published inference repositories, and optimiser state would be named as such rather than as model weights."}]}],"order":[3,0,2,1],"why":null},"prev":{"slug":"reading-a-model-name","title":"A model’s name is a specification, if you can read it","minutes":8},"next":{"slug":"safetensors-and-pickle","title":"Loading a model can run someone else’s code","minutes":9}}}