Text Generation
Transformers
Safetensors
English
mixtral
MixtralForCausalLM
mixture-of-experts
Mixture of Experts
digit-recognition
pattern-recognition
toy-model
educational
text-generation-inference
Instructions to use junzzhu/atoMixtral-58K-5x5-DigitMesh with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use junzzhu/atoMixtral-58K-5x5-DigitMesh with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="junzzhu/atoMixtral-58K-5x5-DigitMesh")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("junzzhu/atoMixtral-58K-5x5-DigitMesh") model = AutoModelForCausalLM.from_pretrained("junzzhu/atoMixtral-58K-5x5-DigitMesh", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use junzzhu/atoMixtral-58K-5x5-DigitMesh with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "junzzhu/atoMixtral-58K-5x5-DigitMesh" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "junzzhu/atoMixtral-58K-5x5-DigitMesh", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/junzzhu/atoMixtral-58K-5x5-DigitMesh
- SGLang
How to use junzzhu/atoMixtral-58K-5x5-DigitMesh with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "junzzhu/atoMixtral-58K-5x5-DigitMesh" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "junzzhu/atoMixtral-58K-5x5-DigitMesh", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "junzzhu/atoMixtral-58K-5x5-DigitMesh" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "junzzhu/atoMixtral-58K-5x5-DigitMesh", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use junzzhu/atoMixtral-58K-5x5-DigitMesh with Docker Model Runner:
docker model run hf.co/junzzhu/atoMixtral-58K-5x5-DigitMesh
Upload 7 files
Browse files- README.md +78 -3
- config.json +32 -0
- generation_config.json +7 -0
- model.safetensors +3 -0
- special_tokens_map.json +5 -0
- tokenizer.json +51 -0
- tokenizer_config.json +27 -0
README.md
CHANGED
|
@@ -1,3 +1,78 @@
|
|
| 1 |
-
---
|
| 2 |
-
|
| 3 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
tags:
|
| 5 |
+
- mixtral
|
| 6 |
+
- MixtralForCausalLM
|
| 7 |
+
- mixture-of-experts
|
| 8 |
+
- moe
|
| 9 |
+
- digit-recognition
|
| 10 |
+
- pattern-recognition
|
| 11 |
+
- toy-model
|
| 12 |
+
- educational
|
| 13 |
+
license: apache-2.0
|
| 14 |
+
library_name: transformers
|
| 15 |
+
pipeline_tag: text-generation
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# AtoMixtral-58K-5x5-DigitMesh
|
| 19 |
+
|
| 20 |
+
A minimal 58K parameter Mixture-of-Experts (MoE) model for 5×5 digit mesh recognition, built on the MixtralForCausalLM architecture.
|
| 21 |
+
|
| 22 |
+
## Model Description
|
| 23 |
+
|
| 24 |
+
**AtoMixtral-58K-5x5-DigitMesh** is an ultra-lightweight MoE causal language model for efficient digit recognition from 5×5 binary mesh patterns. With only 58K parameters and 2 experts, this "atom-sized" MoE model demonstrates effective pattern recognition with sparse expert activation.
|
| 25 |
+
|
| 26 |
+
### Key Specifications
|
| 27 |
+
|
| 28 |
+
- **Architecture**: MixtralForCausalLM (Mixture-of-Experts)
|
| 29 |
+
- **Parameters**: ~58K
|
| 30 |
+
- **Experts**: 2 local experts, 1 active per token
|
| 31 |
+
- **Input**: 5×5 binary mesh (25 tokens)
|
| 32 |
+
- **Output**: Digit tokens (D0-D9)
|
| 33 |
+
- **Vocabulary Size**: 14 tokens
|
| 34 |
+
- **Context Length**: 32 tokens
|
| 35 |
+
- **Hidden Size**: 32, Layers: 2, Attention Heads: 4
|
| 36 |
+
|
| 37 |
+
## Quick Start
|
| 38 |
+
|
| 39 |
+
### Serving with vLLM
|
| 40 |
+
|
| 41 |
+
```bash
|
| 42 |
+
python -m vllm.entrypoints.openai.api_server \
|
| 43 |
+
--model models/atoMixtral-58K-5x5-DigitMesh \
|
| 44 |
+
--max-model-len 32
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
### Test Example
|
| 48 |
+
|
| 49 |
+
```bash
|
| 50 |
+
curl http://localhost:8000/v1/completions \
|
| 51 |
+
-H 'Content-Type: application/json' \
|
| 52 |
+
-d '{
|
| 53 |
+
"model": "models/atoMixtral-58K-5x5-DigitMesh",
|
| 54 |
+
"prompt": "1 1 1 1 1 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 <SEP>",
|
| 55 |
+
"max_tokens": 1,
|
| 56 |
+
"temperature": 0
|
| 57 |
+
}'
|
| 58 |
+
```
|
| 59 |
+
Expected output: `D7`
|
| 60 |
+
|
| 61 |
+
## Input Format
|
| 62 |
+
|
| 63 |
+
25 space-separated binary values (0 or 1) representing a 5×5 grid, followed by `<SEP>`:
|
| 64 |
+
|
| 65 |
+
```
|
| 66 |
+
[5 values] [5 values] [5 values] [5 values] [5 values] <SEP>
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
## Use Cases
|
| 70 |
+
|
| 71 |
+
- MoE architecture research at minimal scale
|
| 72 |
+
- Educational demonstrations of sparse expert models
|
| 73 |
+
- Resource-constrained digit recognition
|
| 74 |
+
- Pattern recognition proof-of-concepts
|
| 75 |
+
|
| 76 |
+
## License
|
| 77 |
+
|
| 78 |
+
Apache-2.0
|
config.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"MixtralForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_dropout": 0.1,
|
| 6 |
+
"bos_token_id": 2,
|
| 7 |
+
"dtype": "float32",
|
| 8 |
+
"eos_token_id": 2,
|
| 9 |
+
"head_dim": null,
|
| 10 |
+
"hidden_act": "silu",
|
| 11 |
+
"hidden_size": 32,
|
| 12 |
+
"initializer_range": 0.02,
|
| 13 |
+
"intermediate_size": 128,
|
| 14 |
+
"max_position_embeddings": 32,
|
| 15 |
+
"model_type": "mixtral",
|
| 16 |
+
"num_attention_heads": 4,
|
| 17 |
+
"num_experts_per_tok": 1,
|
| 18 |
+
"num_hidden_layers": 2,
|
| 19 |
+
"num_key_value_heads": 4,
|
| 20 |
+
"num_local_experts": 2,
|
| 21 |
+
"output_router_logits": false,
|
| 22 |
+
"pad_token_id": 13,
|
| 23 |
+
"rms_norm_eps": 1e-06,
|
| 24 |
+
"rope_theta": 10000.0,
|
| 25 |
+
"router_aux_loss_coef": 0.01,
|
| 26 |
+
"router_jitter_noise": 0.0,
|
| 27 |
+
"sliding_window": null,
|
| 28 |
+
"tie_word_embeddings": false,
|
| 29 |
+
"transformers_version": "4.57.3",
|
| 30 |
+
"use_cache": true,
|
| 31 |
+
"vocab_size": 14
|
| 32 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 2,
|
| 4 |
+
"eos_token_id": 2,
|
| 5 |
+
"pad_token_id": 13,
|
| 6 |
+
"transformers_version": "4.57.3"
|
| 7 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:758d40bfd4c5c98429c8a744a023a087c5c89b8d53a7827ddd387deaee575913
|
| 3 |
+
size 237264
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": "<SEP>",
|
| 3 |
+
"eos_token": "<SEP>",
|
| 4 |
+
"pad_token": "<PAD>"
|
| 5 |
+
}
|
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": "<PAD>",
|
| 26 |
+
"tokenizer_class": "PreTrainedTokenizerFast"
|
| 27 |
+
}
|