Text Generation
Transformers
Safetensors
English
moeloop
looptitan
mixture-of-experts
Mixture of Experts
custom_code
adamw
conversational
Eval Results (legacy)
Instructions to use NaturalScale/LoopTitan-MoE18-Layout-1.3B-A0.2B-AdamW with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NaturalScale/LoopTitan-MoE18-Layout-1.3B-A0.2B-AdamW with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NaturalScale/LoopTitan-MoE18-Layout-1.3B-A0.2B-AdamW", 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-MoE18-Layout-1.3B-A0.2B-AdamW", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NaturalScale/LoopTitan-MoE18-Layout-1.3B-A0.2B-AdamW with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NaturalScale/LoopTitan-MoE18-Layout-1.3B-A0.2B-AdamW" # 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-MoE18-Layout-1.3B-A0.2B-AdamW", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NaturalScale/LoopTitan-MoE18-Layout-1.3B-A0.2B-AdamW
- SGLang
How to use NaturalScale/LoopTitan-MoE18-Layout-1.3B-A0.2B-AdamW 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-MoE18-Layout-1.3B-A0.2B-AdamW" \ --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-MoE18-Layout-1.3B-A0.2B-AdamW", "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-MoE18-Layout-1.3B-A0.2B-AdamW" \ --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-MoE18-Layout-1.3B-A0.2B-AdamW", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NaturalScale/LoopTitan-MoE18-Layout-1.3B-A0.2B-AdamW with Docker Model Runner:
docker model run hf.co/NaturalScale/LoopTitan-MoE18-Layout-1.3B-A0.2B-AdamW
File size: 2,597 Bytes
5576d49 | 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 49 50 51 52 53 54 55 56 57 58 59 60 61 | """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)
|