Add atomllama-33K-5x5-DigitMesh-sparse-q8
Browse files- README.md +103 -3
- config.json +65 -0
- generation_config.json +10 -0
- model.safetensors +3 -0
- recipe.yaml +6 -0
- special_tokens_map.json +23 -0
- tokenizer.json +51 -0
- tokenizer_config.json +27 -0
README.md
CHANGED
|
@@ -1,3 +1,103 @@
|
|
| 1 |
-
---
|
| 2 |
-
|
| 3 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
tags:
|
| 5 |
+
- llama
|
| 6 |
+
- causal-lm
|
| 7 |
+
- digit-recognition
|
| 8 |
+
- sparse-model
|
| 9 |
+
- quantized-model
|
| 10 |
+
- int8-quantization
|
| 11 |
+
- qat
|
| 12 |
+
- model-compression
|
| 13 |
+
- 50-percent-sparse
|
| 14 |
+
license: apache-2.0
|
| 15 |
+
base_model: junzzhu/atomllama-33K-5x5-DigitMesh-sparse
|
| 16 |
+
library_name: transformers
|
| 17 |
+
pipeline_tag: text-generation
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# AtomLlama-33K-5x5-DigitMesh-Sparse-Q8
|
| 21 |
+
|
| 22 |
+
An INT8 quantized version of [atomllama-33K-5x5-DigitMesh-sparse](https://huggingface.co/junzzhu/atomllama-33K-5x5-DigitMesh-sparse) for ultra-efficient 5×5 digit mesh recognition.
|
| 23 |
+
|
| 24 |
+
## Model Description
|
| 25 |
+
|
| 26 |
+
This is a **50% sparse + INT8 quantized** variant of the AtomLlama-33K-5x5-DigitMesh model, combining structured sparsity with Quantization Aware Training (QAT). This dual compression approach maintains digit recognition accuracy while significantly reducing model size and computational requirements.
|
| 27 |
+
|
| 28 |
+
### Key Features
|
| 29 |
+
|
| 30 |
+
- **Base Model**: [junzzhu/atomllama-33K-5x5-DigitMesh-sparse](https://huggingface.co/junzzhu/atomllama-33K-5x5-DigitMesh-sparse)
|
| 31 |
+
- **Sparsity**: ~50% (unstructured)
|
| 32 |
+
- **Quantization**: INT8 with Quantization Aware Training (QAT)
|
| 33 |
+
- **Parameters**: ~33K total, ~16.5K non-zero, 8-bit precision
|
| 34 |
+
- **Architecture**: LlamaForCausalLM
|
| 35 |
+
- **Task**: 5×5 binary digit mesh recognition
|
| 36 |
+
- **Compression**: ~3x smaller than original model (50% sparsity + 4x from INT8)
|
| 37 |
+
|
| 38 |
+
## Usage
|
| 39 |
+
|
| 40 |
+
### Basic Inference with Transformers
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 44 |
+
|
| 45 |
+
# Load model and tokenizer
|
| 46 |
+
model_path = "./models/atomllama-33K-5x5-DigitMesh-sparse-q8"
|
| 47 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
| 48 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 49 |
+
model_path,
|
| 50 |
+
dtype="auto",
|
| 51 |
+
device_map="auto"
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
# Example: Classify a 5x5 binary digit pattern (digit "0")
|
| 55 |
+
pattern = "1 1 1 1 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 1 1 1 1"
|
| 56 |
+
prompt = f"{pattern} <SEP>"
|
| 57 |
+
|
| 58 |
+
# Tokenize and generate prediction
|
| 59 |
+
inputs = tokenizer([prompt], return_tensors="pt").to(model.device)
|
| 60 |
+
inputs.pop("token_type_ids", None)
|
| 61 |
+
|
| 62 |
+
outputs = model.generate(
|
| 63 |
+
**inputs,
|
| 64 |
+
max_new_tokens=1,
|
| 65 |
+
do_sample=False
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
# Decode the prediction
|
| 69 |
+
prediction = tokenizer.decode(
|
| 70 |
+
outputs[0][len(inputs.input_ids[0]):],
|
| 71 |
+
skip_special_tokens=True
|
| 72 |
+
).strip()
|
| 73 |
+
|
| 74 |
+
print(f"Predicted digit: {prediction}") # Expected: "D0"
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
## Compression Details
|
| 79 |
+
|
| 80 |
+
### Sparsity
|
| 81 |
+
- **Type**: Unstructured (weights pruned individually based on importance)
|
| 82 |
+
- **Target Sparsity**: 50%
|
| 83 |
+
- **Method**: SparseGPT with Hessian-based importance scoring
|
| 84 |
+
|
| 85 |
+
### Quantization
|
| 86 |
+
- **Precision**: INT8 (8-bit integers)
|
| 87 |
+
- **Method**: Quantization Aware Training (QAT)
|
| 88 |
+
- **Framework**: [Axolotl Sparse QAT Integration](https://github.com/junzzhu/axolotl/blob/main/src/axolotl/integrations/sparse_qat/)
|
| 89 |
+
|
| 90 |
+
## License
|
| 91 |
+
|
| 92 |
+
Apache-2.0
|
| 93 |
+
|
| 94 |
+
## Citation
|
| 95 |
+
|
| 96 |
+
```bibtex
|
| 97 |
+
@misc{atomllama-33k-digitMesh-sparse-q8,
|
| 98 |
+
title={AtomLlama-33K-5x5-DigitMesh-Sparse-Q8: A 50% Sparse INT8 Quantized Model for Digit Recognition},
|
| 99 |
+
author={Jun Zhu},
|
| 100 |
+
year={2026},
|
| 101 |
+
howpublished={\url{https://huggingface.co/junzzhu/atomllama-33K-5x5-DigitMesh-sparse-q8}}
|
| 102 |
+
}
|
| 103 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"LlamaForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.3,
|
| 7 |
+
"bos_token_id": 2,
|
| 8 |
+
"dtype": "float32",
|
| 9 |
+
"eos_token_id": 2,
|
| 10 |
+
"head_dim": 8,
|
| 11 |
+
"hidden_act": "silu",
|
| 12 |
+
"hidden_size": 32,
|
| 13 |
+
"initializer_range": 0.02,
|
| 14 |
+
"intermediate_size": 128,
|
| 15 |
+
"max_position_embeddings": 32,
|
| 16 |
+
"mlp_bias": false,
|
| 17 |
+
"model_type": "llama",
|
| 18 |
+
"num_attention_heads": 4,
|
| 19 |
+
"num_hidden_layers": 2,
|
| 20 |
+
"num_key_value_heads": 4,
|
| 21 |
+
"pad_token_id": 2,
|
| 22 |
+
"pretraining_tp": 1,
|
| 23 |
+
"quantization_config": {
|
| 24 |
+
"config_groups": {
|
| 25 |
+
"group_0": {
|
| 26 |
+
"format": "pack-quantized",
|
| 27 |
+
"input_activations": null,
|
| 28 |
+
"output_activations": null,
|
| 29 |
+
"targets": [
|
| 30 |
+
"Linear"
|
| 31 |
+
],
|
| 32 |
+
"weights": {
|
| 33 |
+
"actorder": null,
|
| 34 |
+
"block_structure": null,
|
| 35 |
+
"dynamic": false,
|
| 36 |
+
"group_size": null,
|
| 37 |
+
"num_bits": 8,
|
| 38 |
+
"observer": "minmax",
|
| 39 |
+
"observer_kwargs": {},
|
| 40 |
+
"strategy": "channel",
|
| 41 |
+
"symmetric": true,
|
| 42 |
+
"type": "int"
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
},
|
| 46 |
+
"format": "pack-quantized",
|
| 47 |
+
"global_compression_ratio": null,
|
| 48 |
+
"ignore": [
|
| 49 |
+
"lm_head"
|
| 50 |
+
],
|
| 51 |
+
"kv_cache_scheme": null,
|
| 52 |
+
"quant_method": "compressed-tensors",
|
| 53 |
+
"quantization_status": "compressed",
|
| 54 |
+
"sparsity_config": {},
|
| 55 |
+
"transform_config": {},
|
| 56 |
+
"version": "0.12.2"
|
| 57 |
+
},
|
| 58 |
+
"rms_norm_eps": 1e-06,
|
| 59 |
+
"rope_scaling": null,
|
| 60 |
+
"rope_theta": 10000.0,
|
| 61 |
+
"tie_word_embeddings": false,
|
| 62 |
+
"transformers_version": "4.56.2",
|
| 63 |
+
"use_cache": false,
|
| 64 |
+
"vocab_size": 14
|
| 65 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 2,
|
| 4 |
+
"do_sample": true,
|
| 5 |
+
"eos_token_id": [
|
| 6 |
+
2
|
| 7 |
+
],
|
| 8 |
+
"pad_token_id": 2,
|
| 9 |
+
"transformers_version": "4.56.2"
|
| 10 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:62c96c0e254a2645fb6fd5c3230e042e23c138fbda2f2fdf9d00ce3fce3ab43d
|
| 3 |
+
size 45536
|
recipe.yaml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
default_stage:
|
| 2 |
+
default_modifiers:
|
| 3 |
+
QuantizationModifier:
|
| 4 |
+
targets: [Linear]
|
| 5 |
+
ignore: [lm_head]
|
| 6 |
+
scheme: W8A16
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<SEP>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"eos_token": {
|
| 10 |
+
"content": "<SEP>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"pad_token": {
|
| 17 |
+
"content": "<SEP>",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
}
|
| 23 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"version": "1.0",
|
| 3 |
+
"truncation": null,
|
| 4 |
+
"padding": null,
|
| 5 |
+
"added_tokens": [
|
| 6 |
+
{
|
| 7 |
+
"id": 2,
|
| 8 |
+
"content": "<SEP>",
|
| 9 |
+
"single_word": false,
|
| 10 |
+
"lstrip": false,
|
| 11 |
+
"rstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"special": true
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
"id": 13,
|
| 17 |
+
"content": "<PAD>",
|
| 18 |
+
"single_word": false,
|
| 19 |
+
"lstrip": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"normalized": false,
|
| 22 |
+
"special": true
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"normalizer": null,
|
| 26 |
+
"pre_tokenizer": {
|
| 27 |
+
"type": "WhitespaceSplit"
|
| 28 |
+
},
|
| 29 |
+
"post_processor": null,
|
| 30 |
+
"decoder": null,
|
| 31 |
+
"model": {
|
| 32 |
+
"type": "WordLevel",
|
| 33 |
+
"vocab": {
|
| 34 |
+
"0": 0,
|
| 35 |
+
"1": 1,
|
| 36 |
+
"<SEP>": 2,
|
| 37 |
+
"D0": 3,
|
| 38 |
+
"D1": 4,
|
| 39 |
+
"D2": 5,
|
| 40 |
+
"D3": 6,
|
| 41 |
+
"D4": 7,
|
| 42 |
+
"D5": 8,
|
| 43 |
+
"D6": 9,
|
| 44 |
+
"D7": 10,
|
| 45 |
+
"D8": 11,
|
| 46 |
+
"D9": 12,
|
| 47 |
+
"<PAD>": 13
|
| 48 |
+
},
|
| 49 |
+
"unk_token": "<unk>"
|
| 50 |
+
}
|
| 51 |
+
}
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"2": {
|
| 4 |
+
"content": "<SEP>",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"13": {
|
| 12 |
+
"content": "<PAD>",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
}
|
| 19 |
+
},
|
| 20 |
+
"bos_token": "<SEP>",
|
| 21 |
+
"clean_up_tokenization_spaces": false,
|
| 22 |
+
"eos_token": "<SEP>",
|
| 23 |
+
"extra_special_tokens": {},
|
| 24 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 25 |
+
"pad_token": "<SEP>",
|
| 26 |
+
"tokenizer_class": "PreTrainedTokenizerFast"
|
| 27 |
+
}
|