Instructions to use bearzi/Trinity-Mini-oQ6 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use bearzi/Trinity-Mini-oQ6 with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("bearzi/Trinity-Mini-oQ6") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- LM Studio
- Pi new
How to use bearzi/Trinity-Mini-oQ6 with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "bearzi/Trinity-Mini-oQ6"
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "bearzi/Trinity-Mini-oQ6" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use bearzi/Trinity-Mini-oQ6 with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "bearzi/Trinity-Mini-oQ6"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default bearzi/Trinity-Mini-oQ6
Run Hermes
hermes
- MLX LM
How to use bearzi/Trinity-Mini-oQ6 with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "bearzi/Trinity-Mini-oQ6"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "bearzi/Trinity-Mini-oQ6" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bearzi/Trinity-Mini-oQ6", "messages": [ {"role": "user", "content": "Hello"} ] }'
| # 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 PretrainedConfig | |
| from transformers.modeling_rope_utils import rope_config_validation | |
| from transformers.configuration_utils import layer_type_validation | |
| from 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"] | |