Instructions to use Delta-Vector/Trinity-Large-Base-Magnum-SFT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Delta-Vector/Trinity-Large-Base-Magnum-SFT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Delta-Vector/Trinity-Large-Base-Magnum-SFT", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Delta-Vector/Trinity-Large-Base-Magnum-SFT", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("Delta-Vector/Trinity-Large-Base-Magnum-SFT", trust_remote_code=True, device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Delta-Vector/Trinity-Large-Base-Magnum-SFT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Delta-Vector/Trinity-Large-Base-Magnum-SFT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Delta-Vector/Trinity-Large-Base-Magnum-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Delta-Vector/Trinity-Large-Base-Magnum-SFT
- SGLang
How to use Delta-Vector/Trinity-Large-Base-Magnum-SFT 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 "Delta-Vector/Trinity-Large-Base-Magnum-SFT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Delta-Vector/Trinity-Large-Base-Magnum-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "Delta-Vector/Trinity-Large-Base-Magnum-SFT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Delta-Vector/Trinity-Large-Base-Magnum-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Delta-Vector/Trinity-Large-Base-Magnum-SFT with Docker Model Runner:
docker model run hf.co/Delta-Vector/Trinity-Large-Base-Magnum-SFT
Add NewEden configuration and tokenizer
Browse files- .gitattributes +1 -0
- LICENSE +49 -0
- README.md +60 -0
- chat_template.jinja +1 -0
- config.json +108 -0
- configuration_afmoe.py +129 -0
- model.safetensors.index.json +0 -0
- tokenizer.json +3 -0
- tokenizer_config.json +14 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ 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 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
OpenMDW License Agreement, version 1.1 (OpenMDW-1.1)
|
| 2 |
+
|
| 3 |
+
By exercising rights granted to you under this agreement, you accept and agree
|
| 4 |
+
to its terms.
|
| 5 |
+
|
| 6 |
+
As used in this agreement, "Model Materials" means the materials provided to
|
| 7 |
+
you under this agreement, consisting of: (1) one or more machine learning
|
| 8 |
+
models (including architecture and parameters); and (2) all related artifacts
|
| 9 |
+
(including associated data, documentation and software) that are provided to
|
| 10 |
+
you hereunder.
|
| 11 |
+
|
| 12 |
+
Subject to your compliance with this agreement, permission is hereby granted,
|
| 13 |
+
free of charge, to deal in the Model Materials without restriction, including
|
| 14 |
+
under all copyright, patent, database, and trade secret rights included or
|
| 15 |
+
embodied therein.
|
| 16 |
+
|
| 17 |
+
If you distribute any portion of the Model Materials, you shall retain in your
|
| 18 |
+
distribution (1) a copy of this agreement, and (2) all copyright notices and
|
| 19 |
+
other notices of origin included in the Model Materials that are applicable to
|
| 20 |
+
your distribution.
|
| 21 |
+
|
| 22 |
+
If you file, maintain, or voluntarily participate in a lawsuit against any
|
| 23 |
+
person or entity asserting that the Model Materials directly or indirectly
|
| 24 |
+
infringe any patent or copyright, then all rights and grants made to you
|
| 25 |
+
hereunder are terminated, unless that lawsuit was in response to a
|
| 26 |
+
corresponding lawsuit first brought against you.
|
| 27 |
+
|
| 28 |
+
This agreement does not impose any restrictions or obligations with respect to
|
| 29 |
+
any use, modification, or sharing of any outputs generated by using the Model
|
| 30 |
+
Materials.
|
| 31 |
+
|
| 32 |
+
THE MODEL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
| 33 |
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 34 |
+
FITNESS FOR A PARTICULAR PURPOSE, TITLE, NONINFRINGEMENT, ACCURACY, OR THE
|
| 35 |
+
ABSENCE OF LATENT OR OTHER DEFECTS OR ERRORS, WHETHER OR NOT DISCOVERABLE, ALL
|
| 36 |
+
TO THE GREATEST EXTENT PERMISSIBLE UNDER APPLICABLE LAW.
|
| 37 |
+
|
| 38 |
+
YOU ARE SOLELY RESPONSIBLE FOR (1) CLEARING RIGHTS OF OTHER PERSONS THAT MAY
|
| 39 |
+
APPLY TO THE MODEL MATERIALS OR ANY USE THEREOF, INCLUDING WITHOUT LIMITATION
|
| 40 |
+
ANY PERSON'S COPYRIGHTS OR OTHER RIGHTS INCLUDED OR EMBODIED IN THE MODEL
|
| 41 |
+
MATERIALS; (2) OBTAINING ANY NECESSARY CONSENTS, PERMISSIONS OR OTHER RIGHTS
|
| 42 |
+
REQUIRED FOR ANY USE OF THE MODEL MATERIALS; OR (3) PERFORMING ANY DUE
|
| 43 |
+
DILIGENCE OR UNDERTAKING ANY OTHER INVESTIGATIONS INTO THE MODEL MATERIALS OR
|
| 44 |
+
ANYTHING INCORPORATED OR EMBODIED THEREIN.
|
| 45 |
+
|
| 46 |
+
IN NO EVENT SHALL THE PROVIDERS OF THE MODEL MATERIALS BE LIABLE FOR ANY CLAIM,
|
| 47 |
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
| 48 |
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MODEL MATERIALS, THE
|
| 49 |
+
USE THEREOF OR OTHER DEALINGS THEREIN.
|
README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: openmdw-1.1
|
| 4 |
+
license_link: LICENSE
|
| 5 |
+
base_model: arcee-ai/Trinity-Large-Base
|
| 6 |
+
library_name: transformers
|
| 7 |
+
pipeline_tag: text-generation
|
| 8 |
+
tags:
|
| 9 |
+
- NewEden
|
| 10 |
+
- trinity
|
| 11 |
+
- sparse-moe
|
| 12 |
+
- merged
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# NewEden
|
| 16 |
+
|
| 17 |
+
NewEden is a non-reasoning instruction and creative-writing fine-tune of
|
| 18 |
+
[Arcee AI's Trinity-Large-Base](https://huggingface.co/arcee-ai/Trinity-Large-Base).
|
| 19 |
+
This repository contains the merged BF16 checkpoint, not a standalone LoRA adapter.
|
| 20 |
+
|
| 21 |
+
## Training
|
| 22 |
+
|
| 23 |
+
- LoRA rank: 64
|
| 24 |
+
- LoRA alpha: 128
|
| 25 |
+
- Context length: 32,768
|
| 26 |
+
- Learning rate: 8e-6
|
| 27 |
+
- Schedule: cosine
|
| 28 |
+
- Weight decay: 0.0001
|
| 29 |
+
- Maximum gradient norm: 1.0
|
| 30 |
+
- Final checkpoint: step 523
|
| 31 |
+
|
| 32 |
+
The training mix intentionally contains non-reasoning instruction, roleplay, and
|
| 33 |
+
creative-writing data:
|
| 34 |
+
|
| 35 |
+
- `PocketDoc/Dans-Kinomaxx-VanillaBackrooms`
|
| 36 |
+
- `PocketDoc/Dans-Personamaxx-Logs-2`
|
| 37 |
+
- `PocketDoc/Dans-Prosemaxx-RepRemover-1`
|
| 38 |
+
- `PocketDoc/Dans-Failuremaxx-Adventure-3`
|
| 39 |
+
- `Delta-Vector/Hydrus-Claude-Instruct-2.7K`
|
| 40 |
+
- `Delta-Vector/Hydrus-Claude-Instruct-5K`
|
| 41 |
+
- `anthracite-org/kalo-opus-instruct-22k-no-refusal`
|
| 42 |
+
- `anthracite-org/nopm_claude_writing_fixed`
|
| 43 |
+
- `anthracite-org/kalo_opus_misc_240827`
|
| 44 |
+
- `anthracite-org/kalo_misc_part2`
|
| 45 |
+
- `Epiculous/SynthRP-Gens-v1.1-Filtered-n-Cleaned`
|
| 46 |
+
- `Epiculous/Synthstruct-Gens-v1.1-Filtered-n-Cleaned`
|
| 47 |
+
- `Delta-Vector/Orion-Sonnet-CharCard`
|
| 48 |
+
|
| 49 |
+
## Format
|
| 50 |
+
|
| 51 |
+
The checkpoint uses the tokenizer and ChatML template saved by the final training
|
| 52 |
+
checkpoint. The template supports `system`, `user`, and `assistant` messages and
|
| 53 |
+
uses `<|im_end|>` as EOS and padding.
|
| 54 |
+
|
| 55 |
+
Trinity-Large is a 398B-parameter sparse mixture-of-experts model with roughly 13B
|
| 56 |
+
active parameters per token. Serving the BF16 checkpoint requires multiple GPUs.
|
| 57 |
+
|
| 58 |
+
## License
|
| 59 |
+
|
| 60 |
+
NewEden retains the base model's OpenMDW 1.1 license. See `LICENSE`.
|
chat_template.jinja
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{{ bos_token }}{% for message in messages %}{{ '<|im_start|>' + message['role'] + '\n' + (message.get('prefix') or '') + message['content'] + '<|im_end|>\n' }}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}
|
config.json
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"AfmoeForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_dropout": 0.0,
|
| 6 |
+
"auto_map": {
|
| 7 |
+
"AutoConfig": "configuration_afmoe.AfmoeConfig",
|
| 8 |
+
"AutoModel": "modeling_afmoe.AfmoeModel",
|
| 9 |
+
"AutoModelForCausalLM": "modeling_afmoe.AfmoeForCausalLM"
|
| 10 |
+
},
|
| 11 |
+
"dtype": "bfloat16",
|
| 12 |
+
"global_attn_every_n_layers": 4,
|
| 13 |
+
"head_dim": 128,
|
| 14 |
+
"hidden_act": "silu",
|
| 15 |
+
"hidden_size": 3072,
|
| 16 |
+
"initializer_range": 0.02,
|
| 17 |
+
"intermediate_size": 12288,
|
| 18 |
+
"layer_types": [
|
| 19 |
+
"sliding_attention",
|
| 20 |
+
"sliding_attention",
|
| 21 |
+
"sliding_attention",
|
| 22 |
+
"full_attention",
|
| 23 |
+
"sliding_attention",
|
| 24 |
+
"sliding_attention",
|
| 25 |
+
"sliding_attention",
|
| 26 |
+
"full_attention",
|
| 27 |
+
"sliding_attention",
|
| 28 |
+
"sliding_attention",
|
| 29 |
+
"sliding_attention",
|
| 30 |
+
"full_attention",
|
| 31 |
+
"sliding_attention",
|
| 32 |
+
"sliding_attention",
|
| 33 |
+
"sliding_attention",
|
| 34 |
+
"full_attention",
|
| 35 |
+
"sliding_attention",
|
| 36 |
+
"sliding_attention",
|
| 37 |
+
"sliding_attention",
|
| 38 |
+
"full_attention",
|
| 39 |
+
"sliding_attention",
|
| 40 |
+
"sliding_attention",
|
| 41 |
+
"sliding_attention",
|
| 42 |
+
"full_attention",
|
| 43 |
+
"sliding_attention",
|
| 44 |
+
"sliding_attention",
|
| 45 |
+
"sliding_attention",
|
| 46 |
+
"full_attention",
|
| 47 |
+
"sliding_attention",
|
| 48 |
+
"sliding_attention",
|
| 49 |
+
"sliding_attention",
|
| 50 |
+
"full_attention",
|
| 51 |
+
"sliding_attention",
|
| 52 |
+
"sliding_attention",
|
| 53 |
+
"sliding_attention",
|
| 54 |
+
"full_attention",
|
| 55 |
+
"sliding_attention",
|
| 56 |
+
"sliding_attention",
|
| 57 |
+
"sliding_attention",
|
| 58 |
+
"full_attention",
|
| 59 |
+
"sliding_attention",
|
| 60 |
+
"sliding_attention",
|
| 61 |
+
"sliding_attention",
|
| 62 |
+
"full_attention",
|
| 63 |
+
"sliding_attention",
|
| 64 |
+
"sliding_attention",
|
| 65 |
+
"sliding_attention",
|
| 66 |
+
"full_attention",
|
| 67 |
+
"sliding_attention",
|
| 68 |
+
"sliding_attention",
|
| 69 |
+
"sliding_attention",
|
| 70 |
+
"full_attention",
|
| 71 |
+
"sliding_attention",
|
| 72 |
+
"sliding_attention",
|
| 73 |
+
"sliding_attention",
|
| 74 |
+
"full_attention",
|
| 75 |
+
"sliding_attention",
|
| 76 |
+
"sliding_attention",
|
| 77 |
+
"sliding_attention",
|
| 78 |
+
"full_attention"
|
| 79 |
+
],
|
| 80 |
+
"load_balance_coeff": 0.00005,
|
| 81 |
+
"max_position_embeddings": 262144,
|
| 82 |
+
"model_type": "afmoe",
|
| 83 |
+
"moe_intermediate_size": 3072,
|
| 84 |
+
"mup_enabled": true,
|
| 85 |
+
"n_group": 1,
|
| 86 |
+
"num_attention_heads": 48,
|
| 87 |
+
"num_dense_layers": 6,
|
| 88 |
+
"num_expert_groups": 1,
|
| 89 |
+
"num_experts": 256,
|
| 90 |
+
"num_experts_per_tok": 4,
|
| 91 |
+
"num_hidden_layers": 60,
|
| 92 |
+
"num_key_value_heads": 8,
|
| 93 |
+
"num_limited_groups": 1,
|
| 94 |
+
"num_shared_experts": 1,
|
| 95 |
+
"rms_norm_eps": 1e-05,
|
| 96 |
+
"rope_scaling": null,
|
| 97 |
+
"rope_theta": 10000,
|
| 98 |
+
"route_norm": true,
|
| 99 |
+
"route_scale": 2.448,
|
| 100 |
+
"score_func": "sigmoid",
|
| 101 |
+
"sliding_window": 4096,
|
| 102 |
+
"tie_word_embeddings": false,
|
| 103 |
+
"topk_group": 1,
|
| 104 |
+
"transformers_version": "4.57.1",
|
| 105 |
+
"use_cache": true,
|
| 106 |
+
"use_grouped_mm": true,
|
| 107 |
+
"vocab_size": 200192
|
| 108 |
+
}
|
configuration_afmoe.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 16 |
+
from transformers.utils import logging
|
| 17 |
+
|
| 18 |
+
logger = logging.get_logger(__name__)
|
| 19 |
+
|
| 20 |
+
class AfmoeConfig(PretrainedConfig):
|
| 21 |
+
"""
|
| 22 |
+
n_group (`int`, *optional*, defaults to 1):
|
| 23 |
+
Number of groups for routed experts.
|
| 24 |
+
topk_group (`int`, *optional*, defaults to 1):
|
| 25 |
+
Number of selected groups for each token(for each token, ensuring the selected experts is only within `topk_group` groups).
|
| 26 |
+
"""
|
| 27 |
+
model_type = "afmoe"
|
| 28 |
+
base_model_pp_plan = {
|
| 29 |
+
"embed_tokens": (["input_ids"], ["inputs_embeds"]),
|
| 30 |
+
"layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
|
| 31 |
+
"norm": (["hidden_states"], ["hidden_states"]),
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
def __init__(
|
| 35 |
+
self,
|
| 36 |
+
num_hidden_layers: int = 32,
|
| 37 |
+
vocab_size: int = 200192,
|
| 38 |
+
hidden_size: int = 2048,
|
| 39 |
+
intermediate_size: int = 6144,
|
| 40 |
+
moe_intermediate_size=1408,
|
| 41 |
+
num_dense_layers=1,
|
| 42 |
+
num_attention_heads=16,
|
| 43 |
+
num_key_value_heads=None,
|
| 44 |
+
head_dim=128,
|
| 45 |
+
hidden_act="silu",
|
| 46 |
+
max_position_embeddings=16384,
|
| 47 |
+
initializer_range=0.02,
|
| 48 |
+
rms_norm_eps=1e-5,
|
| 49 |
+
use_cache=True,
|
| 50 |
+
tie_word_embeddings=False,
|
| 51 |
+
rope_theta=10000.0,
|
| 52 |
+
rope_scaling=None,
|
| 53 |
+
num_experts=64,
|
| 54 |
+
num_experts_per_tok=6,
|
| 55 |
+
num_shared_experts=2,
|
| 56 |
+
num_expert_groups=1,
|
| 57 |
+
num_limited_groups=1,
|
| 58 |
+
score_func="sigmoid",
|
| 59 |
+
route_norm=True,
|
| 60 |
+
route_scale=1.0,
|
| 61 |
+
global_attn_every_n_layers=4,
|
| 62 |
+
sliding_window=1024,
|
| 63 |
+
mup_enabled=False,
|
| 64 |
+
layer_types=None,
|
| 65 |
+
attention_dropout: float = 0.0,
|
| 66 |
+
n_group: int = 1,
|
| 67 |
+
topk_group: int = 1,
|
| 68 |
+
**kwargs,
|
| 69 |
+
):
|
| 70 |
+
self.vocab_size = vocab_size
|
| 71 |
+
self.max_position_embeddings = max_position_embeddings
|
| 72 |
+
self.hidden_size = hidden_size
|
| 73 |
+
self.intermediate_size = intermediate_size
|
| 74 |
+
self.num_hidden_layers = num_hidden_layers
|
| 75 |
+
self.num_dense_layers = num_dense_layers
|
| 76 |
+
self.num_attention_heads = num_attention_heads
|
| 77 |
+
self.head_dim = head_dim
|
| 78 |
+
self.hidden_act = hidden_act
|
| 79 |
+
self.initializer_range = initializer_range
|
| 80 |
+
self.rms_norm_eps = rms_norm_eps
|
| 81 |
+
self.use_cache = use_cache
|
| 82 |
+
self.rope_theta = rope_theta
|
| 83 |
+
self.rope_scaling = rope_scaling
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
# MoE specific
|
| 87 |
+
self.moe_intermediate_size = moe_intermediate_size
|
| 88 |
+
self.num_experts_per_tok = num_experts_per_tok
|
| 89 |
+
self.n_group = n_group
|
| 90 |
+
self.topk_group = topk_group
|
| 91 |
+
self.num_experts = num_experts
|
| 92 |
+
self.num_shared_experts = num_shared_experts
|
| 93 |
+
self.num_expert_groups = num_expert_groups
|
| 94 |
+
self.num_limited_groups = num_limited_groups
|
| 95 |
+
self.score_func = score_func
|
| 96 |
+
self.route_norm = route_norm
|
| 97 |
+
self.route_scale = route_scale
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
# Attention specific
|
| 101 |
+
self.attention_dropout = attention_dropout
|
| 102 |
+
self.global_attn_every_n_layers = global_attn_every_n_layers
|
| 103 |
+
self.sliding_window = sliding_window
|
| 104 |
+
self.layer_types = layer_types
|
| 105 |
+
if self.layer_types is None:
|
| 106 |
+
self.layer_types = [
|
| 107 |
+
"sliding_attention" if bool((i + 1) % global_attn_every_n_layers) else "full_attention" for i in range(self.num_hidden_layers)
|
| 108 |
+
]
|
| 109 |
+
|
| 110 |
+
# muP specific
|
| 111 |
+
self.mup_enabled = mup_enabled
|
| 112 |
+
|
| 113 |
+
if num_key_value_heads is None:
|
| 114 |
+
num_key_value_heads = num_attention_heads
|
| 115 |
+
|
| 116 |
+
self.num_key_value_heads = num_key_value_heads
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
# Validate rope configs
|
| 120 |
+
if self.rope_scaling is not None and "type" in self.rope_scaling:
|
| 121 |
+
self.rope_scaling["rope_type"] = self.rope_scaling["type"]
|
| 122 |
+
|
| 123 |
+
super().__init__(
|
| 124 |
+
tie_word_embeddings=tie_word_embeddings,
|
| 125 |
+
**kwargs,
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
__all__ = ["AfmoeConfig"]
|
model.safetensors.index.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:828acd18c21bd13ecbb88d3ad33db323fa4953d1c52350a5b15ae8c9cd379547
|
| 3 |
+
size 14615220
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": null,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<|begin_of_text|>",
|
| 5 |
+
"clean_up_tokenization_spaces": false,
|
| 6 |
+
"eos_token": "<|im_end|>",
|
| 7 |
+
"fix_mistral_regex": true,
|
| 8 |
+
"is_local": true,
|
| 9 |
+
"local_files_only": true,
|
| 10 |
+
"model_max_length": 65536,
|
| 11 |
+
"pad_token": "<|im_end|>",
|
| 12 |
+
"tokenizer_class": "TokenizersBackend",
|
| 13 |
+
"use_default_system_prompt": false
|
| 14 |
+
}
|