Text Generation
Transformers
English
transwave_meyer
causal-lm
byte-level
raw-byte
attention-free
meyer
wavelet
custom_code
Instructions to use Angshul/TransWave with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Angshul/TransWave with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Angshul/TransWave", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Angshul/TransWave", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Angshul/TransWave with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Angshul/TransWave" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Angshul/TransWave", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Angshul/TransWave
- SGLang
How to use Angshul/TransWave 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 "Angshul/TransWave" \ --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": "Angshul/TransWave", "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 "Angshul/TransWave" \ --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": "Angshul/TransWave", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Angshul/TransWave with Docker Model Runner:
docker model run hf.co/Angshul/TransWave
Download smoke_test.py from Angshul/TransWave: direct link, hf CLI and curl.
- Browser
- Download file 2.27 kB
-
https://huggingface.co/Angshul/TransWave/resolve/main/smoke_test.py
- Command line
-
hf download hf://Angshul/TransWave/smoke_test.py
-
curl -L -o smoke_test.py https://huggingface.co/Angshul/TransWave/resolve/main/smoke_test.py
2.27 kB
| from __future__ import annotations | |
| import math | |
| from pathlib import Path | |
| import torch | |
| from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer | |
| ROOT = Path(__file__).resolve().parent | |
| EXPECTED_PARAMS = 96_130_040 | |
| print("1/6 tokenizer load + UTF-8 round trip") | |
| tok = AutoTokenizer.from_pretrained( | |
| ROOT, | |
| trust_remote_code=True, | |
| use_fast=False, | |
| ) | |
| sample = "TransWave — raw bytes ✓" | |
| ids = tok(sample, return_tensors="pt")["input_ids"] | |
| decoded = tok.decode(ids[0].tolist()) | |
| assert decoded == sample, (decoded, sample) | |
| assert tok.vocab_size == 256 | |
| print("2/6 config") | |
| cfg = AutoConfig.from_pretrained(ROOT, trust_remote_code=True) | |
| assert cfg.architecture_id == "causal_transwave_blocklifting_meyer_byte_lm_g4_v2" | |
| assert cfg.trained_context_length == 20480 | |
| assert cfg.vocab_size == 256 | |
| print("3/6 trained checkpoint load") | |
| model = AutoModelForCausalLM.from_pretrained( | |
| ROOT, | |
| trust_remote_code=True, | |
| ).eval() | |
| n = sum(p.numel() for p in model.transwave.parameters()) | |
| assert n == EXPECTED_PARAMS, n | |
| print("4/6 exact finite NLL") | |
| torch.manual_seed(20261012) | |
| x = torch.randint(0, 256, (1, 32), dtype=torch.long) | |
| with torch.no_grad(): | |
| direct = model.transwave.nll(x, checkpoint_layers=False) | |
| wrapped = model(input_ids=x, labels=x).loss | |
| assert torch.isfinite(direct) | |
| assert torch.isfinite(wrapped) | |
| assert abs(float(direct - wrapped)) < 2e-5 | |
| print("NLL:", float(wrapped), "PPL:", math.exp(float(wrapped))) | |
| print("5/6 future-perturbation causality") | |
| a = torch.randint(0, 256, (1, 32), dtype=torch.long) | |
| b = a.clone() | |
| b[:, 16:] = torch.randint(0, 256, b[:, 16:].shape, dtype=torch.long) | |
| with torch.no_grad(): | |
| ca, _ = model.transwave.contexts(a, checkpoint_layers=False) | |
| cb, _ = model.transwave.contexts(b, checkpoint_layers=False) | |
| diff = float((ca[:, :3, :] - cb[:, :3, :]).abs().max()) | |
| assert diff <= 2e-4, diff | |
| print("future->past max diff:", diff) | |
| print("6/6 reference generation") | |
| prompt = tok("abcdefgh", return_tensors="pt")["input_ids"] | |
| with torch.no_grad(): | |
| y = model.generate_bytes(prompt, max_new_tokens=2, do_sample=False) | |
| assert y.shape == (1, 10) | |
| assert int(y.min()) >= 0 and int(y.max()) <= 255 | |
| print("SMOKE TEST: PASS") |