Text Generation
Transformers
Safetensors
English
llama
small-language-model
slm
from-scratch
tiny
nexus-erebus
arithmetic
text-generation-inference
Instructions to use MaliosDark/Nexus-Erebus-3M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MaliosDark/Nexus-Erebus-3M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MaliosDark/Nexus-Erebus-3M", device_map="auto")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("MaliosDark/Nexus-Erebus-3M") model = AutoModelForCausalLM.from_pretrained("MaliosDark/Nexus-Erebus-3M", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MaliosDark/Nexus-Erebus-3M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MaliosDark/Nexus-Erebus-3M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MaliosDark/Nexus-Erebus-3M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/MaliosDark/Nexus-Erebus-3M
- SGLang
How to use MaliosDark/Nexus-Erebus-3M 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 "MaliosDark/Nexus-Erebus-3M" \ --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": "MaliosDark/Nexus-Erebus-3M", "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 "MaliosDark/Nexus-Erebus-3M" \ --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": "MaliosDark/Nexus-Erebus-3M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use MaliosDark/Nexus-Erebus-3M with Docker Model Runner:
docker model run hf.co/MaliosDark/Nexus-Erebus-3M
File size: 1,805 Bytes
4d848c2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | """Nexus-Erebus digit-atomic, least-significant-digit-first tokenizer.
Digits are never merged by BPE, and every maximal run of digits is reversed at
encode time so the model reads and writes numbers least-significant-digit first.
This aligns carry propagation with the left-to-right direction the model reads,
which is what lets a tiny model do integer arithmetic.
The transform is an involution, so decoding simply applies it again to restore
ordinary left-to-right numbers. Callers see normal text in and normal text out.
Load with:
AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
"""
import re
from transformers import PreTrainedTokenizerFast
_DIGIT_RUN = re.compile(r"\d+")
def rev_digits(text: str) -> str:
"""Reverse each maximal run of digits. Involution: rev(rev(x)) == x."""
return _DIGIT_RUN.sub(lambda m: m.group(0)[::-1], text)
class NexusLSDTokenizer(PreTrainedTokenizerFast):
"""PreTrainedTokenizerFast that applies the LSD-first digit transform."""
def _t(self, x):
if x is None:
return None
if isinstance(x, str):
return rev_digits(x)
if isinstance(x, (list, tuple)):
return type(x)(self._t(i) for i in x)
return x
def _batch_encode_plus(self, batch_text_or_text_pairs, *args, **kwargs):
return super()._batch_encode_plus(self._t(batch_text_or_text_pairs), *args, **kwargs)
def _encode_plus(self, text, text_pair=None, *args, **kwargs):
return super()._encode_plus(self._t(text), self._t(text_pair), *args, **kwargs)
# NOTE: do not override tokenize(); it routes through _encode_plus, so the
# transform would be applied twice and cancel out.
def _decode(self, *args, **kwargs):
return rev_digits(super()._decode(*args, **kwargs))
|