Text Generation
Transformers
Safetensors
mini-beatrix
byte-level
tokenizer-free
aleph
signed-address
custom_code
Instructions to use AbstractPhil/mini-beatrix-1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AbstractPhil/mini-beatrix-1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AbstractPhil/mini-beatrix-1", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("AbstractPhil/mini-beatrix-1", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use AbstractPhil/mini-beatrix-1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AbstractPhil/mini-beatrix-1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AbstractPhil/mini-beatrix-1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/AbstractPhil/mini-beatrix-1
- SGLang
How to use AbstractPhil/mini-beatrix-1 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 "AbstractPhil/mini-beatrix-1" \ --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": "AbstractPhil/mini-beatrix-1", "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 "AbstractPhil/mini-beatrix-1" \ --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": "AbstractPhil/mini-beatrix-1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use AbstractPhil/mini-beatrix-1 with Docker Model Runner:
docker model run hf.co/AbstractPhil/mini-beatrix-1
File size: 2,223 Bytes
b007aec | 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 | """AnchoredBank — the E1-form anchored FFN, born on its own null path.
Bank(x) = trunk(x) + sum_k w_k(x) * sigmoid(g_k) * expert_k(x)
Trunk: always-on d->ff->d GELU expert. Dispatch: the signed aleph address
over a learned K x d codebook read against the layer input (K=3 fat
experts, the shape validated at parity under encoder pressure). Gates
init -3.0; expert OUTPUT projections zero-init, so at birth the dispatch
contributes exactly zero and the bank is bit-identical to its dense
control (the C6 null path). No balance machinery of any kind —
differentiation is an attractor, pressure stays out of the task gradient.
"""
from __future__ import annotations
import torch
import torch.nn as nn
import torch.nn.functional as F
from .address import AlephAddress
class AnchoredBank(nn.Module):
def __init__(self, d: int, n_experts: int = 3, ff: int | None = None,
tau: float = 0.1, gate_init: float = -3.0):
super().__init__()
ff = ff or d
self.n_experts = n_experts
self.t_in = nn.Linear(d, ff, bias=False)
self.t_out = nn.Linear(ff, d, bias=False)
nn.init.orthogonal_(self.t_in.weight)
nn.init.orthogonal_(self.t_out.weight)
self.addr = AlephAddress(n_experts, d, tau)
w_in = torch.empty(n_experts, d, ff)
for k in range(n_experts):
nn.init.orthogonal_(w_in[k])
self.w_in = nn.Parameter(w_in)
self.w_out = nn.Parameter(torch.zeros(n_experts, ff, d)) # null path
self.gates = nn.Parameter(torch.full((n_experts,), gate_init))
self.last_dispatch = None # (mean|w| per expert, w sample) for instruments
def forward(self, x, disable_dispatch: bool = False):
trunk = self.t_out(F.gelu(self.t_in(x)))
if disable_dispatch:
return trunk
w = self.addr.signed(x) # (B, n, K)
with torch.no_grad():
self.last_dispatch = w.detach()
h = F.gelu(torch.einsum("bnd,kdf->bnkf", x, self.w_in))
e = torch.einsum("bnkf,kfd->bnkd", h, self.w_out)
return trunk + torch.einsum("bnk,bnkd->bnd",
w * torch.sigmoid(self.gates), e)
|