Upload folder using huggingface_hub
Browse files- README.md +71 -0
- config.json +31 -0
- mergekit_moe_config.yml +20 -0
- moe_router_weights.pth +3 -0
- special_tokens_map.json +24 -0
- tokenizer.json +0 -0
- tokenizer.model +3 -0
- tokenizer_config.json +42 -0
README.md
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
tags:
|
4 |
+
- moe
|
5 |
+
- frankenmoe
|
6 |
+
- merge
|
7 |
+
- mergekit
|
8 |
+
- lazymergekit
|
9 |
+
- openaccess-ai-collective/tiny-mistral
|
10 |
+
base_model:
|
11 |
+
- openaccess-ai-collective/tiny-mistral
|
12 |
+
- openaccess-ai-collective/tiny-mistral
|
13 |
+
- openaccess-ai-collective/tiny-mistral
|
14 |
+
- openaccess-ai-collective/tiny-mistral
|
15 |
+
---
|
16 |
+
|
17 |
+
# test_tiny_mixtral_only_router
|
18 |
+
|
19 |
+
test_tiny_mixtral_only_router is a Mixure of Experts (MoE) made with the following models using [LazyMergekit](https://colab.research.google.com/drive/1obulZ1ROXHjYLn6PPZJwRR6GzgQogxxb?usp=sharing):
|
20 |
+
* [openaccess-ai-collective/tiny-mistral](https://huggingface.co/openaccess-ai-collective/tiny-mistral)
|
21 |
+
* [openaccess-ai-collective/tiny-mistral](https://huggingface.co/openaccess-ai-collective/tiny-mistral)
|
22 |
+
* [openaccess-ai-collective/tiny-mistral](https://huggingface.co/openaccess-ai-collective/tiny-mistral)
|
23 |
+
* [openaccess-ai-collective/tiny-mistral](https://huggingface.co/openaccess-ai-collective/tiny-mistral)
|
24 |
+
|
25 |
+
## 🧩 Configuration
|
26 |
+
|
27 |
+
```yaml
|
28 |
+
base_model: openaccess-ai-collective/tiny-mistral
|
29 |
+
gate_mode: hidden
|
30 |
+
dtype: bfloat16
|
31 |
+
experts:
|
32 |
+
- source_model: openaccess-ai-collective/tiny-mistral
|
33 |
+
positive_prompts:
|
34 |
+
- "math"
|
35 |
+
# You can add negative_prompts if needed
|
36 |
+
- source_model: openaccess-ai-collective/tiny-mistral
|
37 |
+
|
38 |
+
positive_prompts:
|
39 |
+
- "science"
|
40 |
+
- source_model: openaccess-ai-collective/tiny-mistral
|
41 |
+
positive_prompts:
|
42 |
+
- "writing"
|
43 |
+
# You can add negative_prompts if needed
|
44 |
+
- source_model: openaccess-ai-collective/tiny-mistral
|
45 |
+
positive_prompts:
|
46 |
+
- "general"
|
47 |
+
```
|
48 |
+
|
49 |
+
## 💻 Usage
|
50 |
+
|
51 |
+
```python
|
52 |
+
!pip install -qU transformers bitsandbytes accelerate
|
53 |
+
|
54 |
+
from transformers import AutoTokenizer
|
55 |
+
import transformers
|
56 |
+
import torch
|
57 |
+
|
58 |
+
model = "JSpergel/test_tiny_mixtral_only_router"
|
59 |
+
|
60 |
+
tokenizer = AutoTokenizer.from_pretrained(model)
|
61 |
+
pipeline = transformers.pipeline(
|
62 |
+
"text-generation",
|
63 |
+
model=model,
|
64 |
+
model_kwargs={"torch_dtype": torch.float16, "load_in_4bit": True},
|
65 |
+
)
|
66 |
+
|
67 |
+
messages = [{"role": "user", "content": "Explain what a Mixture of Experts is in less than 100 words."}]
|
68 |
+
prompt = pipeline.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
69 |
+
outputs = pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
|
70 |
+
print(outputs[0]["generated_text"])
|
71 |
+
```
|
config.json
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "openaccess-ai-collective/tiny-mistral",
|
3 |
+
"architectures": [
|
4 |
+
"MixtralForCausalLM"
|
5 |
+
],
|
6 |
+
"attention_dropout": 0.0,
|
7 |
+
"bos_token_id": 1,
|
8 |
+
"dropout_p": 0.1,
|
9 |
+
"eos_token_id": 2,
|
10 |
+
"hidden_act": "silu",
|
11 |
+
"hidden_size": 512,
|
12 |
+
"initializer_range": 0.02,
|
13 |
+
"intermediate_size": 14336,
|
14 |
+
"max_position_embeddings": 32768,
|
15 |
+
"model_type": "mixtral",
|
16 |
+
"num_attention_heads": 16,
|
17 |
+
"num_experts_per_tok": 2,
|
18 |
+
"num_hidden_layers": 8,
|
19 |
+
"num_key_value_heads": 4,
|
20 |
+
"num_local_experts": 4,
|
21 |
+
"output_router_logits": false,
|
22 |
+
"rms_norm_eps": 1e-05,
|
23 |
+
"rope_theta": 10000.0,
|
24 |
+
"router_aux_loss_coef": 0.001,
|
25 |
+
"sliding_window": null,
|
26 |
+
"tie_word_embeddings": false,
|
27 |
+
"torch_dtype": "bfloat16",
|
28 |
+
"transformers_version": "4.39.3",
|
29 |
+
"use_cache": true,
|
30 |
+
"vocab_size": 32000
|
31 |
+
}
|
mergekit_moe_config.yml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
base_model: openaccess-ai-collective/tiny-mistral
|
3 |
+
gate_mode: hidden
|
4 |
+
dtype: bfloat16
|
5 |
+
experts:
|
6 |
+
- source_model: openaccess-ai-collective/tiny-mistral
|
7 |
+
positive_prompts:
|
8 |
+
- "math"
|
9 |
+
# You can add negative_prompts if needed
|
10 |
+
- source_model: openaccess-ai-collective/tiny-mistral
|
11 |
+
|
12 |
+
positive_prompts:
|
13 |
+
- "science"
|
14 |
+
- source_model: openaccess-ai-collective/tiny-mistral
|
15 |
+
positive_prompts:
|
16 |
+
- "writing"
|
17 |
+
# You can add negative_prompts if needed
|
18 |
+
- source_model: openaccess-ai-collective/tiny-mistral
|
19 |
+
positive_prompts:
|
20 |
+
- "general"
|
moe_router_weights.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f030f672fe5e9dbf86bccef6eee1b7b67e506055dff820c323fbe21db254f461
|
3 |
+
size 36228
|
special_tokens_map.json
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"content": "<s>",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": true,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"eos_token": {
|
10 |
+
"content": "</s>",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": true,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"pad_token": "<s>",
|
17 |
+
"unk_token": {
|
18 |
+
"content": "<unk>",
|
19 |
+
"lstrip": false,
|
20 |
+
"normalized": true,
|
21 |
+
"rstrip": false,
|
22 |
+
"single_word": false
|
23 |
+
}
|
24 |
+
}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dadfd56d766715c61d2ef780a525ab43b8e6da4de6865bda3d95fdef5e134055
|
3 |
+
size 493443
|
tokenizer_config.json
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": true,
|
3 |
+
"add_eos_token": false,
|
4 |
+
"added_tokens_decoder": {
|
5 |
+
"0": {
|
6 |
+
"content": "<unk>",
|
7 |
+
"lstrip": false,
|
8 |
+
"normalized": true,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false,
|
11 |
+
"special": true
|
12 |
+
},
|
13 |
+
"1": {
|
14 |
+
"content": "<s>",
|
15 |
+
"lstrip": false,
|
16 |
+
"normalized": true,
|
17 |
+
"rstrip": false,
|
18 |
+
"single_word": false,
|
19 |
+
"special": true
|
20 |
+
},
|
21 |
+
"2": {
|
22 |
+
"content": "</s>",
|
23 |
+
"lstrip": false,
|
24 |
+
"normalized": true,
|
25 |
+
"rstrip": false,
|
26 |
+
"single_word": false,
|
27 |
+
"special": true
|
28 |
+
}
|
29 |
+
},
|
30 |
+
"additional_special_tokens": [],
|
31 |
+
"bos_token": "<s>",
|
32 |
+
"clean_up_tokenization_spaces": false,
|
33 |
+
"eos_token": "</s>",
|
34 |
+
"legacy": true,
|
35 |
+
"model_max_length": 1000000000000000019884624838656,
|
36 |
+
"pad_token": "<s>",
|
37 |
+
"sp_model_kwargs": {},
|
38 |
+
"spaces_between_special_tokens": false,
|
39 |
+
"tokenizer_class": "LlamaTokenizer",
|
40 |
+
"unk_token": "<unk>",
|
41 |
+
"use_default_system_prompt": true
|
42 |
+
}
|