Instructions to use CollectionStudio/Trinity-Large-Preview with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CollectionStudio/Trinity-Large-Preview with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="CollectionStudio/Trinity-Large-Preview", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("CollectionStudio/Trinity-Large-Preview", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("CollectionStudio/Trinity-Large-Preview", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use CollectionStudio/Trinity-Large-Preview with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "CollectionStudio/Trinity-Large-Preview" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CollectionStudio/Trinity-Large-Preview", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/CollectionStudio/Trinity-Large-Preview
- SGLang
How to use CollectionStudio/Trinity-Large-Preview 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 "CollectionStudio/Trinity-Large-Preview" \ --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": "CollectionStudio/Trinity-Large-Preview", "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 "CollectionStudio/Trinity-Large-Preview" \ --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": "CollectionStudio/Trinity-Large-Preview", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use CollectionStudio/Trinity-Large-Preview with Docker Model Runner:
docker model run hf.co/CollectionStudio/Trinity-Large-Preview
Commit ·
76010d8
0
Parent(s):
Duplicate from arcee-ai/Trinity-Large-Preview
Browse filesCo-authored-by: Varun Singh <sapiosaturn@users.noreply.huggingface.co>
Files changed (43)
- .eval_results/mmlu_pro.yamlAdded+8
- .gitattributesAdded+36
- LICENSEAdded+49
- README.mdAdded+226
- chat_template.jinjaAdded+65
- config.jsonAdded+108
- configuration_afmoe.pyAdded+133
- generation_config.jsonAdded+9
- model-00001-of-00031.safetensorsAdded+3
- model-00002-of-00031.safetensorsAdded+3
- model-00003-of-00031.safetensorsAdded+3
- model-00004-of-00031.safetensorsAdded+3
- model-00005-of-00031.safetensorsAdded+3
- model-00006-of-00031.safetensorsAdded+3
- model-00007-of-00031.safetensorsAdded+3
- model-00008-of-00031.safetensorsAdded+3
- model-00009-of-00031.safetensorsAdded+3
- model-00010-of-00031.safetensorsAdded+3
- model-00011-of-00031.safetensorsAdded+3
- model-00012-of-00031.safetensorsAdded+3
- model-00013-of-00031.safetensorsAdded+3
- model-00014-of-00031.safetensorsAdded+3
- model-00015-of-00031.safetensorsAdded+3
- model-00016-of-00031.safetensorsAdded+3
- model-00017-of-00031.safetensorsAdded+3
- model-00018-of-00031.safetensorsAdded+3
- model-00019-of-00031.safetensorsAdded+3
- model-00020-of-00031.safetensorsAdded+3
- model-00021-of-00031.safetensorsAdded+3
- model-00022-of-00031.safetensorsAdded+3
- model-00023-of-00031.safetensorsAdded+3
- model-00024-of-00031.safetensorsAdded+3
- model-00025-of-00031.safetensorsAdded+3
- model-00026-of-00031.safetensorsAdded+3
- model-00027-of-00031.safetensorsAdded+3
- model-00028-of-00031.safetensorsAdded+3
- model-00029-of-00031.safetensorsAdded+3
- model-00030-of-00031.safetensorsAdded+3
- model-00031-of-00031.safetensorsAdded+3
- model.safetensors.index.jsonAdded
- special_tokens_map.jsonAdded+23
- tokenizer.jsonAdded+3
- tokenizer_config.jsonAdded+272
12345678- dataset: id: TIGER-Lab/MMLU-Pro task_id: mmlu_pro value: 75.2 date: '2026-02-03' source: url: https://huggingface.co/arcee-ai/Trinity-Large-Preview name: Model Card123456789101112131415161718192021222324252627282930313233343536*.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 -textsaved_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 -texttokenizer.json filter=lfs diff=lfs merge=lfs -text12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849OpenMDW License Agreement, version 1.1 (OpenMDW-1.1)
By exercising rights granted to you under this agreement, you accept and agreeto its terms.
As used in this agreement, "Model Materials" means the materials provided toyou under this agreement, consisting of: (1) one or more machine learningmodels (including architecture and parameters); and (2) all related artifacts(including associated data, documentation and software) that are provided toyou hereunder.
Subject to your compliance with this agreement, permission is hereby granted,free of charge, to deal in the Model Materials without restriction, includingunder all copyright, patent, database, and trade secret rights included orembodied therein.
If you distribute any portion of the Model Materials, you shall retain in yourdistribution (1) a copy of this agreement, and (2) all copyright notices andother notices of origin included in the Model Materials that are applicable toyour distribution.
If you file, maintain, or voluntarily participate in a lawsuit against anyperson or entity asserting that the Model Materials directly or indirectlyinfringe any patent or copyright, then all rights and grants made to youhereunder are terminated, unless that lawsuit was in response to acorresponding lawsuit first brought against you.
This agreement does not impose any restrictions or obligations with respect toany use, modification, or sharing of any outputs generated by using the ModelMaterials.
THE MODEL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE, TITLE, NONINFRINGEMENT, ACCURACY, OR THEABSENCE OF LATENT OR OTHER DEFECTS OR ERRORS, WHETHER OR NOT DISCOVERABLE, ALLTO THE GREATEST EXTENT PERMISSIBLE UNDER APPLICABLE LAW.
YOU ARE SOLELY RESPONSIBLE FOR (1) CLEARING RIGHTS OF OTHER PERSONS THAT MAYAPPLY TO THE MODEL MATERIALS OR ANY USE THEREOF, INCLUDING WITHOUT LIMITATIONANY PERSON'S COPYRIGHTS OR OTHER RIGHTS INCLUDED OR EMBODIED IN THE MODELMATERIALS; (2) OBTAINING ANY NECESSARY CONSENTS, PERMISSIONS OR OTHER RIGHTSREQUIRED FOR ANY USE OF THE MODEL MATERIALS; OR (3) PERFORMING ANY DUEDILIGENCE OR UNDERTAKING ANY OTHER INVESTIGATIONS INTO THE MODEL MATERIALS ORANYTHING INCORPORATED OR EMBODIED THEREIN.
IN NO EVENT SHALL THE PROVIDERS OF THE MODEL MATERIALS BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OROTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MODEL MATERIALS, THEUSE THEREOF OR OTHER DEALINGS THEREIN.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226---license: otherlanguage:- en- es- fr- de- it- pt- ru- ar- hi- ko- zhlibrary_name: transformersbase_model:- arcee-ai/Trinity-Large-Basearxiv:- 2602.17004license_link: LICENSElicense_name: openmdw-1.1---<!-- markdownlint-disable first-line-h1 --><!-- markdownlint-disable html --><!-- markdownlint-disable no-duplicate-header -->
<div align="center"> <picture> <img src="https://cdn-uploads.huggingface.co/production/uploads/6435718aaaef013d1aec3b8b/i-v1KyAMOW_mgVGeic9WJ.png" alt="Arcee Trinity Large" style="max-width: 100%; height: auto;" > </picture></div><hr>
# Trinity-Large-Preview
## Introduction
Trinity-Large-Preview is a 398B-parameter sparse Mixture-of-Experts (MoE) model with approximately 13B active parameters per token. It is the largest model in Arcee AI's Trinity family, trained on more than 17 trillion tokens and delivering frontier-level performance with strong long-context comprehension.Trinity-Large-Preview is a lightly post-trained model based on Trinity-Large-Base.
Try it at [chat.arcee.ai](http://chat.arcee.ai/)
More details on the training of Trinity Large are available in the [technical report](https://github.com/arcee-ai/trinity-large-tech-report/).
## Model Variants
The Trinity Large family consists of three checkpoints from the same training run:
- **Trinity-Large-Preview** (this release): Lightly post-trained, chat-ready model undergoing active RL- **[Trinity-Large-Thinking](https://huggingface.co/arcee-ai/Trinity-Large-Thinking)**: Reasoning-optimized, agentic post-training with extended chain-of-thought- **[Trinity-Large-TrueBase](https://huggingface.co/arcee-ai/Trinity-Large-TrueBase)**: 10T-token pre-anneal pretraining checkpoint- **[Trinity-Large-Base](https://huggingface.co/arcee-ai/Trinity-Large-Base)**: Full 17T-token pretrained foundation model with mid-training anneals
## Architecture
Trinity-Large-Preview uses a sparse MoE configuration designed to maximize efficiency while maintaining large-scale capacity.
| Hyperparameter | Value ||:---|:---:|| Total parameters | ~398B || Active parameters per token | ~13B || Experts | 256 (1 shared) || Active experts | 4 || Routing strategy | 4-of-256 (1.56% sparsity) || Dense layers | 6 || Pretraining context length | 8,192 || Context length after extension | 512k || Architecture | Sparse MoE (AfmoeForCausalLM) |
## Benchmarks
| Benchmark | Llama 4 Maverick | Trinity-Large Preview ||-----------|------------------|----------------------|| MMLU | 85.5 | 87.2 || MMLU-Pro | 80.5 | 75.2 || GPQA-Diamond | 69.8 | 63.3 || AIME 2025 | 19.3 | 24.0 |
## Training Configuration
### Pretraining
- Training tokens: 17 trillion- Data partner: [Datology](https://www.datologyai.com/)
<div align="center"> <picture> <img src="https://cdn-uploads.huggingface.co/production/uploads/6435718aaaef013d1aec3b8b/sSVjGNHfrJKmQ6w8I18ek.png" style="background-color:ghostwhite;padding:5px;" width="17%" alt="Powered by Datology"> </picture></div>
## Posttraining- This checkpoint was instruction tuned on 20B tokens.
### Infrastructure
- Hardware: 2,048 NVIDIA B300 GPUs- Parallelism: HSDP + Expert Parallelism- Compute partner: [Prime Intellect](https://www.primeintellect.ai/)
<div align="center"> <picture> <img src="https://cdn-avatars.huggingface.co/v1/production/uploads/61e020e4a343274bb132e138/H2mcdPRWtl4iKLd-OYYBc.jpeg" style="background-color:ghostwhite;padding:5px;" width="17%" alt="Powered by Prime Intellect"> </picture></div>
## Usage
### Running our model
- [Transformers](https://huggingface.co/arcee-ai/Trinity-Large-Preview#transformers)- [VLLM](https://huggingface.co/arcee-ai/Trinity-Large-Preview#vllm)- [llama.cpp](https://huggingface.co/arcee-ai/Trinity-Large-Preview#llamacpp)- [LM Studio](https://huggingface.co/arcee-ai/Trinity-Large-Preview#lm-studio)- [API](https://huggingface.co/arcee-ai/Trinity-Large-Preview#api)
### Transformers
Use the `main` transformers branch or pass `trust_remote_code=True` with a released version.
```pythonfrom transformers import AutoTokenizer, AutoModelForCausalLMimport torch
model_id = "arcee-ai/Trinity-Large-Preview"tokenizer = AutoTokenizer.from_pretrained(model_id)model = AutoModelForCausalLM.from_pretrained( model_id, torch_dtype=torch.bfloat16, device_map="auto", trust_remote_code=True)
messages = [ {"role": "user", "content": "Who are you?"},]
input_ids = tokenizer.apply_chat_template( messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
outputs = model.generate( input_ids, max_new_tokens=256, do_sample=True, temperature=0.8, top_k=50, top_p=0.8)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)print(response)```
### VLLM
Supported in VLLM release 0.11.1+
```bashvllm serve arcee-ai/Trinity-Large-Preview \ --dtype bfloat16 \ --enable-auto-tool-choice \ --tool-call-parser hermes```
### llama.cpp
Supported in llama.cpp release b7061+
```bashllama-server -hf arcee-ai/Trinity-Large-Preview-GGUF:q4_k_m```
### LM Studio
Supported in the latest LM Studio runtime. Search for `arcee-ai/Trinity-Large-Preview-GGUF` in Model Search.
### API
Available on OpenRouter:
```bashcurl -X POST "https://openrouter.ai/v1/chat/completions" \ -H "Authorization: Bearer $OPENROUTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "arcee-ai/trinity-large-preview", "messages": [ { "role": "user", "content": "What are some fun things to do in New York?" } ] }'```
## License
Trinity-Large-Preview is released under the OpenMDW License, version 1.1 (OpenMDW-1.1).
## Citation
If you use this model, please cite:
```bibtex@misc{singh2026arceetrinity, title = {Arcee Trinity Large Technical Report}, author = {Varun Singh and Lucas Krauss and Sami Jaghouar and Matej Sirovatka and Charles Goddard and Fares Obied and Jack Min Ong and Jannik Straube and Fern and Aria Harley and Conner Stewart and Colin Kealty and Maziyar Panahi and Simon Kirsten and Anushka Deshpande and Anneketh Vij and Arthur Bresnu and Pranav Veldurthi and Raghav Ravishankar and Hardik Bishnoi and DatologyAI Team and Arcee AI Team and Prime Intellect Team and Mark McQuade and Johannes Hagemann and Lucas Atkins}, year = {2026}, eprint = {2602.17004}, archivePrefix= {arXiv}, primaryClass = {cs.LG}, doi = {10.48550/arXiv.2602.17004}, url = {https://arxiv.org/abs/2602.17004}}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465{{ bos_token }}{%- if tools %} {{- '<|im_start|>system\n' }} {%- if messages[0].role == 'system' %} {{- messages[0].content + '\n\n' }} {%- endif %} {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }} {%- for tool in tools %} {{- "\n" }} {{- tool | tojson }} {%- endfor %} {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}{%- else %} {%- if messages[0].role == 'system' %} {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }} {%- endif %}{%- endif %}{%- for message in messages %} {%- if message.content is string %} {%- set content = message.content %} {%- else %} {%- set content = '' %} {%- endif %} {%- if (message.role == "user") or (message.role == "system" and not loop.first) %} {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }} {%- elif message.role == "assistant" %} {{- '<|im_start|>' + message.role + '\n' }} {% generation %} {{- content}} {%- if message.tool_calls %} {%- for tool_call in message.tool_calls %} {%- if (loop.first and content) or (not loop.first) %} {{- '\n' }} {%- endif %} {%- if tool_call.function %} {%- set tool_call = tool_call.function %} {%- endif %} {{- '<tool_call>\n{"name": "' }} {{- tool_call.name }} {{- '", "arguments": ' }} {%- if tool_call.arguments is string %} {{- tool_call.arguments }} {%- else %} {{- tool_call.arguments | tojson }} {%- endif %} {{- '}\n</tool_call>' }} {%- endfor %} {%- endif %} {{- '<|im_end|>' }} {% endgeneration%} {{- '\n' }} {%- elif message.role == "tool" %} {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %} {{- '<|im_start|>user' }} {%- endif %} {{- '\n<tool_response>\n' }} {{- content }} {{- '\n</tool_response>' }} {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %} {{- '<|im_end|>\n' }} {%- endif %} {%- endif %}{%- endfor %}{%- if add_generation_prompt %} {{- '<|im_start|>assistant\n' }}{%- endif %}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108{ "architectures": [ "AfmoeForCausalLM" ], "attention_dropout": 0.0, "auto_map": { "AutoConfig": "configuration_afmoe.AfmoeConfig", "AutoModel": "modeling_afmoe.AfmoeModel", "AutoModelForCausalLM": "modeling_afmoe.AfmoeForCausalLM" }, "dtype": "bfloat16", "global_attn_every_n_layers": 4, "head_dim": 128, "hidden_act": "silu", "hidden_size": 3072, "initializer_range": 0.02, "intermediate_size": 12288, "layer_types": [ "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention" ], "load_balance_coeff": 0.00005, "max_position_embeddings": 262144, "model_type": "afmoe", "moe_intermediate_size": 3072, "mup_enabled": true, "n_group": 1, "num_attention_heads": 48, "num_dense_layers": 6, "num_expert_groups": 1, "num_experts": 256, "num_experts_per_tok": 4, "num_hidden_layers": 60, "num_key_value_heads": 8, "num_limited_groups": 1, "num_shared_experts": 1, "rms_norm_eps": 1e-05, "rope_scaling": null, "rope_theta": 10000, "route_norm": true, "route_scale": 2.448, "score_func": "sigmoid", "sliding_window": 4096, "tie_word_embeddings": false, "topk_group": 1, "transformers_version": "4.57.1", "use_cache": true, "use_grouped_mm": true, "vocab_size": 200192}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133# coding=utf-8# Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.from transformers.configuration_utils import PretrainedConfigfrom transformers.modeling_rope_utils import rope_config_validationfrom transformers.configuration_utils import layer_type_validationfrom transformers.utils import logging
logger = logging.get_logger(__name__)
class AfmoeConfig(PretrainedConfig): """ n_group (`int`, *optional*, defaults to 1): Number of groups for routed experts. topk_group (`int`, *optional*, defaults to 1): Number of selected groups for each token(for each token, ensuring the selected experts is only within `topk_group` groups). """ model_type = "afmoe" base_model_pp_plan = { "embed_tokens": (["input_ids"], ["inputs_embeds"]), "layers": (["hidden_states", "attention_mask"], ["hidden_states"]), "norm": (["hidden_states"], ["hidden_states"]), }
def __init__( self, num_hidden_layers: int = 32, vocab_size: int = 200192, hidden_size: int = 2048, intermediate_size: int = 6144, moe_intermediate_size=1408, num_dense_layers=1, num_attention_heads=16, num_key_value_heads=None, head_dim=128, hidden_act="silu", max_position_embeddings=16384, initializer_range=0.02, rms_norm_eps=1e-5, use_cache=True, tie_word_embeddings=False, rope_theta=10000.0, rope_scaling=None, num_experts=64, num_experts_per_tok=6, num_shared_experts=2, num_expert_groups=1, num_limited_groups=1, score_func="sigmoid", route_norm=True, route_scale=1.0, global_attn_every_n_layers=4, sliding_window=1024, mup_enabled=False, layer_types=None, attention_dropout: float = 0.0, n_group: int = 1, topk_group: int = 1, **kwargs, ): self.vocab_size = vocab_size self.max_position_embeddings = max_position_embeddings self.hidden_size = hidden_size self.intermediate_size = intermediate_size self.num_hidden_layers = num_hidden_layers self.num_dense_layers = num_dense_layers self.num_attention_heads = num_attention_heads self.head_dim = head_dim self.hidden_act = hidden_act self.initializer_range = initializer_range self.rms_norm_eps = rms_norm_eps self.use_cache = use_cache self.rope_theta = rope_theta self.rope_scaling = rope_scaling
# MoE specific self.moe_intermediate_size = moe_intermediate_size self.num_experts_per_tok = num_experts_per_tok self.n_group = n_group self.topk_group = topk_group self.num_experts = num_experts self.num_shared_experts = num_shared_experts self.num_expert_groups = num_expert_groups self.num_limited_groups = num_limited_groups self.score_func = score_func self.route_norm = route_norm self.route_scale = route_scale
# Attention specific self.attention_dropout = attention_dropout self.global_attn_every_n_layers = global_attn_every_n_layers self.sliding_window = sliding_window self.layer_types = layer_types if self.layer_types is None: self.layer_types = [ "sliding_attention" if bool((i + 1) % global_attn_every_n_layers) else "full_attention" for i in range(self.num_hidden_layers) ] layer_type_validation(self.layer_types)
# muP specific self.mup_enabled = mup_enabled
if num_key_value_heads is None: num_key_value_heads = num_attention_heads
self.num_key_value_heads = num_key_value_heads
# Validate rope configs if self.rope_scaling is not None and "type" in self.rope_scaling: self.rope_scaling["rope_type"] = self.rope_scaling["type"] rope_config_validation(self)
super().__init__( tie_word_embeddings=tie_word_embeddings, **kwargs, )
__all__ = ["AfmoeConfig"]123456789{ "_from_model_config": true, "bos_token_id": 0, "eos_token_id": 3, "pad_token_id": 12, "transformers_version": "4.57.3", "temperature": 0.8, "top_p": 0.8}123version https://git-lfs.github.com/spec/v1oid sha256:abc9e696257c4d65fa11f392129c3dfecaaa2fe3c4a572f73840ee88ad6221fbsize 2459965736123version https://git-lfs.github.com/spec/v1oid sha256:cf0a02920bc6750b2397e2bf4d82a922404504404f8efe46ad2c8bb1c7d897e9size 704696408123version https://git-lfs.github.com/spec/v1oid sha256:529bec08d7558b4b028bb25dc31333d9b3118e43254b0d7f2a49a4b3e925efc4size 704696408123version https://git-lfs.github.com/spec/v1oid sha256:c6d4b3c832b7ae965286b209a664f0f3b51912ea5157c00ae6b88ee4048e4dd7size 704696408123version https://git-lfs.github.com/spec/v1oid sha256:e5c39a196e257c98f6159a8e63f33a8fe083f11e79668683b476bffb1c3cec22size 29359328160123version https://git-lfs.github.com/spec/v1oid sha256:fe19dbdb61db4e880e4ee22c706d2944a518f8e14f00c5015730dd76c949f7b3size 29359328160123version https://git-lfs.github.com/spec/v1oid sha256:7ad6b0fdf1b740419194c24516a5548190828c6faa0d0d6e51decf2799d8c985size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:7940b25ac61c123cf37931c5c5624f5fb04496c134417d9aaef19cd92681be70size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:dc7453c0e5368ab1cc12a1c200fdaba13d5b1331d467f30971f0fe1777531042size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:85fec4b1a26b292c72140de3a32ae873c377a199009638a3ddeba9d1d6bc88d5size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:2ec54b656ed08c9210366041ca515112c8a965d74987560930d75a41e609b4e0size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:807c63d689ef1adf90c201b8c40e94578bea20f746c56419e4e630bd3ffabc5esize 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:4de01f641aef864e9a380fd214311342a5befc700076e4cc2590713a317a5c63size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:732fa9c1586a8f43ee3bbe8364c9d7496bec04283800fc936c843e49dc649c24size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:c24d9f2ed114cf1b2739f6e622fa50a6cfb963f1d93a412b09ed0635195e924fsize 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:b2cbd47b5b38bfffab863bbd76aedff6aeafd8d5b9af118f0cd9c1d09843fa32size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:c099081adcc09e4473609edb1a8069cf3de243ca601241e81f273eb5410d740asize 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:0c53be7c5101d32d7fe2d832929049a759ea55d340d2cdb11fff194619561231size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:6c4df3f75451b5740aa2bea3b1f9fcc0c6597ec773535f996c1c7c5eeb1569e1size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:c107c2f427a96a8620212884298a5e9850e5ba02b5a310c8a27d187b99a411a6size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:bbbe80752f0972113f6facb2a928553721117382f2ff0dce825cc73e21b8923fsize 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:c82e838e032f638647abba7c89cea19bfe08ba59054927af2a0191327acd1608size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:a4b1fb43b32bf1025453c7305681d15abe6294c0ab14f522a6e8c8a13a5f734dsize 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:474000b92f3b48bfdde560b4191cb7588413ece620948b711e8b0b06c953b1a8size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:2e08d4238d940872960fba67bc202c24268846f1f729bcbe7c201b8479b4708dsize 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:f9f2d5aa61254e42fd8fdf85eb7f0dcc69479000d82649290699c8f494282c55size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:ca2aa10c0058b264b7b4cd74e108052343bf1a9e8f1896b7cdd6a99e73a96b08size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:310cc910bb25f4f4b8bee46e141c807bbde00dac01b7efaeda669bbd950c3754size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:be34656154e1080a42824405e8386f20013c7bc78d080c975efe8c0ac8779903size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:63f091ec2d3a50a7f5286a017bc81623a7b6d286b361d5f765ee8c0dbb02d2d3size 29359329728123version https://git-lfs.github.com/spec/v1oid sha256:d4cb9e764f53af90b44e1938105f56ce8282381d009d2c019c07de3063b27027size 293593297281234567891011121314151617181920212223{ "bos_token": { "content": "<|begin_of_text|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "eos_token": { "content": "<|im_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "pad_token": { "content": "<|pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }}123version https://git-lfs.github.com/spec/v1oid sha256:4d864fe0d9c300d44c54006f5960548946d507d8ec05a082a3bff3e49de58208size 14614721123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272{ "add_bos_token": false, "add_eos_token": false, "add_prefix_space": null, "added_tokens_decoder": { "0": { "content": "<|begin_of_text|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "1": { "content": "<|end_of_text|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "2": { "content": "<|im_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "3": { "content": "<|im_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "4": { "content": "<|eot_id|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "5": { "content": "<|start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "6": { "content": "<|channel|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "7": { "content": "<|message|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "8": { "content": "<|end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "9": { "content": "<|fitm_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "10": { "content": "<|fitm_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "11": { "content": "<|fitm_hole|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "12": { "content": "<|pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "13": { "content": "<think>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "14": { "content": "</think>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "15": { "content": "<tools>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "16": { "content": "</tools>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "17": { "content": "<tool_call>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "18": { "content": "</tool_call>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "19": { "content": "<tool_response>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "20": { "content": "</tool_response>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "21": { "content": "<|reserved_special_8|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "22": { "content": "<|reserved_special_9|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "23": { "content": "<|reserved_special_10|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "24": { "content": "<|reserved_special_11|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "25": { "content": "<|reserved_special_12|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "26": { "content": "<|reserved_special_13|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "27": { "content": "<|reserved_special_14|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "28": { "content": "<|reserved_special_15|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "29": { "content": "<|reserved_special_16|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "30": { "content": "<|reserved_special_17|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "31": { "content": "<|reserved_special_18|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true } }, "bos_token": "<|begin_of_text|>", "clean_up_tokenization_spaces": false, "eos_token": "<|im_end|>", "extra_special_tokens": {}, "model_max_length": 65536, "pad_token": "<|pad|>", "tokenizer_class": "PreTrainedTokenizerFast", "use_default_system_prompt": false, "chat_template": "{{ bos_token }}{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0].role == 'system' %}\n {{- messages[0].content + '\\n\\n' }}\n {%- endif %}\n {{- \"# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0].content + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- for message in messages %}\n {%- if message.content is string %}\n {%- set content = message.content %}\n {%- else %}\n {%- set content = '' %}\n {%- endif %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) %}\n {{- '<|im_start|>' + message.role + '\\n' + content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {{- '<|im_start|>' + message.role + '\\n' }}\n {{- content}}\n {%- if message.tool_calls %}\n {%- for tool_call in message.tool_calls %}\n {%- if (loop.first and content) or (not loop.first) %}\n {{- '\\n' }}\n {%- endif %}\n {%- if tool_call.function %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {%- if tool_call.arguments is string %}\n {{- tool_call.arguments }}\n {%- else %}\n {{- tool_call.arguments | tojson }}\n {%- endif %}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>' }}\n {{- '\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n{%- endif %}"}.eval_results/mmlu_pro.yamlAdded+8
.gitattributesAdded+36
LICENSEAdded+49
README.mdAdded+226
chat_template.jinjaAdded+65
config.jsonAdded+108
configuration_afmoe.pyAdded+133
generation_config.jsonAdded+9
model-00001-of-00031.safetensorsAdded+3
model-00002-of-00031.safetensorsAdded+3
model-00003-of-00031.safetensorsAdded+3
model-00004-of-00031.safetensorsAdded+3
model-00005-of-00031.safetensorsAdded+3
model-00006-of-00031.safetensorsAdded+3
model-00007-of-00031.safetensorsAdded+3
model-00008-of-00031.safetensorsAdded+3
model-00009-of-00031.safetensorsAdded+3
model-00010-of-00031.safetensorsAdded+3
model-00011-of-00031.safetensorsAdded+3
model-00012-of-00031.safetensorsAdded+3
model-00013-of-00031.safetensorsAdded+3
model-00014-of-00031.safetensorsAdded+3
model-00015-of-00031.safetensorsAdded+3
model-00016-of-00031.safetensorsAdded+3
model-00017-of-00031.safetensorsAdded+3
model-00018-of-00031.safetensorsAdded+3
model-00019-of-00031.safetensorsAdded+3
model-00020-of-00031.safetensorsAdded+3
model-00021-of-00031.safetensorsAdded+3
model-00022-of-00031.safetensorsAdded+3
model-00023-of-00031.safetensorsAdded+3
model-00024-of-00031.safetensorsAdded+3
model-00025-of-00031.safetensorsAdded+3
model-00026-of-00031.safetensorsAdded+3
model-00027-of-00031.safetensorsAdded+3
model-00028-of-00031.safetensorsAdded+3
model-00029-of-00031.safetensorsAdded+3
model-00030-of-00031.safetensorsAdded+3
model-00031-of-00031.safetensorsAdded+3
model.safetensors.index.jsonAdded
special_tokens_map.jsonAdded+23
tokenizer.jsonAdded+3
tokenizer_config.jsonAdded+272