Instructions to use FrontiersMind/Nandi-Mini-150M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use FrontiersMind/Nandi-Mini-150M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="FrontiersMind/Nandi-Mini-150M", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("FrontiersMind/Nandi-Mini-150M", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use FrontiersMind/Nandi-Mini-150M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "FrontiersMind/Nandi-Mini-150M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FrontiersMind/Nandi-Mini-150M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/FrontiersMind/Nandi-Mini-150M
- SGLang
How to use FrontiersMind/Nandi-Mini-150M 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 "FrontiersMind/Nandi-Mini-150M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FrontiersMind/Nandi-Mini-150M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "FrontiersMind/Nandi-Mini-150M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FrontiersMind/Nandi-Mini-150M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use FrontiersMind/Nandi-Mini-150M with Docker Model Runner:
docker model run hf.co/FrontiersMind/Nandi-Mini-150M
Fix configuration_nandi.py: use __init__ instead of @strict /__post_init__ for compatibility with released transformers
Browse files- configuration_nandi.py +67 -58
configuration_nandi.py
CHANGED
|
@@ -1,10 +1,4 @@
|
|
| 1 |
-
#
|
| 2 |
-
# This file was automatically generated from src/transformers/models/nandi/modular_nandi.py.
|
| 3 |
-
# Do NOT edit this file manually as any edits will be overwritten by the generation of
|
| 4 |
-
# the file from the modular. If any change should be done, please apply the change to the
|
| 5 |
-
# modular_nandi.py file directly. One of our CI enforces this.
|
| 6 |
-
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 7 |
-
# Copyright 2026 The HuggingFace Inc. team. All rights reserved.
|
| 8 |
#
|
| 9 |
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 10 |
# you may not use this file except in compliance with the License.
|
|
@@ -18,29 +12,25 @@
|
|
| 18 |
# See the License for the specific language governing permissions and
|
| 19 |
# limitations under the License.
|
| 20 |
|
| 21 |
-
from huggingface_hub.dataclasses import strict
|
| 22 |
-
|
| 23 |
from transformers.configuration_utils import PretrainedConfig
|
| 24 |
-
from transformers.modeling_rope_utils import RopeParameters
|
| 25 |
|
| 26 |
|
| 27 |
-
@strict(accept_kwargs=True)
|
| 28 |
class NandiConfig(PretrainedConfig):
|
| 29 |
r"""
|
|
|
|
|
|
|
| 30 |
Example:
|
| 31 |
|
| 32 |
```python
|
| 33 |
-
>>> from transformers import
|
| 34 |
|
| 35 |
-
>>>
|
| 36 |
-
>>> configuration = NandiConfig()
|
| 37 |
|
| 38 |
-
>>>
|
| 39 |
-
>>> model = NandiForCausalLM(configuration)
|
| 40 |
|
| 41 |
-
>>> # Accessing the model configuration
|
| 42 |
>>> configuration = model.config
|
| 43 |
-
```
|
|
|
|
| 44 |
|
| 45 |
model_type = "nandi"
|
| 46 |
keys_to_ignore_at_inference = ["past_key_values"]
|
|
@@ -55,44 +45,56 @@ class NandiConfig(PretrainedConfig):
|
|
| 55 |
"layers.*.mlp.down_proj": "rowwise",
|
| 56 |
}
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
if self.factorized_embedding and self.embedding_rank <= 0:
|
| 98 |
raise ValueError(
|
|
@@ -100,12 +102,19 @@ class NandiConfig(PretrainedConfig):
|
|
| 100 |
)
|
| 101 |
if self.hidden_size % self.num_attention_heads != 0:
|
| 102 |
raise ValueError(
|
| 103 |
-
f"`hidden_size` ({self.hidden_size}) must be divisible by
|
|
|
|
| 104 |
)
|
| 105 |
if self.layer_sharing_repeats < 1:
|
| 106 |
raise ValueError(f"`layer_sharing_repeats` must be >= 1, got {self.layer_sharing_repeats}.")
|
| 107 |
|
| 108 |
-
super().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
|
| 111 |
__all__ = ["NandiConfig"]
|
|
|
|
| 1 |
+
# Copyright 2026 RTA AI Labs. All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
#
|
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
# you may not use this file except in compliance with the License.
|
|
|
|
| 12 |
# See the License for the specific language governing permissions and
|
| 13 |
# limitations under the License.
|
| 14 |
|
|
|
|
|
|
|
| 15 |
from transformers.configuration_utils import PretrainedConfig
|
|
|
|
| 16 |
|
| 17 |
|
|
|
|
| 18 |
class NandiConfig(PretrainedConfig):
|
| 19 |
r"""
|
| 20 |
+
Configuration class for the Nandi model.
|
| 21 |
+
|
| 22 |
Example:
|
| 23 |
|
| 24 |
```python
|
| 25 |
+
>>> from transformers import AutoConfig, AutoModelForCausalLM
|
| 26 |
|
| 27 |
+
>>> configuration = AutoConfig.from_pretrained("Rta-AILabs/Nandi-150M-remote", trust_remote_code=True)
|
|
|
|
| 28 |
|
| 29 |
+
>>> model = AutoModelForCausalLM.from_pretrained("Rta-AILabs/Nandi-150M-remote", trust_remote_code=True)
|
|
|
|
| 30 |
|
|
|
|
| 31 |
>>> configuration = model.config
|
| 32 |
+
```
|
| 33 |
+
"""
|
| 34 |
|
| 35 |
model_type = "nandi"
|
| 36 |
keys_to_ignore_at_inference = ["past_key_values"]
|
|
|
|
| 45 |
"layers.*.mlp.down_proj": "rowwise",
|
| 46 |
}
|
| 47 |
|
| 48 |
+
def __init__(
|
| 49 |
+
self,
|
| 50 |
+
vocab_size=131072,
|
| 51 |
+
hidden_size=832,
|
| 52 |
+
intermediate_size=2496,
|
| 53 |
+
num_hidden_layers=16,
|
| 54 |
+
num_attention_heads=16,
|
| 55 |
+
num_key_value_heads=4,
|
| 56 |
+
head_dim=None,
|
| 57 |
+
hidden_act="silu",
|
| 58 |
+
max_position_embeddings=2048,
|
| 59 |
+
initializer_range=0.008,
|
| 60 |
+
rms_norm_eps=1e-5,
|
| 61 |
+
use_cache=True,
|
| 62 |
+
pad_token_id=None,
|
| 63 |
+
bos_token_id=1,
|
| 64 |
+
eos_token_id=0,
|
| 65 |
+
pretraining_tp=1,
|
| 66 |
+
tie_word_embeddings=True,
|
| 67 |
+
rope_parameters=None,
|
| 68 |
+
attention_bias=False,
|
| 69 |
+
attention_dropout=0.0,
|
| 70 |
+
mlp_bias=False,
|
| 71 |
+
factorized_embedding=True,
|
| 72 |
+
embedding_rank=196,
|
| 73 |
+
layer_sharing=True,
|
| 74 |
+
layer_sharing_repeats=2,
|
| 75 |
+
**kwargs,
|
| 76 |
+
):
|
| 77 |
+
self.vocab_size = vocab_size
|
| 78 |
+
self.hidden_size = hidden_size
|
| 79 |
+
self.intermediate_size = intermediate_size
|
| 80 |
+
self.num_hidden_layers = num_hidden_layers
|
| 81 |
+
self.num_attention_heads = num_attention_heads
|
| 82 |
+
self.num_key_value_heads = num_key_value_heads if num_key_value_heads is not None else num_attention_heads
|
| 83 |
+
self.head_dim = head_dim if head_dim is not None else hidden_size // num_attention_heads
|
| 84 |
+
self.hidden_act = hidden_act
|
| 85 |
+
self.max_position_embeddings = max_position_embeddings
|
| 86 |
+
self.initializer_range = initializer_range
|
| 87 |
+
self.rms_norm_eps = rms_norm_eps
|
| 88 |
+
self.use_cache = use_cache
|
| 89 |
+
self.pretraining_tp = pretraining_tp
|
| 90 |
+
self.rope_parameters = rope_parameters if rope_parameters is not None else {"rope_theta": 100000.0}
|
| 91 |
+
self.attention_bias = attention_bias
|
| 92 |
+
self.attention_dropout = attention_dropout
|
| 93 |
+
self.mlp_bias = mlp_bias
|
| 94 |
+
self.factorized_embedding = factorized_embedding
|
| 95 |
+
self.embedding_rank = embedding_rank
|
| 96 |
+
self.layer_sharing = layer_sharing
|
| 97 |
+
self.layer_sharing_repeats = layer_sharing_repeats if layer_sharing else 1
|
| 98 |
|
| 99 |
if self.factorized_embedding and self.embedding_rank <= 0:
|
| 100 |
raise ValueError(
|
|
|
|
| 102 |
)
|
| 103 |
if self.hidden_size % self.num_attention_heads != 0:
|
| 104 |
raise ValueError(
|
| 105 |
+
f"`hidden_size` ({self.hidden_size}) must be divisible by "
|
| 106 |
+
f"`num_attention_heads` ({self.num_attention_heads})."
|
| 107 |
)
|
| 108 |
if self.layer_sharing_repeats < 1:
|
| 109 |
raise ValueError(f"`layer_sharing_repeats` must be >= 1, got {self.layer_sharing_repeats}.")
|
| 110 |
|
| 111 |
+
super().__init__(
|
| 112 |
+
pad_token_id=pad_token_id,
|
| 113 |
+
bos_token_id=bos_token_id,
|
| 114 |
+
eos_token_id=eos_token_id,
|
| 115 |
+
tie_word_embeddings=tie_word_embeddings,
|
| 116 |
+
**kwargs,
|
| 117 |
+
)
|
| 118 |
|
| 119 |
|
| 120 |
__all__ = ["NandiConfig"]
|