Text Generation
Transformers
Safetensors
English
moeloop
looptitan
mixture-of-experts
Mixture of Experts
custom_code
muon
conversational
Eval Results (legacy)
Instructions to use NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon
- SGLang
How to use NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon 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 "NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon with Docker Model Runner:
docker model run hf.co/NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon
Download memory.py from NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon: direct link, hf CLI and curl.
- Browser
- Download file 2.6 kB
-
https://huggingface.co/NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon/resolve/main/memory.py
- Command line
-
hf download hf://NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon/memory.py
-
curl -L -o memory.py https://huggingface.co/NaturalScale/LoopTitan-MoE12-1.3B-A0.2B-Muon/resolve/main/memory.py
2.6 kB
| """Functional normalized memories; callers own forward and visit resets.""" | |
| from __future__ import annotations | |
| import math | |
| from typing import NamedTuple | |
| from torch import Tensor | |
| class EMACarry(NamedTuple): | |
| """A differentiable numerator and its scalar normalization, never a buffer.""" | |
| numerator: Tensor | None = None | |
| denominator: float = 0.0 | |
| def ema_update(carry: EMACarry, write: Tensor, *, beta: float = .5) -> tuple[EMACarry, Tensor]: | |
| """Return new carry and its updated read without mutating or detaching history. | |
| Start a new forward with ``EMACarry()`` for global memory; separately start | |
| each visit with ``EMACarry()`` for local memory. Add the two returned reads | |
| directly to the residual stream. This function neither combines memories | |
| nor adds a separate attention residual. | |
| Precondition: ``beta`` is finite and in [0, 1); ``ModelConfig`` enforces | |
| this for ``memory_beta``. The carry and write are checked here. | |
| """ | |
| if not isinstance(write, Tensor) or not write.is_floating_point(): | |
| raise ValueError("write must be a floating-point tensor") | |
| numerator, denominator = carry | |
| if type(denominator) not in (int, float) or not math.isfinite(denominator): | |
| raise ValueError("carry denominator must be finite") | |
| if numerator is None: | |
| if denominator != 0: | |
| raise ValueError("empty carry must have zero denominator") | |
| numerator = write | |
| else: | |
| if (denominator <= 0 or numerator.shape != write.shape | |
| or numerator.device != write.device or numerator.dtype != write.dtype): | |
| raise ValueError("carry must have positive normalization and match the write shape/device/dtype") | |
| numerator = beta * numerator + write | |
| denominator = beta * denominator + 1.0 | |
| return EMACarry(numerator, denominator), numerator / denominator | |
| def residual_gain(num_cells: int, num_visits: int, *, scale: float = .5) -> float: | |
| """Scale a residual write by ``scale / (num_visits * sqrt(num_cells))``. | |
| Precondition: positive integer ``num_cells`` and ``num_visits`` and finite | |
| nonnegative ``scale``; ``ModelConfig`` and ``RecursiveLM.forward`` enforce them. | |
| """ | |
| return scale / (num_visits * math.sqrt(num_cells)) | |
| def reinjection_gain(num_cells: int, visit: int, *, scale: float = .5) -> float: | |
| """Gain for a one-based visit >= 2; visit 1 starts from the input itself.""" | |
| if type(visit) is not int or visit < 2: | |
| raise ValueError("reinjection requires a one-based visit >= 2") | |
| return residual_gain(num_cells, visit, scale=scale) | |