初始化项目,由ModelHub XC社区提供模型
Model: FlameF0X/TinyMoE-100m-2x8-chat-stage1 Source: Original Platform
This commit is contained in:
35
.gitattributes
vendored
Normal file
35
.gitattributes
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
178
README.md
Normal file
178
README.md
Normal file
@@ -0,0 +1,178 @@
|
||||
---
|
||||
language:
|
||||
- en
|
||||
license: apache-2.0
|
||||
library_name: transformers
|
||||
pipeline_tag: text-generation
|
||||
tags:
|
||||
- moe
|
||||
- mixture-of-experts
|
||||
- chat
|
||||
- sft
|
||||
- fine-tuned
|
||||
- pytorch
|
||||
- tiny
|
||||
- efficient
|
||||
- trl
|
||||
base_model: FlameF0X/TinyMoE-100m-2x8-retrained
|
||||
datasets:
|
||||
- HuggingFaceTB/smol-smoltalk
|
||||
- yahma/alpaca-cleaned
|
||||
- databricks/databricks-dolly-15k
|
||||
- HuggingFaceH4/ultrachat_200k
|
||||
- Open-Orca/OpenOrca
|
||||
- teknium/openhermes
|
||||
- HuggingFaceH4/no_robots
|
||||
model-index:
|
||||
- name: TinyMoE-100m-2x8-chat-stage1
|
||||
results: []
|
||||
---
|
||||
|
||||
# TinyMoE-100m-2x8 Chat (Stage 1)
|
||||
|
||||
A **chat fine-tuned Mixture of Experts (MoE) language model** — small, efficient, and fully open-source.
|
||||
|
||||
TinyMoE is a ~100M parameter transformer using a **Mixture of Experts** architecture, fine-tuned via supervised fine-tuning (SFT) on a diverse blend of high-quality chat and instruction datasets. It's designed to be a compact but capable conversational AI that knows its own identity.
|
||||
|
||||
## Model Details
|
||||
|
||||
| Property | Value |
|
||||
|---|---|
|
||||
| **Architecture** | Mixture of Experts (MoE) Transformer |
|
||||
| **Parameters** | ~100M total |
|
||||
| **Experts** | 8 experts, top-2 routing per token |
|
||||
| **Context Length** | 4,096 tokens (extended via linear RoPE scaling) |
|
||||
| **Chat Template** | ChatML-style — `<\|system\|>`, `<\|user\|>`, `<\|assistant\|>` |
|
||||
| **Base Model** | [TinyMoE-100m-2x8-retrained](https://huggingface.co/FlameF0X/TinyMoE-100m-2x8-retrained) |
|
||||
| **Training Type** | Full-weight SFT (not LoRA) |
|
||||
| **Precision** | bfloat16 |
|
||||
| **Creator** | [FlameF0X](https://huggingface.co/FlameF0X) |
|
||||
| **License** | Apache 2.0 |
|
||||
|
||||
## What is Mixture of Experts?
|
||||
|
||||
Unlike a standard dense transformer where every token goes through the same large feed-forward network, TinyMoE uses **8 expert sub-networks** with a learned router that selects the top-2 experts per token. This means:
|
||||
|
||||
- **More total knowledge capacity** without proportionally increasing compute
|
||||
- **Sparse activation** — only a fraction of parameters fire per token
|
||||
- **Efficient inference** — you get more model per FLOP
|
||||
|
||||
This is the same architectural family as Mixtral, but at a much smaller scale — proving that MoE works even at ~100M parameters.
|
||||
|
||||
## Training Recipe
|
||||
|
||||
### Stage 1 — Chat SFT
|
||||
|
||||
The base pretrained model was fine-tuned on a carefully curated mixture of chat datasets to teach conversational ability, instruction following, and model identity.
|
||||
|
||||
**Hardware:** NVIDIA L4 (24 GB) on [Modal](https://modal.com)
|
||||
**Framework:** TRL (Transformer Reinforcement Learning) `SFTTrainer`
|
||||
**Max examples:** 80,000 (after length filtering)
|
||||
|
||||
| Hyperparameter | Value |
|
||||
|---|---|
|
||||
| Epochs | 3 |
|
||||
| Learning Rate | 2e-5 |
|
||||
| LR Schedule | Cosine with 5% warmup |
|
||||
| Optimizer | AdamW (weight decay 0.01) |
|
||||
| Batch Size | 4 per device × 8 grad accum = 32 effective |
|
||||
| Max Gradient Norm | 1.0 |
|
||||
| Packing | Yes |
|
||||
| Gradient Checkpointing | Yes |
|
||||
|
||||
### Training Datasets
|
||||
|
||||
| Dataset | Examples | Description |
|
||||
|---|---|---|
|
||||
| [SmolTalk](https://huggingface.co/datasets/HuggingFaceTB/smol-smoltalk) | ~4k | Synthetic diverse chat conversations |
|
||||
| [Alpaca Cleaned](https://huggingface.co/datasets/yahma/alpaca-cleaned) | ~52k | Cleaned instruction-following data |
|
||||
| [Dolly 15k](https://huggingface.co/datasets/databricks/databricks-dolly-15k) | ~15k | Human-written instruction/response pairs |
|
||||
| [UltraChat 200k](https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k) | 12k subset | High-quality multi-turn chat |
|
||||
| [OpenOrca](https://huggingface.co/datasets/Open-Orca/OpenOrca) | 15k subset | GPT-4 augmented FLAN instructions |
|
||||
| [OpenHermes](https://huggingface.co/datasets/teknium/openhermes) | 10k subset | Diverse tasks (code, write, reason, roleplay) |
|
||||
| [No Robots](https://huggingface.co/datasets/HuggingFaceH4/no_robots) | 10k | Hand-curated high-quality SFT examples |
|
||||
| **TinyMoE Identity** *(custom)* | 44 | Synthetic identity Q&A + multi-turn conversations |
|
||||
|
||||
### Identity Training
|
||||
|
||||
The model was explicitly taught to know it's **TinyMoE** through two mechanisms:
|
||||
|
||||
1. **Dedicated identity dataset** — 44 custom examples covering name, creator, architecture, capabilities, and differentiation from other models (ChatGPT, Claude, Llama, etc.)
|
||||
2. **System prompt injection** — 15% of all training examples received a system prompt: *"You are TinyMoE, a helpful Mixture of Experts AI assistant created by FlameF0X."*
|
||||
|
||||
This means TinyMoE knows who it is — ask it "What's your name?" or "Who created you?" and it will answer correctly.
|
||||
|
||||
## Usage
|
||||
|
||||
### Chat Format
|
||||
|
||||
TinyMoE uses a **ChatML-style** template with special tokens:
|
||||
|
||||
```
|
||||
<|system|>
|
||||
You are TinyMoE, a helpful Mixture of Experts AI assistant created by FlameF0X.</s>
|
||||
<|user|>
|
||||
What's Mixture of Experts?</s>
|
||||
<|assistant|>
|
||||
MoE stands for Mixture of Experts! Instead of one big neural network...</s>
|
||||
```
|
||||
|
||||
### Quick Start
|
||||
|
||||
```python
|
||||
import torch
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
model_id = "FlameF0X/TinyMoE-100m-2x8-chat-stage1"
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
||||
model = AutoModelForCausalLM.from_pretrained(
|
||||
model_id,
|
||||
torch_dtype=torch.bfloat16,
|
||||
device_map="auto",
|
||||
)
|
||||
|
||||
messages = [
|
||||
{"role": "system", "content": "You are TinyMoE, a helpful Mixture of Experts AI assistant created by FlameF0X."},
|
||||
{"role": "user", "content": "What's your name and who made you?"},
|
||||
]
|
||||
|
||||
inputs = tokenizer.apply_chat_template(
|
||||
messages,
|
||||
tokenize=True,
|
||||
add_generation_prompt=True,
|
||||
return_tensors="pt",
|
||||
).to(model.device)
|
||||
|
||||
outputs = model.generate(
|
||||
inputs,
|
||||
max_new_tokens=256,
|
||||
temperature=0.7,
|
||||
do_sample=True,
|
||||
top_p=0.9,
|
||||
)
|
||||
|
||||
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
||||
```
|
||||
## Capabilities & Limitations
|
||||
|
||||
### ✅ Strengths
|
||||
|
||||
- **Efficient** — MoE architecture means more capacity per inference FLOP
|
||||
- **Conversational** — trained on diverse multi-turn chat data
|
||||
- **Self-aware** — knows it's TinyMoE, not ChatGPT/Claude/Llama
|
||||
- **Open-source** — weights, architecture, and training code are all public
|
||||
- **Fast** — small enough to run on consumer hardware or free-tier GPUs
|
||||
|
||||
### ⚠️ Limitations
|
||||
|
||||
- **Small model** — at 100M parameters, factual knowledge is limited compared to billion-parameter models
|
||||
- **Stage 1 only** — this is a direct-answer SFT model; it hasn't undergone RLHF/DPO alignment
|
||||
- **No CoT** — training explicitly excluded chain-of-thought reasoning traces (saved for future stages)
|
||||
- **English only** — training data was English-dominant
|
||||
- **May hallucinate** — like all LLMs, it can generate incorrect information with confidence
|
||||
|
||||
### Future Stages (planned)
|
||||
|
||||
- **Stage 2:** MCP/Tool usage + RL
|
||||
- **Longer context** — potential extension beyond 4K tokens
|
||||
8
chat_template.jinja
Normal file
8
chat_template.jinja
Normal file
@@ -0,0 +1,8 @@
|
||||
{% for message in messages %}{% if message['role'] == 'system' %}{{ '<|system|>
|
||||
' + message['content'] + eos_token + '
|
||||
' }}{% elif message['role'] == 'user' %}{{ '<|user|>
|
||||
' + message['content'] + eos_token + '
|
||||
' }}{% elif message['role'] == 'assistant' %}{{ '<|assistant|>
|
||||
' + message['content'] + eos_token + '
|
||||
' }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '<|assistant|>
|
||||
' }}{% endif %}
|
||||
35
config.json
Normal file
35
config.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"architectures": [
|
||||
"MixtralForCausalLM"
|
||||
],
|
||||
"attention_dropout": 0.0,
|
||||
"bos_token_id": 1,
|
||||
"eos_token_id": 2,
|
||||
"head_dim": null,
|
||||
"hidden_act": "silu",
|
||||
"hidden_size": 384,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 768,
|
||||
"max_position_embeddings": 4096,
|
||||
"model_type": "mixtral",
|
||||
"num_attention_heads": 8,
|
||||
"num_experts_per_tok": 2,
|
||||
"num_hidden_layers": 10,
|
||||
"num_key_value_heads": 4,
|
||||
"num_local_experts": 8,
|
||||
"output_router_logits": true,
|
||||
"rms_norm_eps": 1e-06,
|
||||
"rope_scaling": {
|
||||
"factor": 4.0,
|
||||
"type": "linear"
|
||||
},
|
||||
"rope_theta": 1000000.0,
|
||||
"router_aux_loss_coef": 0.02,
|
||||
"router_jitter_noise": 0.0,
|
||||
"sliding_window": 4096,
|
||||
"tie_word_embeddings": false,
|
||||
"torch_dtype": "bfloat16",
|
||||
"transformers_version": "4.55.0",
|
||||
"use_cache": false,
|
||||
"vocab_size": 32003
|
||||
}
|
||||
7
generation_config.json
Normal file
7
generation_config.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"_from_model_config": true,
|
||||
"bos_token_id": 1,
|
||||
"eos_token_id": 2,
|
||||
"transformers_version": "4.55.0",
|
||||
"use_cache": false
|
||||
}
|
||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:720e7f5dc0986d0168c31d57c0dd1efc5ef53ab0a70b2af29d3a22de06feb1c3
|
||||
size 199677576
|
||||
53
special_tokens_map.json
Normal file
53
special_tokens_map.json
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"additional_special_tokens": [
|
||||
{
|
||||
"content": "<|system|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
{
|
||||
"content": "<|user|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
{
|
||||
"content": "<|assistant|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
}
|
||||
],
|
||||
"bos_token": {
|
||||
"content": "<s>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"eos_token": {
|
||||
"content": "</s>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"pad_token": {
|
||||
"content": "</s>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"unk_token": {
|
||||
"content": "<unk>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
}
|
||||
}
|
||||
268080
tokenizer.json
Normal file
268080
tokenizer.json
Normal file
File diff suppressed because it is too large
Load Diff
76
tokenizer_config.json
Normal file
76
tokenizer_config.json
Normal file
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"add_bos_token": true,
|
||||
"add_eos_token": false,
|
||||
"add_prefix_space": null,
|
||||
"added_tokens_decoder": {
|
||||
"0": {
|
||||
"content": "<unk>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"1": {
|
||||
"content": "<s>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"2": {
|
||||
"content": "</s>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"32000": {
|
||||
"content": "<|system|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"32001": {
|
||||
"content": "<|user|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"32002": {
|
||||
"content": "<|assistant|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
}
|
||||
},
|
||||
"additional_special_tokens": [
|
||||
"<|system|>",
|
||||
"<|user|>",
|
||||
"<|assistant|>"
|
||||
],
|
||||
"bos_token": "<s>",
|
||||
"clean_up_tokenization_spaces": false,
|
||||
"eos_token": "</s>",
|
||||
"extra_special_tokens": {},
|
||||
"legacy": false,
|
||||
"max_length": 1024,
|
||||
"model_max_length": 4096,
|
||||
"pad_token": "</s>",
|
||||
"sp_model_kwargs": {},
|
||||
"spaces_between_special_tokens": false,
|
||||
"stride": 0,
|
||||
"tokenizer_class": "LlamaTokenizerFast",
|
||||
"truncation_side": "right",
|
||||
"truncation_strategy": "longest_first",
|
||||
"unk_token": "<unk>",
|
||||
"use_default_system_prompt": false
|
||||
}
|
||||
Reference in New Issue
Block a user