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
| """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)) | |