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)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("FrontiersMind/Nandi-Mini-150M", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- 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 NandiModel.forward: add cache_position for compatibility with released transformers 5.3.0
Browse files353 unmodified lines3543553563573583599 unmodified lines3693703713723733743753763773783793803813823833843853863873 unmodified lines3913923933943953963973986 unmodified lines405406407408409410353 unmodified linesposition_ids: torch.LongTensor | None = None,past_key_values: Cache | None = None,inputs_embeds: torch.FloatTensor | None = None,use_cache: bool | None = None,**kwargs: Unpack[TransformersKwargs],) -> BaseModelOutputWithPast:9 unmodified linesrepeats = self.config.layer_sharing_repeats if self.config.layer_sharing else 1if use_cache and past_key_values is None:# Use lazy DynamicCache (no config) so it grows to accommodate# num_hidden_layers * repeats virtual slots for layer-sharing.past_key_values = DynamicCache()if position_ids is None:past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0position_ids = torch.arange(inputs_embeds.shape[1], device=inputs_embeds.device) + past_seen_tokensposition_ids = position_ids.unsqueeze(0)causal_mask = create_causal_mask(config=self.config,inputs_embeds=inputs_embeds,attention_mask=attention_mask,past_key_values=past_key_values,position_ids=position_ids,)3 unmodified linesfor decoder_layer in self.layers[: self.config.num_hidden_layers]:for repeat_idx in range(repeats):# Each repeat gets its own virtual cache slots offset by num_hidden_layers,# so repeat 0 uses slots 0..N-1 and repeat 1 uses slots N..2N-1, etc.repeat_cache = (_VirtualLayerCache(past_key_values, repeat_idx * self.config.num_hidden_layers)if (past_key_values is not None and repeat_idx > 0)6 unmodified linesposition_ids=position_ids,past_key_values=repeat_cache,use_cache=use_cache,**kwargs,)353 unmodified lines3543553563573583593609 unmodified lines3703713723733743753763773783793803813823833843853863873883893 unmodified lines3933943953963973986 unmodified lines405406407408409410411353 unmodified linesposition_ids: torch.LongTensor | None = None,past_key_values: Cache | None = None,inputs_embeds: torch.FloatTensor | None = None,cache_position: torch.LongTensor | None = None,use_cache: bool | None = None,**kwargs: Unpack[TransformersKwargs],) -> BaseModelOutputWithPast:9 unmodified linesrepeats = self.config.layer_sharing_repeats if self.config.layer_sharing else 1if use_cache and past_key_values is None:past_key_values = DynamicCache()if cache_position is None:past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0cache_position = torch.arange(inputs_embeds.shape[1], device=inputs_embeds.device) + past_seen_tokensif position_ids is None:position_ids = cache_position.unsqueeze(0)causal_mask = create_causal_mask(config=self.config,inputs_embeds=inputs_embeds,attention_mask=attention_mask,cache_position=cache_position,past_key_values=past_key_values,position_ids=position_ids,)3 unmodified linesfor decoder_layer in self.layers[: self.config.num_hidden_layers]:for repeat_idx in range(repeats):repeat_cache = (_VirtualLayerCache(past_key_values, repeat_idx * self.config.num_hidden_layers)if (past_key_values is not None and repeat_idx > 0)6 unmodified linesposition_ids=position_ids,past_key_values=repeat_cache,use_cache=use_cache,cache_position=cache_position,**kwargs,)
modeling_nandi.py+8-7