Views
No views yet
| Stage | Model |
|---|---|
| Base (before annealing) | EvaByte-Phase1 |
| Base | EvaByte |
| SFT | EvaByte-SFT <-- you are here |
trust_remote_code=True when loading the model (or tokenizer), as our implementation includes custom code.1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4# Load tokenizer and model
5tokenizer = AutoTokenizer.from_pretrained("evabyte/EvaByte-SFT", trust_remote_code=True)
6model = AutoModelForCausalLM.from_pretrained("evabyte/EvaByte-SFT", torch_dtype=torch.bfloat16, trust_remote_code=True).eval().to("cuda")
7
8# Prepare input messages
9messages = [
10 {"role": "user", "content": "Write me an English pangram."}
11]
12input_ids = tokenizer.apply_chat_template(
13 messages,
14 add_generation_prompt=True,
15 return_tensors="pt",
16).to("cuda")
17
18# Byte-by-byte generation (default)
19generation_output = model.generate(
20 input_ids=input_ids,
21 max_new_tokens=256
22)
23# Multibyte generation (faster alternative)
24generation_output = model.multi_byte_generate(
25 input_ids=input_ids,
26 max_new_tokens=256
27)
28
29response = tokenizer.decode(
30 generation_output[0][input_ids.shape[1]:],
31 skip_special_tokens=False,
32 clean_up_tokenization_spaces=False
33)
34print(response)
35# Sample output:
36# An English pangram is a sentence that uses every letter of the alphabet at least once. Here's a simple pangram:\n\n"The quick brown fox jumps over the lazy dog."<|eot_id|>model.generate(): The default generation method compatible with Huggingface transformers library. This approach generates one byte at a time and might be slow.model.multi_byte_generate(): A faster alternative that generates multiple bytes per step and usually yields the same result as model.generate() under greedy decoding, with the implementation adapted from Medusa. model.multi_byte_generate() supports a subset of arguments in model.generate():
input_ids: the input byte ids.temperature: the temperature for sampling.max_length: the maximum length of the generated sequence.max_new_tokens: the maximum number of new bytes to generate.stopping_criteria: the stopping criteria for generation.top_p: the top-p parameter for sampling.do_sample: greedy decoding or sampling.device_map="auto" is not supported for >2 GPUs.attention_mask=None) is supported for decoding.torch_dtype=torch.bfloat16 is required.model.multi_byte_generate() might return extra bytes after the end-of-sequence sentinel, due to the nature of the multibyte decoding. Manual truncation or cleaning may be needed.EvaByte-SFT serves primarily as a demonstration to showcase how the base model of EvaByte can be effectively fine-tuned for chat and instruction-following capabilities. While it shows improved conversational abilities, users should note that it has not undergone specific alignment or incorporated any moderation mechanisms. Like other instruction-tuned models without safety filtering, it can still generate potentially harmful, inappropriate, or factually incorrect content.1@misc{evabyte,
2 title = {EvaByte: Efficient Byte-level Language Models at Scale},
3 url = {https://hkunlp.github.io/blog/2025/evabyte},
4 author = {Lin Zheng and Xueliang Zhao and Guangtao Wang and Chen Wu and David Dong and Angela Wang and Mingran Wang and Yun Du and Haige Bo and Amol Sharma and Bo Li and Kejie Zhang and Changran Hu and Urmish Thakker and Lingpeng Kong},
5 year = {2025}
6}