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
mirror geolip 0.8.8: relay.py docstring cleanup + from_patchwork rename
Browse files
relay.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
-
"""RelayPatchwork + RelayEMA —
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
slots_t = proj(x_t) (B, n, n_slots, D) orthogonal, no bias
|
| 7 |
f_t = m_hat(slots_t) flattened the reconstructive signed read
|
|
@@ -10,30 +11,25 @@ brought here as a native model component):
|
|
| 10 |
y_t = x_t + sigmoid(gate) * consume(f_t)
|
| 11 |
|
| 12 |
consume = Linear(nD -> hidden), ReLU^2, LayerNorm, Linear(hidden -> d) with the
|
| 13 |
-
output layer zero-initialized (weight AND bias
|
| 14 |
-
|
| 15 |
-
|
| 16 |
|
| 17 |
-
RelayEMA adds
|
| 18 |
-
read, fed to the head through input columns that
|
| 19 |
|
| 20 |
F1_t = (1 - r1) F1_{t-1} + r1 f_t r1 = 1/16
|
| 21 |
F2_t = (1 - r2) F2_{t-1} + r2 f_t r2 = 1/64
|
| 22 |
y_t = x_t + sigmoid(gate) * consume(cat(f_t, F1_t, F2_t))
|
| 23 |
|
| 24 |
-
so at birth RelayEMA's forward
|
| 25 |
-
chunked closed-form scan (ema_chunked, renormalized so q^-t never
|
| 26 |
-
decode carries (F1, F2) state
|
| 27 |
the head is position-wise.
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
rules-shuffled on out-of-vocabulary words (order-invariant; heuristic ceiling
|
| 33 |
-
~.2), 1.000 in-vocabulary. The EMA taps added nothing measurable on that task
|
| 34 |
-
(.527/.587). Packaged with the taps because they are free at birth and the
|
| 35 |
-
accumulator is the certified form. Default geometry below is the validated
|
| 36 |
-
wide arm (n_slots 32, K 64, D 4, hidden 256 at d 1024: 428k params/site).
|
| 37 |
"""
|
| 38 |
from __future__ import annotations
|
| 39 |
|
|
@@ -92,8 +88,8 @@ def _feats(m, x: torch.Tensor) -> torch.Tensor:
|
|
| 92 |
|
| 93 |
|
| 94 |
class RelayPatchwork(nn.Module):
|
| 95 |
-
"""The memory-free
|
| 96 |
-
zero-
|
| 97 |
|
| 98 |
def __init__(self, d: int, spec: RelaySpec | None = None):
|
| 99 |
super().__init__()
|
|
@@ -120,35 +116,36 @@ class RelayPatchwork(nn.Module):
|
|
| 120 |
|
| 121 |
|
| 122 |
class RelayEMA(nn.Module):
|
| 123 |
-
"""
|
| 124 |
-
head to 3nD input columns
|
| 125 |
-
equals the
|
| 126 |
|
| 127 |
def __init__(self, d: int, spec: RelaySpec | None = None):
|
| 128 |
super().__init__()
|
| 129 |
self._widen(RelayPatchwork(d, spec))
|
| 130 |
|
| 131 |
@classmethod
|
| 132 |
-
def
|
| 133 |
-
"""Upgrade a (possibly trained)
|
| 134 |
-
and
|
|
|
|
| 135 |
self = cls.__new__(cls)
|
| 136 |
nn.Module.__init__(self)
|
| 137 |
-
self._widen(
|
| 138 |
return self
|
| 139 |
|
| 140 |
-
def _widen(self,
|
| 141 |
-
self.spec =
|
| 142 |
-
self.nD =
|
| 143 |
-
self.proj, self.addr, self.gate =
|
| 144 |
-
self.n_slots =
|
| 145 |
-
wide = nn.Linear(3 * self.nD,
|
| 146 |
with torch.no_grad():
|
| 147 |
-
wide.weight[:, :self.nD] =
|
| 148 |
wide.weight[:, self.nD:] = 0.0
|
| 149 |
-
wide.bias.copy_(
|
| 150 |
self.consume = nn.Sequential(
|
| 151 |
-
wide,
|
| 152 |
|
| 153 |
def feats(self, x: torch.Tensor) -> torch.Tensor:
|
| 154 |
return _feats(self, x)
|
|
|
|
| 1 |
+
"""RelayPatchwork + RelayEMA — a gated residual patch module over a signed
|
| 2 |
+
address read, and a variant with causal-EMA memory taps.
|
| 3 |
|
| 4 |
+
RelayPatchwork (ported from the amoe-lora adapter of the same name,
|
| 5 |
+
github.com/AbstractEyes/amoe-lora, as a native model component):
|
| 6 |
|
| 7 |
slots_t = proj(x_t) (B, n, n_slots, D) orthogonal, no bias
|
| 8 |
f_t = m_hat(slots_t) flattened the reconstructive signed read
|
|
|
|
| 11 |
y_t = x_t + sigmoid(gate) * consume(f_t)
|
| 12 |
|
| 13 |
consume = Linear(nD -> hidden), ReLU^2, LayerNorm, Linear(hidden -> d) with the
|
| 14 |
+
output layer zero-initialized (weight AND bias), so a fresh module is exactly
|
| 15 |
+
inert: y == x. Gate initialized -3. Reconstructive, never comparative: no
|
| 16 |
+
softmax-over-choices, no argmax, no top-k.
|
| 17 |
|
| 18 |
+
RelayEMA adds one mechanism: two fixed-decay causal EMAs of the module's own
|
| 19 |
+
read, fed to the head through input columns that start at zero —
|
| 20 |
|
| 21 |
F1_t = (1 - r1) F1_{t-1} + r1 f_t r1 = 1/16
|
| 22 |
F2_t = (1 - r2) F2_{t-1} + r2 f_t r2 = 1/64
|
| 23 |
y_t = x_t + sigmoid(gate) * consume(cat(f_t, F1_t, F2_t))
|
| 24 |
|
| 25 |
+
so at birth RelayEMA's forward equals the memory-free RelayPatchwork. Training
|
| 26 |
+
uses the chunked closed-form scan (ema_chunked, renormalized so q^-t never
|
| 27 |
+
overflows); decode carries (F1, F2) state one step at a time — exact, because
|
| 28 |
the head is position-wise.
|
| 29 |
|
| 30 |
+
Defaults are the validated geometry (n_slots 32, K 64, D 4, hidden 256; ~428k
|
| 31 |
+
params at d = 1024). Validation record and trained weights:
|
| 32 |
+
huggingface.co/AbstractPhil/mini-beatrix-2s, arms/btx_e003.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
"""
|
| 34 |
from __future__ import annotations
|
| 35 |
|
|
|
|
| 88 |
|
| 89 |
|
| 90 |
class RelayPatchwork(nn.Module):
|
| 91 |
+
"""The memory-free form: proj -> reconstructive address read ->
|
| 92 |
+
zero-initialized squared-ReLU head, residual write behind a sigmoid gate."""
|
| 93 |
|
| 94 |
def __init__(self, d: int, spec: RelaySpec | None = None):
|
| 95 |
super().__init__()
|
|
|
|
| 116 |
|
| 117 |
|
| 118 |
class RelayEMA(nn.Module):
|
| 119 |
+
"""RelayPatchwork plus the EMA memory taps. Built by widening a patchwork's
|
| 120 |
+
head to 3nD input columns with the added columns zeroed, so at birth the
|
| 121 |
+
forward equals the patchwork it came from (shared weights)."""
|
| 122 |
|
| 123 |
def __init__(self, d: int, spec: RelaySpec | None = None):
|
| 124 |
super().__init__()
|
| 125 |
self._widen(RelayPatchwork(d, spec))
|
| 126 |
|
| 127 |
@classmethod
|
| 128 |
+
def from_patchwork(cls, base: RelayPatchwork) -> "RelayEMA":
|
| 129 |
+
"""Upgrade a (possibly trained) RelayPatchwork in place: shares its
|
| 130 |
+
proj/addr/gate and head tail, widens the head's first layer with
|
| 131 |
+
zeroed columns."""
|
| 132 |
self = cls.__new__(cls)
|
| 133 |
nn.Module.__init__(self)
|
| 134 |
+
self._widen(base)
|
| 135 |
return self
|
| 136 |
|
| 137 |
+
def _widen(self, base: RelayPatchwork):
|
| 138 |
+
self.spec = base.spec
|
| 139 |
+
self.nD = base.nD
|
| 140 |
+
self.proj, self.addr, self.gate = base.proj, base.addr, base.gate
|
| 141 |
+
self.n_slots = base.n_slots
|
| 142 |
+
wide = nn.Linear(3 * self.nD, base.spec.hidden)
|
| 143 |
with torch.no_grad():
|
| 144 |
+
wide.weight[:, :self.nD] = base.consume[0].weight
|
| 145 |
wide.weight[:, self.nD:] = 0.0
|
| 146 |
+
wide.bias.copy_(base.consume[0].bias)
|
| 147 |
self.consume = nn.Sequential(
|
| 148 |
+
wide, base.consume[1], base.consume[2], base.consume[3])
|
| 149 |
|
| 150 |
def feats(self, x: torch.Tensor) -> torch.Tensor:
|
| 151 |
return _feats(self, x)
|