kylesayrs's picture
Upload folder using huggingface_hub
425e05c verified
|
Raw History Blame Contribute Delete
3.07 kB
---
license: mit
base_model:
- meta-llama/Llama-3.2-1B-Instruct
library_name: transformers
---
# Llama-3.2-0.5B-Instruct-small
This is a small version of [meta-llama/Llama-3.2-1B-Instruct](https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct) created for testing and development. It preserves the full architecture characteristics of the base model (GQA attention, SwiGLU MLPs, llama3 rope scaling, tied embeddings, identical hyperparameters) with fewer layers.
## Model Details
- **Base Model**: meta-llama/Llama-3.2-1B-Instruct
- **Architecture**: LlamaForCausalLM (model_type `llama`)
- **Total Parameters**: 0.51B (505,956,352)
- **Activated Parameters**: 0.51B (dense model)
## Configuration Changes
The following parameters were reduced from the original model:
| Parameter | Base | Small |
|---|---|---|
| `num_hidden_layers` | 16 | 4 |
All other hyperparameters are identical to the base: hidden_size 2048, intermediate_size 8192, num_attention_heads 32, num_key_value_heads 8, head_dim 64, vocab_size 128256, `tie_word_embeddings` true, rope/llama3 scaling parameters, max_position_embeddings 131072, etc. This is a dense model with a single layer type, so no layer-type or expert changes apply.
## Checkpoint Structure
Single `model.safetensors` file with 38 bf16 tensors (the base is also a single file with 146 tensors). Tensor naming and per-layer tensor shapes match the base checkpoint exactly modulo layer count (verified against the base checkpoint's safetensors header; layer-0/embedding/norm shapes identical). As in the base, `lm_head.weight` is absent from the checkpoint because embeddings are tied.
## Usage
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("inference-optimization/Llama-3.2-0.5B-Instruct-small", device_map="auto")
tokenizer = AutoTokenizer.from_pretrained("inference-optimization/Llama-3.2-0.5B-Instruct-small")
input_ids = tokenizer("According to all known laws", return_tensors="pt").input_ids.to(model.device)
output = model.generate(input_ids, max_new_tokens=20)
print(tokenizer.decode(output[0]))
```
## Creation Process
This model was created using the llm-compressor `create-tiny-model` skill.
Built from the base `AutoConfig` with only the allowed change above (layer count), initialized with `init_weights()` (bf16), and fine-tuned on a toy copypasta dataset until perplexity ~1.0 (target 3.0).
## Validation
```
$ python validate_tiny_model.py Llama-3.2-0.5B-Instruct-small-ft
Success: 1.0484492778778076 <= 10.0
Generating sample text:
According to all known laws of aviation, there is no way a bee should be able to fly
```
## Notes
- Dense model: no MoE experts, no per-layer type lists; the only allowed change needed to shrink it is the layer count.
- `tie_word_embeddings` kept true (as in base); the checkpoint therefore contains no separate `lm_head` tensor, matching the base layout.
- The base model repository is gated; this small version is published under the `inference-optimization` org for testing convenience.