Text Generation
Transformers
PyTorch
English
experimental
research
bit-level
transformer
reversible
safety
telemetry
language-modeling
Instructions to use WCNegentropy/BitTransformerLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use WCNegentropy/BitTransformerLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="WCNegentropy/BitTransformerLM")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("WCNegentropy/BitTransformerLM", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use WCNegentropy/BitTransformerLM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "WCNegentropy/BitTransformerLM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "WCNegentropy/BitTransformerLM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/WCNegentropy/BitTransformerLM
- SGLang
How to use WCNegentropy/BitTransformerLM 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 "WCNegentropy/BitTransformerLM" \ --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": "WCNegentropy/BitTransformerLM", "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 "WCNegentropy/BitTransformerLM" \ --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": "WCNegentropy/BitTransformerLM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use WCNegentropy/BitTransformerLM with Docker Model Runner:
docker model run hf.co/WCNegentropy/BitTransformerLM
| import io | |
| import time | |
| import contextlib | |
| from pathlib import Path | |
| import sys | |
| import torch | |
| ROOT = Path(__file__).resolve().parents[1] | |
| if str(ROOT) not in sys.path: | |
| sys.path.insert(0, str(ROOT)) | |
| from progressive_scaleup import progressive_scale_up_text | |
| from unified_workflow import run_workflow | |
| from bit_transformer.bit_io import text_to_bits | |
| from bit_transformer.safety import hil_safe_inference | |
| def capture_run(func, *args, **kwargs): | |
| buf = io.StringIO() | |
| start = time.time() | |
| with contextlib.redirect_stdout(buf): | |
| result = func(*args, **kwargs) | |
| duration = time.time() - start | |
| return result, buf.getvalue(), duration | |
| def main() -> None: | |
| summary: list[str] = [] | |
| _, log, dur = capture_run( | |
| progressive_scale_up_text, | |
| improve_thresh=0.01, | |
| steps=10, | |
| width_mult=2.0, | |
| max_len=64, | |
| dataset_size=512, | |
| forward_kwargs={"causal": True}, | |
| ) | |
| summary.append("### Progressive Scale-Up (causal=True)\n") | |
| summary.append(log.strip()) | |
| summary.append(f"Duration: {dur:.2f}s\n") | |
| _, log, dur = capture_run( | |
| progressive_scale_up_text, | |
| improve_thresh=0.01, | |
| steps=10, | |
| width_mult=2.0, | |
| max_len=64, | |
| dataset_size=512, | |
| forward_kwargs={"causal": False}, | |
| ) | |
| summary.append("### Progressive Scale-Up (causal=False)\n") | |
| summary.append(log.strip()) | |
| summary.append(f"Duration: {dur:.2f}s\n") | |
| (model, _), log, dur = capture_run( | |
| run_workflow, | |
| steps=2, | |
| max_len=32, | |
| dataset_size=32, | |
| plateau_steps=1, | |
| epochs_per_step=1, | |
| extra_steps=1, | |
| diffusion=False, | |
| ) | |
| bits = text_to_bits("hi") | |
| tensor = torch.tensor(bits, dtype=torch.long).unsqueeze(0) | |
| out_bits, _ = hil_safe_inference(model, tensor, c_floor=0.0, s_floor=0.0) | |
| summary.append("### Unified Workflow (causal=True)\n") | |
| summary.append(log.strip()) | |
| summary.append(f"Inference on 'hi': {out_bits.squeeze(0).tolist()}\n") | |
| summary.append(f"Duration: {dur:.2f}s\n") | |
| (_, _), log, dur = capture_run( | |
| run_workflow, | |
| steps=2, | |
| max_len=32, | |
| dataset_size=32, | |
| plateau_steps=1, | |
| epochs_per_step=1, | |
| extra_steps=1, | |
| diffusion=True, | |
| ) | |
| summary.append("### Unified Workflow (causal=False / Diffusion)\n") | |
| summary.append(log.strip()) | |
| summary.append(f"Duration: {dur:.2f}s\n") | |
| report = "\n".join(summary) | |
| print(report) | |
| if __name__ == "__main__": | |
| main() | |