Text Generation
Transformers
Safetensors
PyTorch
Kashmiri
ksbyte
kashmiri
byte-level
causal-lm
spacebyte
custom_code
Eval Results (legacy)
Instructions to use Omarrran/ks-byte-lm-spacebyte-transformers with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Omarrran/ks-byte-lm-spacebyte-transformers with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Omarrran/ks-byte-lm-spacebyte-transformers", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Omarrran/ks-byte-lm-spacebyte-transformers", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Omarrran/ks-byte-lm-spacebyte-transformers with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Omarrran/ks-byte-lm-spacebyte-transformers" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Omarrran/ks-byte-lm-spacebyte-transformers", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Omarrran/ks-byte-lm-spacebyte-transformers
- SGLang
How to use Omarrran/ks-byte-lm-spacebyte-transformers 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 "Omarrran/ks-byte-lm-spacebyte-transformers" \ --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": "Omarrran/ks-byte-lm-spacebyte-transformers", "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 "Omarrran/ks-byte-lm-spacebyte-transformers" \ --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": "Omarrran/ks-byte-lm-spacebyte-transformers", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Omarrran/ks-byte-lm-spacebyte-transformers with Docker Model Runner:
docker model run hf.co/Omarrran/ks-byte-lm-spacebyte-transformers
| """Evaluation utilities: held-out loss -> bits-per-byte and word perplexity. | |
| `estimate_loss` is used inside the training loop (cheap, fixed #micro-batches). | |
| `evaluate_split` produces a final report dict for a whole split. | |
| """ | |
| from __future__ import annotations | |
| from typing import Dict | |
| import torch | |
| from .config import ByteLMConfig | |
| from .data import ByteDataset | |
| from .metrics import bpb_from_nats, word_ppl_from_bpb | |
| def estimate_loss(model, dataset: ByteDataset, cfg: ByteLMConfig, | |
| device, iters: int, autocast_ctx) -> Dict[str, float]: | |
| """Mean CE loss (nats/byte) over `iters` random micro-batches -> BPB/ppl.""" | |
| was_training = model.training | |
| model.eval() | |
| losses = torch.zeros(iters) | |
| for i in range(iters): | |
| batch = dataset.get_batch(device) | |
| with autocast_ctx(): | |
| _, _, parts = model(batch["x"], batch["y"], | |
| batch.get("seg_ids"), batch.get("pos_ids")) | |
| losses[i] = parts["ce"] | |
| if was_training: | |
| model.train() | |
| ce = losses.mean().item() | |
| bpb = bpb_from_nats(ce) | |
| return {"ce": ce, "bpb": bpb} | |
| def attach_word_ppl(report: Dict[str, float], meta: dict) -> Dict[str, float]: | |
| bpw = meta.get("bytes_per_word") | |
| if bpw and bpw == bpw: # not NaN | |
| report["word_ppl"] = word_ppl_from_bpb(report["bpb"], bpw) | |
| return report | |
| def evaluate_split(model, cfg: ByteLMConfig, split: str, device, | |
| autocast_ctx, iters: int, meta: dict) -> Dict[str, float]: | |
| ds = ByteDataset(cfg, split) | |
| rep = estimate_loss(model, ds, cfg, device, iters, autocast_ctx) | |
| return attach_word_ppl(rep, meta) | |