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)# pip install -U transformers accelerate # 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: 6,297 Bytes
d47859f bf36780 d47859f bf36780 20fcd3f bf36780 20fcd3f bf36780 20fcd3f bf36780 511072b bf36780 511072b bf36780 511072b bf36780 | 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | """The anchor governor — min-separation projection (2026-08-25).
Measured (aleph-splat-0 TECHNICAL_ROUND5.md, rounds 5e/5f): anchors
crowded past the separation floor flutter under the positional sweep (the
static logit gap is quadratic in separation, the oscillation linear), and the
crowding tail tracks seed fragility. The governor holds the space open FROM
BIRTH — the projection is preventive, not curative (exact lemma: separating an
already-crowded book leaves its flip pattern bit-identical for content already
associated with it).
Form: a post-optimizer-step PROJECTION, never an auxiliary loss — this repo's
standing law ("no balance machinery; pressure stays out of the task gradient",
model/bank.py) is respected because the governor never touches the gradient.
Hub and head codebooks live natively in their own D-dim address space, so the
plain projective form applies (|cos| on RP^(D-1): the read is exactly
invariant under a -> -a). Identity when slack: the batched check is one
matmul per codebook and nothing is written unless a pair violates.
Verified properties (2026-08-25, gov25m rung): fires only when needed
(bit-identical runs when slack), census tail cut 5.4x, fragile-seed function
+.007, stable-seed +.002 — zero cost, no parameters.
"""
from __future__ import annotations
import math
import torch
from .address import AlephAddress
__all__ = ["minsep_project_", "govern_model"]
@torch.no_grad()
def minsep_project_(codebook: torch.nn.Parameter, theta_min_deg: float,
max_iters: int = 8) -> int:
"""Projective min-separation on one (K, D) codebook, in place.
Bound: |cos(a_i, a_j)| <= cos(theta_min) for every pair. Exact symmetric
geodesic push-apart, largest violation first, projected to theta_min +
0.5 deg (the exact-bound push converges asymptotically under fp32 and
can land ~1e-4 over). Returns the number of pair-pushes performed —
0 means the call was a pure read (identity, zero writes).
"""
c_max = math.cos(math.radians(theta_min_deg))
A = torch.nn.functional.normalize(codebook.data.float(), dim=-1)
hits = 0
changed = False
for _ in range(max_iters):
G = A @ A.T
G.fill_diagonal_(0)
viol = (G.abs() > c_max).nonzero()
viol = viol[viol[:, 0] < viol[:, 1]]
if not len(viol):
break
order = G.abs()[viol[:, 0], viol[:, 1]].argsort(descending=True)
for i, j in viol[order].tolist():
g = float(A[i] @ A[j])
if abs(g) <= c_max:
continue
s = 1.0 if g >= 0 else -1.0
b = s * A[j]
gam = math.acos(max(-1.0, min(1.0, float(A[i] @ b))))
if gam < 1e-6: # exact duplicate: nudge first
b = torch.nn.functional.normalize(
b + 1e-3 * torch.randn_like(b), dim=-1)
gam = math.acos(max(-1.0, min(1.0, float(A[i] @ b))))
delta = (math.radians(theta_min_deg + 0.5) - gam) / 2
ai = A[i].clone()
ti = (b - math.cos(gam) * ai) / math.sin(gam)
tj = (ai - math.cos(gam) * b) / math.sin(gam)
A[i] = torch.nn.functional.normalize(
math.cos(delta) * ai - math.sin(delta) * ti, dim=-1)
A[j] = s * torch.nn.functional.normalize(
math.cos(delta) * b - math.sin(delta) * tj, dim=-1)
hits += 1
changed = True
if changed:
codebook.data.copy_(A.to(codebook.dtype))
return hits
def raw_block(wrap):
"""The model's own Block under any depth of adapter wrappers (amoe
BlockWithAdapter nests one wrapper per attached arm: .block.block...)."""
while hasattr(wrap, "block"):
wrap = wrap.block
return wrap
def _hub_addresses(attn):
"""Every AlephAddress a hub carries (single- or multi-constellation)."""
if hasattr(attn, "consts"):
return [c.addr for c in attn.consts]
addr = getattr(attn, "addr", None)
return [addr] if isinstance(addr, AlephAddress) else []
@torch.no_grad()
def govern_model(model, theta_min_deg: float,
include: tuple = ("hub", "head")) -> int:
"""Batched slack check + projection across a model's governed codebooks.
Slack path costs one small matmul per codebook and writes nothing.
Wrapper-aware (amoe BlockWithAdapter moves the block to .block).
`include`: "hub" = attention codebooks, "head" = DualHead, "bank" =
dispatch anchors (K=experts in d_model — never crowds in practice, off
by default).
"""
c_max = math.cos(math.radians(theta_min_deg))
books: list[torch.nn.Parameter] = []
if "hub" in include:
for wrap in getattr(model, "blocks", []):
blk = raw_block(wrap)
if getattr(blk, "is_hub", False):
books += [a.codebook for a in _hub_addresses(blk.attn)]
if "head" in include and hasattr(model, "head"):
addr = getattr(model.head, "addr", None)
if isinstance(addr, AlephAddress):
books.append(addr.codebook)
if "bank" in include:
for wrap in getattr(model, "blocks", []):
blk = raw_block(wrap)
addr = getattr(getattr(blk, "bank", None), "addr", None)
if isinstance(addr, AlephAddress):
books.append(addr.codebook)
# Batched slack check (2026-08-26): group same-shape books into ONE bmm
# and ONE device sync — the per-book loop was 500+ tiny matmuls each
# with a .max() sync on the v2 craft. Only violating books ever enter
# the Python projection.
hits = 0
by_shape: dict = {}
for cb in books:
by_shape.setdefault(tuple(cb.shape), []).append(cb)
for shape, group in by_shape.items():
A = torch.nn.functional.normalize(
torch.stack([cb.data for cb in group]).float(), dim=-1)
G = torch.bmm(A, A.transpose(1, 2)).abs() # (n_books, K, K)
K = shape[0]
eye = torch.eye(K, device=G.device, dtype=torch.bool)
G = G.masked_fill(eye, 0)
worst = G.amax(dim=(1, 2)) # one sync for all
for idx in (worst > c_max).nonzero().flatten().tolist():
hits += minsep_project_(group[idx], theta_min_deg)
return hits
|