Instructions to use Caiyun-AI/LoomPythia-2.8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Caiyun-AI/LoomPythia-2.8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Caiyun-AI/LoomPythia-2.8B", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Caiyun-AI/LoomPythia-2.8B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Caiyun-AI/LoomPythia-2.8B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Caiyun-AI/LoomPythia-2.8B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Caiyun-AI/LoomPythia-2.8B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Caiyun-AI/LoomPythia-2.8B
- SGLang
How to use Caiyun-AI/LoomPythia-2.8B 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 "Caiyun-AI/LoomPythia-2.8B" \ --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": "Caiyun-AI/LoomPythia-2.8B", "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 "Caiyun-AI/LoomPythia-2.8B" \ --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": "Caiyun-AI/LoomPythia-2.8B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Caiyun-AI/LoomPythia-2.8B with Docker Model Runner:
docker model run hf.co/Caiyun-AI/LoomPythia-2.8B
LoomPythia-2.8B
LoomPythia-2.8B (2,775,190,944 parameters) is a 2.8B-parameter causal language model with loom attention, pretrained from scratch on 300B tokens of the Pile following the exact training recipe and tokenizer of EleutherAI/pythia-2.8b.
- Paper: Rewirable Circuits in Transformers with Loom Attention (
arXiv:2611.30634) - Code (JAX Training + PyTorch/Triton Fast Inference): https://github.com/Caiyun-AI/LoomFormer
- Comparison model (4-stream mHC): Caiyun-AI/mHC-Pythia-2.8B
Model Summary
LoomPythia-2.8B augments a 32-layer Pythia-style Transformer ($D = 2560$, $n = 32$ heads, $d = 80$) with a per-token matrix memory stream $M_t \in \mathbb{R}^{64 \times 80}$ (d_k = 64 slots). At every token, each attention head performs vertical attention (MRead / MWrite) over earlier heads' outputs stored in $M_t$ to dynamically compose its query, key, value, and local output bypass before performing strictly causal horizontal attention over tokens (with rope_dim = 20 RoPE coordinates per head and full-head QKNorm).
Under a matched parameter count (2.78B) and only +1.95% forward FLOPs over Pythia-2.8B, LoomPythia-2.8B matches Pythia-12B in 0-shot accuracy and surpasses Pythia-12B in 5-shot accuracy across 10 standard LM Evaluation Harness benchmarks:
| Model | Params | Pile ppl β | FLAN ppl β | LAMBADA | PIQA | WinoGrande | ARC-E | ARC-C | SciQ | BoolQ | HellaSwag | RACE-M | RACE-H | Avg (0-shot / 5-shot) β |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Pythia-2.8B | 2.78B | 6.63 | 8.16 | 64.7 | 73.9 | 59.4 | 64.4 | 29.5 | 88.2 | 64.5 | 45.4 | 38.1 | 34.9 | 56.3 / 57.3 |
| Pythia-6.9B | 6.86B | 6.29 | 7.85 | 67.3 | 75.2 | 60.9 | 67.3 | 31.3 | 89.7 | 63.7 | 48.0 | 40.6 | 37.0 | 58.1 / 59.3 |
| mHC-Pythia-2.8B | 2.78B | 6.24 | 7.35 | 68.5 | 74.4 | 62.8 | 67.1 | 30.7 | 90.5 | 66.9 | 47.5 | 42.3 | 37.0 | 58.8 / 59.9 |
| Pythia-12B | 11.85B | 6.01 | 7.26 | 70.5 | 76.0 | 63.9 | 70.2 | 31.8 | 90.2 | 67.4 | 50.3 | 40.6 | 38.3 | 59.9 / 60.8 |
| LoomPythia-2.8B | 2.78B | 6.02 | 6.94 | 71.8 | 74.7 | 63.7 | 68.5 | 31.7 | 92.4 | 65.8 | 49.1 | 42.3 | 39.0 | 59.9 / 61.6 |
(Individual task columns show 0-shot accuracy; last column reports 0-shot / 5-shot 10-task average.)
Quickstart
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "Caiyun-AI/LoomPythia-2.8B"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id, trust_remote_code=True, dtype=torch.bfloat16
).cuda().eval()
inputs = tokenizer("The capital of France is", return_tensors="pt").to("cuda")
with torch.no_grad():
out = model.generate(**inputs, max_new_tokens=32, do_sample=False)
print(tokenizer.decode(out[0], skip_special_tokens=True))
For high-throughput GPU deployment using fused Triton kernels and torch.compile CUDA graphs, see pytorch/fast_inference in the GitHub repository.
Architecture Hyperparameters
| Hyperparameter | Value |
|---|---|
num_hidden_layers ($L$) |
32 |
hidden_size ($D$) |
2560 |
num_attention_heads ($n$) |
32 |
head_dim ($d$) |
80 |
d_k (matrix-memory slots) |
64 |
d_r (shared port bottleneck width) |
640 |
rope_dim ($r$, Q/K RoPE tail) |
20 (full Q/K head width 100) |
intermediate_size (ffn_x, layers 0..30) |
7808 |
last_ffn_x_dim (ffn_x, layer 31) |
9984 |
ffn_m_dim (ffn_m, layers 0..30) |
2944 |
max_position_embeddings |
2048 |
vocab_size |
50304 (GPT-NeoX-20B tokenizer) |
Citation
@article{xiao2026loomformer,
title={Rewirable Circuits in Transformers with Loom Attention},
author={Xiao, Da and Meng, Qingye and Li, Shengping and Yuan, Xingyuan},
journal={arXiv preprint arXiv:2611.30634},
year={2026}
}
- Downloads last month
- 10