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
Update modeling_nandi.py
Browse files- modeling_nandi.py +16 -16
modeling_nandi.py
CHANGED
|
@@ -23,20 +23,20 @@ from collections.abc import Callable
|
|
| 23 |
import torch
|
| 24 |
import torch.nn as nn
|
| 25 |
|
| 26 |
-
from .
|
| 27 |
-
from .
|
| 28 |
-
from .
|
| 29 |
-
from .
|
| 30 |
-
from .
|
| 31 |
-
from .
|
| 32 |
-
from .
|
| 33 |
-
from .
|
| 34 |
-
from .
|
| 35 |
-
from .
|
| 36 |
-
from .
|
| 37 |
-
from .
|
| 38 |
-
from .
|
| 39 |
-
from .
|
| 40 |
from .configuration_nandi import NandiConfig
|
| 41 |
|
| 42 |
|
|
@@ -109,8 +109,8 @@ class NandiRotaryEmbedding(nn.Module):
|
|
| 109 |
|
| 110 |
def rotate_half(x):
|
| 111 |
"""Rotates half the hidden dims of the input."""
|
| 112 |
-
x1 = x[.
|
| 113 |
-
x2 = x[.
|
| 114 |
return torch.cat((-x2, x1), dim=-1)
|
| 115 |
|
| 116 |
|
|
|
|
| 23 |
import torch
|
| 24 |
import torch.nn as nn
|
| 25 |
|
| 26 |
+
from transformers.activations import ACT2FN
|
| 27 |
+
from transformers.cache_utils import Cache, DynamicCache, DynamicLayer
|
| 28 |
+
from transformers.generation import GenerationMixin
|
| 29 |
+
from transformers.integrations import use_kernel_forward_from_hub
|
| 30 |
+
from transformers.masking_utils import create_causal_mask
|
| 31 |
+
from transformers.modeling_layers import GradientCheckpointingLayer
|
| 32 |
+
from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
|
| 33 |
+
from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
|
| 34 |
+
from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
|
| 35 |
+
from transformers.processing_utils import Unpack
|
| 36 |
+
from transformers.utils import TransformersKwargs, auto_docstring
|
| 37 |
+
from transformers.utils.deprecation import deprecate_kwarg
|
| 38 |
+
from transformers.utils.generic import can_return_tuple, merge_with_config_defaults
|
| 39 |
+
from transformers.utils.output_capturing import capture_outputs
|
| 40 |
from .configuration_nandi import NandiConfig
|
| 41 |
|
| 42 |
|
|
|
|
| 109 |
|
| 110 |
def rotate_half(x):
|
| 111 |
"""Rotates half the hidden dims of the input."""
|
| 112 |
+
x1 = x[transformers., : x.shape[-1] // 2]
|
| 113 |
+
x2 = x[transformers., x.shape[-1] // 2 :]
|
| 114 |
return torch.cat((-x2, x1), dim=-1)
|
| 115 |
|
| 116 |
|