shibatch commited on
Commit
24bbdc6
·
verified ·
1 Parent(s): 08c6845

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,14 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tinymoeja2m.BF16.gguf filter=lfs diff=lfs merge=lfs -text
37
+ tinymoeja2m.F16.gguf filter=lfs diff=lfs merge=lfs -text
38
+ tinymoeja2m.F32.gguf filter=lfs diff=lfs merge=lfs -text
39
+ tinymoeja2m.Q2_K.gguf filter=lfs diff=lfs merge=lfs -text
40
+ tinymoeja2m.Q3_K_M.gguf filter=lfs diff=lfs merge=lfs -text
41
+ tinymoeja2m.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
42
+ tinymoeja2m.Q4_1.gguf filter=lfs diff=lfs merge=lfs -text
43
+ tinymoeja2m.Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
44
+ tinymoeja2m.Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text
45
+ tinymoeja2m.Q6_K.gguf filter=lfs diff=lfs merge=lfs -text
46
+ tinymoeja2m.Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ base_model: mistralai/Mixtral-8x7B-v0.1
4
+ tags:
5
+ - mixtral
6
+ - moe
7
+ - gguf
8
+ - safetensors
9
+ - transformers
10
+ - validation
11
+ - test-suite
12
+ - japanese
13
+ ---
14
+
15
+ # TinyStories Mixtral 2M Top-2 MoE GQA Japanese Validation Suite (tinymoeja2m)
16
+
17
+ This repository provides an ultra-lightweight, Japanese-specialized Mixtral model variant scaled down to a **2.05M total parameter footprint** and a **1.14M active parameter execution frame**. It is trained on the comprehensive 320k Japanese translated stories from the TinyStories dataset via Gemma 4.
18
+
19
+ This asset is configured with a **2,048 token context window (2k)** and a standard RoPE base frequency (`rope_theta`) of **10,000.0** to act as a clean, trick-free baseline validation asset for runtime implementations.
20
+
21
+ It is designed specifically for debugging custom inference engines against the synergy of Grouped-Query Attention (GQA) and Mixture-of-Experts (MoE) topologies.
22
+
23
+ ---
24
+
25
+ ## 📊 Comparison: `tinymoeja2m` vs Other Variants
26
+
27
+ To help track feature coverage across the verification suite, the updated structural layouts are outlined below:
28
+
29
+ | Feature / Metric | `tiny1m` (Standard) | `tinygemma1m` (Gemma 2) | `tinymoe2m` (English 4k) | `tinymoeja2m` (This Repository) |
30
+ | :--- | :--- | :--- | :--- | :--- |
31
+ | **Language** | English | English | English | **Japanese** |
32
+ | **Base Architecture** | Llama 2 | Gemma 2 | Llama 2 (Mixtral) | **Llama 2 (Mixtral Format)** |
33
+ | **FFN Structure** | Single FFN (Dense) | Single FFN (Dense) | Mixture-of-Experts | **Mixture-of-Experts (MoE)** |
34
+ | **Attention Mechanism** | MHA (Multi-Head) | GQA (Grouped-Query) | MHA (Multi-Head) | **GQA (Grouped-Query)** |
35
+ | **Total / Selected Experts**| 1 / - | 1 / - | 4 Experts / Top-2 | **4 Experts / Top-2** |
36
+ | **GQA Head Ratio (Q:KV)** | 1:1 (MHA) | 4:1 (GQA) | 1:1 (MHA) | **4:1 (Query: 4, KV: 1)** |
37
+ | **Max Position Embeddings** | - | - | 4,096 | **2,048 (2k Context)** |
38
+ | **RoPE Base (`rope_theta`)** | - | - | 15,000.0 | **10,000.0** |
39
+ | **Total / Active Params** | ~1.2M / ~1.2M | ~1.0M / ~1.0M | ~1.95M / ~1.14M | **~2.05M / ~1.14M** |
40
+ | **Primary Debug Target** | Core matrix mult | Advanced graph | Scatter/Gather loops | **GQA Broadcast & Byte Fallback** |
41
+
42
+ ---
43
+
44
+ ## 📂 Repository Structure & File Descriptions
45
+
46
+ ### 1. GGUF Formats (Root Directory `./`)
47
+ Binary files optimized for execution via `llama.cpp` or compatible lower-level inference engines. Upstream parsers automatically recognize this under the `mixed` (Mixtral) descriptor.
48
+
49
+ | Filename | Type | Target / Validation Focus |
50
+ | :--- | :--- | :--- |
51
+ | **`tinymoeja2m.F32.gguf`** | `F32` | **Baseline Test.** Eliminates quantization noise to isolate and verify raw probability mathematics. |
52
+ | **`tinymoeja2m.F16.gguf`**<br>**`tinymoeja2m.BF16.gguf`** | `F16`<br>`BF16` | **Half-Precision Test.** Evaluates 16-bit floating-point unpacking routines and parallelized accumulation layers. |
53
+ | **`tinymoeja2m.Q8_0.gguf`** | `Q8_0` | **Standard Quantization.** Verifies block-based uniform scaling across decentralized MoE structures. |
54
+ | **`tinymoeja2m.Q4_0.gguf`**<br>**`tinymoeja2m.Q4_1.gguf`** | `Q4_0`<br>`Q4_1` | **Classic 4-bit Quantization.** Tests basic linear scaling and unpacking logic across multiple discontinuous expert weight matrices. |
55
+ | **`tinymoeja2m.Q2_K.gguf`** | `Q2_K` | **Standard K-Quant (2-bit).** Evaluates mixed super-block dequantization loops feeding sparse FFN routines. |
56
+ | **`tinymoeja2m.Q3_K_M.gguf`** | `Q3_K_M` | **Standard K-Quant (3-bit).** Tests sub-variant multi-block layouts handling dynamic routing vectors. |
57
+ | **`tinymoeja2m.Q4_K_M.gguf`** | `Q4_K_M` | **Standard K-Quant (4-bit).** Target for modern 4-bit super-block logic coupled with sparse MoE graphs. |
58
+ | **`tinymoeja2m.Q5_K_M.gguf`** | `Q5_K_M` | **Standard K-Quant (5-bit).** Validates high-fidelity mixed 5-bit precision layouts. |
59
+ | **`tinymoeja2m.Q6_K.gguf`** | `Q6_K` | **Standard K-Quant (6-bit).** Validates 6-bit high-fidelity super-block dequantization. |
60
+
61
+ ### 2. Hugging Face Native Format (`./hf/`)
62
+ Unquantized components formatted for direct instantiation inside the PyTorch `transformers` library ecosystem:
63
+ * **`hf/model.safetensors`**: Raw unquantized matrix parameters containing all 4 expert sub-networks, GQA projection matrices, and the master router tensor.
64
+ * **`hf/config.json`**: Architectural specifications built around `MixtralConfig`. Fully configured to enforce `num_attention_heads: 4`, `num_key_value_heads: 1`, `max_position_embeddings: 2048`, and `rope_theta: 10000.0`.
65
+ * **`hf/generation_config.json`**: Standard generation defaults.
66
+ * **`hf/tokenizer.model`**: The custom 1,024-vocabulary size SentencePiece BPE master binary trained on a clean Japanese text subset with `byte_fallback` enabled.
67
+ * **`hf/tokenizer.json`**: Evaluated JSON-serialized token maps for high-speed interoperability across native tokenization backends.
68
+ * **`hf/tokenizer_config.json`**: Enforced metadata linking `LlamaTokenizer` classes to guarantee correct handling of prefix spacing and automatic `<s>` (BOS) injection.
69
+ * **`hf/special_tokens_map.json`**: Structural map linking special tokens (`<s>`=1, `</s>`=2, `<unk>`=0, `<pad>`=2).
70
+
71
+ ---
72
+
73
+ ## 🎯 Purpose & Design Philosophy (Verification Targets)
74
+
75
+ This checkpoint is specifically engineered as a deterministic validation test asset for runtime computing backends and **is not designed for practical semantic tasks.**
76
+
77
+ Due to the compact parameter size (~2.05M) and ultra-focused vocabulary layout (1,024 tokens), the network concentrates its capacity entirely on mastering Japanese phrase continuations and basic syntax under an autoregressive framework.
78
+
79
+ ### Critical Debugging Capabilities for Custom Engines:
80
+ 1. **GQA Broadcast Matrix Multiplication**
81
+ The 4:1 Grouped-Query Attention structure requires the execution kernels to correctly share a single Key/Value cache block across 4 independent Query heads. This serves as an ideal testbed for tracking memory stride offsets and tensor broadcasting alignment in parallel computing shaders.
82
+ 2. **Multi-Byte UTF-8 Byte Fallback Validation**
83
+ With the vocabulary limited to 1,024 tokens, any kanji or character outside the primary training subset triggers the `byte_fallback` mechanism, breaking the character down into raw sequential UTF-8 byte tokens (3 tokens per character). This enforces a rigorous stress test on the engine's streaming decoder to correctly stitch unaligned byte streams back into flawless Japanese text without truncation or corruption.
84
+
85
+ ---
86
+
87
+ ## 🚀 Usage Examples
88
+
89
+ ### A. Running GGUF via llama.cpp
90
+ To process the GQA MoE execution graph and evaluate dynamic expert routing directly on your shell:
91
+ ```bash
92
+ ./llama-cli -m tinymoeja2m.Q4_K_M.gguf -p "トムとリリーは" -n 64 --temp 0.0
93
+
94
+ ```
95
+
96
+ ### B. Loading Hugging Face Formats via Python
97
+
98
+ ```python
99
+ import torch
100
+ from transformers import AutoTokenizer, AutoModelForCausalLM
101
+
102
+ repo_id = "shibatch/tinymoeja2m"
103
+
104
+ print("Loading Japanese MoE GQA configuration and tokenizer layers...")
105
+ tokenizer = AutoTokenizer.from_pretrained(repo_id, subfolder="hf")
106
+ model = AutoModelForCausalLM.from_pretrained(repo_id, subfolder="hf")
107
+
108
+ device = "cuda" if torch.cuda.is_available() else ("xpu" if torch.xpu.is_available() else "cpu")
109
+ model = model.to(device)
110
+ model.eval()
111
+
112
+ prompt = "トムとリリーは"
113
+ inputs = tokenizer(prompt, return_tensors="pt").to(device)
114
+
115
+ print("Running inference loop (Validating 4:1 GQA & Top-2 MoE Kernels)...")
116
+ with torch.no_grad():
117
+ outputs = model.generate(
118
+ **inputs,
119
+ max_length=64,
120
+ do_sample=False
121
+ )
122
+
123
+ generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
124
+
125
+ print("\n--- Inference Test Result ---")
126
+ print("Prompt :", prompt)
127
+ print("Generated:", generated_text)
128
+
129
+ ```
130
+
131
+ ---
132
+
133
+ ## 📝 Model Specifications
134
+
135
+ * **Architecture:** Mixtral (`MixtralForCausalLM`)
136
+ * **Dataset:** TinyStories Japanese Translation Corpus (320k stories)
137
+ * **Total Parameters (`num_local_experts` = 4):** ~2.05M
138
+ * **Active Parameters (`num_experts_per_tok` = 2):** ~1.14M
139
+ * **Vocabulary Size (`vocab_size`):** 1,024 (Custom SentencePiece BPE with `byte_fallback` enabled)
140
+ * **Hidden Size (`hidden_size`):** 128
141
+ * **Number of Hidden Layers (`num_hidden_layers`):** 3
142
+ * **Number of Attention Heads (`num_heads` / `num_kv_heads`):** 4 / 1 *(4:1 GQA layout)*
143
+ * **Individual Expert Internal Dimension (`intermediate_size`):** 352 *(SwiGLU structure)*
144
+ * **Max Position Embeddings (`max_position_embeddings`):** 2,048
145
+ * **RoPE Base Frequency (`rope_theta`):** 10,000.0
146
+
147
+ ## 📜 License
148
+
149
+ * **License:** **MIT License**. You are completely free to duplicate, modify, distribute, and utilize these assets across any commercial, personal, or educational environments.
hf/config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "MixtralForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "bos_token_id": 1,
7
+ "dtype": "float32",
8
+ "eos_token_id": 2,
9
+ "head_dim": null,
10
+ "hidden_act": "silu",
11
+ "hidden_size": 128,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 352,
14
+ "max_position_embeddings": 2048,
15
+ "model_type": "mixtral",
16
+ "num_attention_heads": 4,
17
+ "num_experts_per_tok": 2,
18
+ "num_hidden_layers": 3,
19
+ "num_key_value_heads": 1,
20
+ "num_local_experts": 4,
21
+ "output_router_logits": false,
22
+ "pad_token_id": 2,
23
+ "rms_norm_eps": 1e-05,
24
+ "rope_parameters": {
25
+ "rope_theta": 10000.0,
26
+ "rope_type": "default"
27
+ },
28
+ "router_aux_loss_coef": 0.001,
29
+ "router_jitter_noise": 0.0,
30
+ "sliding_window": null,
31
+ "tie_word_embeddings": false,
32
+ "transformers_version": "5.9.0",
33
+ "use_cache": false,
34
+ "vocab_size": 1024
35
+ }
hf/generation_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "output_attentions": false,
6
+ "output_hidden_states": false,
7
+ "pad_token_id": 2,
8
+ "transformers_version": "5.9.0",
9
+ "use_cache": true
10
+ }
hf/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e05efbaa834a2cf2471dba0dde6bc25b5170583fcf51e212a6821397db542fe0
3
+ size 8044808
hf/special_tokens_map.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "eos_token": "</s>",
4
+ "pad_token": "</s>",
5
+ "unk_token": "<unk>"
6
+ }
hf/tokenizer.json ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "1.0",
3
+ "truncation": null,
4
+ "padding": null,
5
+ "added_tokens": [
6
+ {
7
+ "id": 0,
8
+ "content": "<unk>",
9
+ "single_word": false,
10
+ "lstrip": false,
11
+ "rstrip": false,
12
+ "normalized": false,
13
+ "special": true
14
+ },
15
+ {
16
+ "id": 1,
17
+ "content": "<s>",
18
+ "single_word": false,
19
+ "lstrip": false,
20
+ "rstrip": false,
21
+ "normalized": false,
22
+ "special": true
23
+ },
24
+ {
25
+ "id": 2,
26
+ "content": "</s>",
27
+ "single_word": false,
28
+ "lstrip": false,
29
+ "rstrip": false,
30
+ "normalized": false,
31
+ "special": true
32
+ }
33
+ ],
34
+ "normalizer": null,
35
+ "pre_tokenizer": {
36
+ "type": "Metaspace",
37
+ "replacement": "▁",
38
+ "prepend_scheme": "first",
39
+ "split": false
40
+ },
41
+ "post_processor": {
42
+ "type": "TemplateProcessing",
43
+ "single": [
44
+ {
45
+ "Sequence": {
46
+ "id": "A",
47
+ "type_id": 0
48
+ }
49
+ }
50
+ ],
51
+ "pair": [
52
+ {
53
+ "Sequence": {
54
+ "id": "A",
55
+ "type_id": 0
56
+ }
57
+ },
58
+ {
59
+ "Sequence": {
60
+ "id": "B",
61
+ "type_id": 1
62
+ }
63
+ }
64
+ ],
65
+ "special_tokens": {}
66
+ },
67
+ "decoder": {
68
+ "type": "Sequence",
69
+ "decoders": [
70
+ {
71
+ "type": "Replace",
72
+ "pattern": {
73
+ "String": "▁"
74
+ },
75
+ "content": " "
76
+ },
77
+ {
78
+ "type": "ByteFallback"
79
+ },
80
+ {
81
+ "type": "Fuse"
82
+ },
83
+ {
84
+ "type": "Strip",
85
+ "content": " ",
86
+ "start": 1,
87
+ "stop": 0
88
+ }
89
+ ]
90
+ },
91
+ "model": {
92
+ "type": "BPE",
93
+ "dropout": null,
94
+ "unk_token": null,
95
+ "continuing_subword_prefix": null,
96
+ "end_of_word_suffix": null,
97
+ "fuse_unk": true,
98
+ "byte_fallback": true,
99
+ "ignore_merges": false,
100
+ "vocab": {
101
+ "<unk>": 0,
102
+ "<s>": 1,
103
+ "</s>": 2
104
+ },
105
+ "merges": []
106
+ }
107
+ }
hf/tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:064eec0d246d749175b47e112fd8e16a69745af947b58a8bbce1fc93a4a1d0a7
3
+ size 254715
hf/tokenizer_config.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": null,
3
+ "backend": "tokenizers",
4
+ "bos_token": "<s>",
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "</s>",
7
+ "model_max_length": 1000000000000000019884624838656,
8
+ "pad_token": "</s>",
9
+ "tokenizer_class": "LlamaTokenizer",
10
+ "unk_token": "<unk>",
11
+ "use_default_system_prompt": false
12
+ }
tinymoeja2m.BF16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfebfcdf0713b7f3abf564be699254d9eb1976f816216ecf6e5ad986e10a7905
3
+ size 4048288
tinymoeja2m.F16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:02ab7e1f621602db54b2f254fee0482b713c7ef25371e16037ab2c09b619e933
3
+ size 4048288
tinymoeja2m.F32.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bc6361d000efb38ff380f7b0cbe011e7f7714cf16edf71f69a786f39acee8abd
3
+ size 8062368
tinymoeja2m.Q2_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4ebf693e9b852052e06d330b00d4362999d8fac25faf793bb65dc988b6f481d1
3
+ size 1230240
tinymoeja2m.Q3_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:446a7bc7adc26448ca4f5cde8d1e250906fcc04316b260b50d6301fffe949877
3
+ size 1304480
tinymoeja2m.Q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fe7997b4d6fe1034fcb6d1a61822cfc0a431958c0246341f3f45a2ed9eb7794f
3
+ size 1228704
tinymoeja2m.Q4_1.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3e3b2602948c914c0e399e47931de56b932fc62906eeee12ba5128b828525f66
3
+ size 1345952
tinymoeja2m.Q4_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dd957f6eaa68b8f87546afbcb25f0af17fccc8d54ab074f7aa707bc5b6f35452
3
+ size 1532320
tinymoeja2m.Q5_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:26400fec736c23f0728dfaaf3ae8ad61b4b2b55c666af4eff0c166999392b48c
3
+ size 1638048
tinymoeja2m.Q6_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b3972decba22f8318a13a94ed58fa0ae077e0681d237dd7c8725f482734c73b6
3
+ size 2166688
tinymoeja2m.Q8_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e300cd576f0f5571f7d8e6e0ad022d5985c849932c5208a14478b1a0ad05e0a2
3
+ size 2166688