Text Generation
Transformers
Safetensors
llama
grimboost
speculative-decoding
inference-optimization
confidence-gated
cascading-re-evaluation
local-inference
causal-lm
research
conversational
text-generation-inference
Instructions to use Grimlabs/GrimBoost-01 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Grimlabs/GrimBoost-01 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Grimlabs/GrimBoost-01") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Grimlabs/GrimBoost-01") model = AutoModelForCausalLM.from_pretrained("Grimlabs/GrimBoost-01", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Grimlabs/GrimBoost-01 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Grimlabs/GrimBoost-01" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Grimlabs/GrimBoost-01", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Grimlabs/GrimBoost-01
- SGLang
How to use Grimlabs/GrimBoost-01 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 "Grimlabs/GrimBoost-01" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Grimlabs/GrimBoost-01", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "Grimlabs/GrimBoost-01" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Grimlabs/GrimBoost-01", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Grimlabs/GrimBoost-01 with Docker Model Runner:
docker model run hf.co/Grimlabs/GrimBoost-01
Download tests/test_tokenizer_bytes.py from Grimlabs/GrimBoost-01: direct link, hf CLI and curl.
- Browser
- Download file 2.85 kB
-
https://huggingface.co/Grimlabs/GrimBoost-01/resolve/main/tests/test_tokenizer_bytes.py
- Command line
-
hf download hf://Grimlabs/GrimBoost-01/tests/test_tokenizer_bytes.py
-
curl -L -o test_tokenizer_bytes.py https://huggingface.co/Grimlabs/GrimBoost-01/resolve/main/tests/test_tokenizer_bytes.py
2.85 kB
| import random | |
| from pathlib import Path | |
| import pytest | |
| from grimboost.tokenization.byte_bpe import ByteBPETokenizer, train_byte_bpe | |
| CORPUS = [ | |
| "The quick brown fox jumps over the lazy dog. ", | |
| "def f(x):\n return x + 1\n", | |
| "中文测试:字节级分词必须精确往返。", | |
| "Emoji 🙂🚀 and accents café naïve. ", | |
| "Special markers <|im_start|>user<|im_end|> are ordinary text here. ", | |
| "Tabs\tand multiple spaces and\nnewlines.\n", | |
| ] | |
| def _iter_corpus(): | |
| for _ in range(200): | |
| for line in CORPUS: | |
| yield line | |
| def tokenizer(tmp_path_factory: pytest.TempPathFactory) -> ByteBPETokenizer: | |
| path = tmp_path_factory.mktemp("tok") / "bpe.json" | |
| return train_byte_bpe( | |
| _iter_corpus(), | |
| vocab_size=320, | |
| save_path=path, | |
| min_frequency=1, | |
| ) | |
| def test_roundtrip_all_examples(tokenizer: ByteBPETokenizer): | |
| for text in CORPUS: | |
| ids = tokenizer.encode(text) | |
| assert tokenizer.decode_bytes(ids) == text.encode("utf-8") | |
| assert tokenizer.decode(ids) == text | |
| def test_encode_with_spans(tokenizer: ByteBPETokenizer): | |
| for text in CORPUS: | |
| data = text.encode("utf-8") | |
| ids, spans = tokenizer.encode_with_spans(data) | |
| assert spans[0][0] == 0 | |
| assert spans[-1][1] == len(data) | |
| for (a, b), (c, _) in zip(spans, spans[1:]): | |
| assert b == c | |
| assert b"".join(tokenizer.token_bytes(i) for i in ids) == data | |
| def test_random_unicode_roundtrip(tokenizer: ByteBPETokenizer): | |
| rng = random.Random(0) | |
| alphabet = "abc XYZ\n\t.,!?é中🙂🚀0123456789" | |
| for _ in range(50): | |
| text = "".join(rng.choice(alphabet) for _ in range(rng.randint(1, 80))) | |
| ids = tokenizer.encode(text) | |
| assert tokenizer.decode_bytes(ids) == text.encode("utf-8") | |
| def test_save_load(tokenizer: ByteBPETokenizer, tmp_path: Path): | |
| path = tmp_path / "saved.json" | |
| tokenizer.save(path) | |
| loaded = ByteBPETokenizer.load(path) | |
| text = "roundtrip café 中文 🙂" | |
| assert loaded.decode_bytes(loaded.encode(text)) == text.encode("utf-8") | |
| assert loaded.vocab_size == tokenizer.vocab_size | |
| def test_special_tokens_have_no_bytes(tokenizer: ByteBPETokenizer): | |
| for idx in tokenizer.special_ids: | |
| assert tokenizer.token_bytes(idx) is None | |
| def test_encode_bytes_exact_with_invalid_tail(tokenizer: ByteBPETokenizer): | |
| samples = [ | |
| b"hello \xe4\xb8", # truncated CJK | |
| b"abc\xff\xfe", # invalid bytes | |
| b"abc", | |
| b"\xf0\x9f\x99", # truncated emoji | |
| ] | |
| for data in samples: | |
| ids, spans = tokenizer.encode_bytes_exact(data) | |
| recon = b"".join(tokenizer.token_bytes(i) for i in ids) | |
| assert recon == data | |
| assert spans[0][0] == 0 | |
| assert spans[-1][1] == len(data) | |