Text Generation
Transformers
Safetensors
English
nessim
custom_code
small-language-model
base
pretrained
hybrid
gated-deltanet
looped
Instructions to use Nessim/Nessim-48M-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Nessim/Nessim-48M-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Nessim/Nessim-48M-Base", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Nessim/Nessim-48M-Base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Nessim/Nessim-48M-Base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Nessim/Nessim-48M-Base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Nessim/Nessim-48M-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Nessim/Nessim-48M-Base
- SGLang
How to use Nessim/Nessim-48M-Base 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 "Nessim/Nessim-48M-Base" \ --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": "Nessim/Nessim-48M-Base", "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 "Nessim/Nessim-48M-Base" \ --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": "Nessim/Nessim-48M-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Nessim/Nessim-48M-Base with Docker Model Runner:
docker model run hf.co/Nessim/Nessim-48M-Base
Download configuration_nessim.py from Nessim/Nessim-48M-Base: direct link, hf CLI and curl.
- Browser
- Download file 3.07 kB
-
https://huggingface.co/Nessim/Nessim-48M-Base/resolve/main/configuration_nessim.py
- Command line
-
hf download hf://Nessim/Nessim-48M-Base/configuration_nessim.py
-
curl -L -o configuration_nessim.py https://huggingface.co/Nessim/Nessim-48M-Base/resolve/main/configuration_nessim.py
3.07 kB
| """Configuration of Nessim-48M-Base, a KLM 1.6 based model with a looped core and four token-level programs. | |
| Derived from configuration_klm.py of KLM 1.6 (Apache-2.0, https://huggingface.co/MinimaLabs/KLM-1.6). Changes: the | |
| 24 unshared layers become `n_prelude` + `n_core` + `n_coda` layers with the core applied `loops` times, and the | |
| fields of the four programs (previous-token and induction inputs, copy pointer, distance biases) are added. | |
| This file ships inside the model directory and must not import anything from the training repository. | |
| """ | |
| from __future__ import annotations | |
| from transformers import PretrainedConfig | |
| class NessimConfig(PretrainedConfig): | |
| model_type = "nessim" | |
| def __init__( | |
| self, | |
| vocab_size: int = 4160, | |
| hidden_size: int = 512, | |
| n_prelude: int = 2, | |
| n_core: int = 6, | |
| n_coda: int = 2, | |
| loops: int = 4, | |
| attention_every: int = 4, | |
| gdn_heads: int = 4, | |
| gdn_head_dim: int = 128, | |
| num_attention_heads: int = 8, | |
| num_key_value_heads: int = 4, | |
| intermediate_size: int = 1536, | |
| max_position_embeddings: int = 2048, | |
| rope_theta: float = 10000.0, | |
| n_bigrams: int = 125000, | |
| n_trigrams: int = 38000, | |
| ngram_dim: int = 32, | |
| rms_norm_eps: float = 1e-6, | |
| gdn_norm_eps: float = 1e-5, | |
| decay_floor: float = -20.0, | |
| previous_tokens: int = 2, | |
| induction_inputs: bool = True, | |
| front_rank: int = 32, | |
| copy_pointer: bool = True, | |
| pointer_chunk: int = 128, | |
| distance_bias: bool = True, | |
| bos_token_id: int = 1, | |
| eos_token_id: int = 2, | |
| pad_token_id: int = 0, | |
| tie_word_embeddings: bool = True, | |
| **kwargs, | |
| ): | |
| self.vocab_size = vocab_size | |
| self.hidden_size = hidden_size | |
| self.n_prelude = n_prelude | |
| self.n_core = n_core | |
| self.n_coda = n_coda | |
| self.loops = loops | |
| self.num_hidden_layers = n_prelude + n_core + n_coda | |
| self.attention_every = attention_every | |
| self.gdn_heads = gdn_heads | |
| self.gdn_head_dim = gdn_head_dim | |
| self.num_attention_heads = num_attention_heads | |
| self.num_key_value_heads = num_key_value_heads | |
| self.intermediate_size = intermediate_size | |
| self.max_position_embeddings = max_position_embeddings | |
| self.rope_theta = rope_theta | |
| self.n_bigrams = n_bigrams | |
| self.n_trigrams = n_trigrams | |
| self.ngram_dim = ngram_dim | |
| self.rms_norm_eps = rms_norm_eps | |
| self.gdn_norm_eps = gdn_norm_eps | |
| self.decay_floor = decay_floor | |
| self.previous_tokens = previous_tokens | |
| self.induction_inputs = induction_inputs | |
| self.front_rank = front_rank | |
| self.copy_pointer = copy_pointer | |
| self.pointer_chunk = pointer_chunk | |
| self.distance_bias = distance_bias | |
| super().__init__(bos_token_id=bos_token_id, eos_token_id=eos_token_id, | |
| pad_token_id=pad_token_id, tie_word_embeddings=tie_word_embeddings, **kwargs) | |