|
--- |
|
license: apache-2.0 |
|
--- |
|
# EvaByte Model Card |
|
|
|
**EvaByte** is a 6.5B **byte-level language model** built upon an improved architecture with multibyte prediction and EVA -- an efficient attention mechanism designed for scalability and performance. Trained on 1.5T bytes spanning natural language text, math, and code, EvaByte demonstrates the viability of efficient byte-level processing at scale -- rivaling top open-source tokenizer-based LMs using 5x less training data, excelling in coding tasks, and decoding up to 2x faster. |
|
|
|
## Model Resources |
|
|
|
- **Repository:** https://github.com/openevabyte/evabyte |
|
- **Blog:** https://hkunlp.github.io/blog/2024/evabyte |
|
- **Paper:** Coming soon |
|
|
|
## Model Details |
|
|
|
EvaByte is trained using the SambaNova SN30 RDU system with a batch size of 8M bytes and 32K context length. The training process consists of 3 phases: after pre-training on 1.2T bytes (yielding **EvaByte-6.5B-Phase1**), two independent annealing runs (100B and 200B bytes respectively) are conducted with learning rate linearly decayed from 1e-4 to 0. The resulting checkpoints are merged via model soup (**EvaByte-6.5B**), which then undergoes supervised fine-tuning (**EvaByte-6.5B-SFT**). |
|
|
|
| Stage | Model | |
|
|:----- |:-----| |
|
| Base (before annealing) | [EvaByte-6.5B-Phase1](https://huggingface.co./evabyte/EvaByte-6.5B-Phase1) | |
|
| Base | [EvaByte-6.5B](https://huggingface.co./evabyte/EvaByte-6.5B) | |
|
| SFT | [EvaByte-6.5B-SFT](https://huggingface.co./evabyte/EvaByte-6.5B-SFT) <-- you are here | |
|
|
|
|
|
## Usage |
|
|
|
Please note that we do not train the model with a specific system prompt during SFT. |
|
```python |
|
from transformers import AutoTokenizer, AutoModelForCausalLM |
|
import torch |
|
|
|
tokenizer = AutoTokenizer.from_pretrained("evabyte/EvaByte-6.5B-SFT", trust_remote_code=True) |
|
model = AutoModelForCausalLM.from_pretrained("evabyte/EvaByte-6.5B-SFT", torch_dtype=torch.bfloat16, trust_remote_code=True).eval().to("cuda") |
|
|
|
messages = [ |
|
{"role": "user", "content": "Write me an English pangram."} |
|
] |
|
input_ids = tokenizer.apply_chat_template( |
|
messages, |
|
add_generation_prompt=True, |
|
return_tensors="pt", |
|
).to("cuda") |
|
|
|
# byte-by-byte generation |
|
generation_output = model.generate( |
|
input_ids=input_ids, |
|
max_new_tokens=256 |
|
) |
|
# alternatively, use multibyte generation |
|
generation_output = model.multi_byte_generate( |
|
input_ids=input_ids, |
|
max_new_tokens=256 |
|
) |
|
|
|
response = tokenizer.decode( |
|
generation_output[0][input_ids.shape[1]:], |
|
skip_special_tokens=False, |
|
clean_up_tokenization_spaces=False |
|
) |
|
print(response) |
|
``` |
|
We support two modes of generation: |
|
- `model.generate()`: When invoked, the model will generate one byte at a time. This is the default mode of generation with the Huggingface interface. |
|
- `model.multi_byte_generate()`: generate multiple bytes in a single step, adapted from the implementation of [Medusa](https://github.com/FasterDecoding/Medusa). This will be much faster than above and usually yields the same result under the setting of greedy decoding. `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](https://huggingface.co./docs/transformers/v4.47.1/en/internal/generation_utils#transformers.StoppingCriteria) for generation. |
|
- `top_p`: the top-p parameter for sampling. |
|
- `do_sample`: greedy decoding or sampling. |
|
|
|
NOTE: |
|
- `device_map="auto"` is not supported for > 2 GPUs |
|
- Decoding only supports batch size of 1 with `attention_mask=None` for now. |
|
- Only supports `torch_dtype=torch.bfloat16` for now. |
|
|
|
|
|
## Bias, Risks, and Limitations |
|
`EvaByte-6.5B-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. |
|
|
|
## Evaluation |
|
|
|
For detailed evaluation results, please refer to the [blog](https://hkunlp.github.io/blog/2024/evabyte). |
|
|
|
|
|
## Citation |
|
|
|
**BibTeX:** |
|
|
|
``` |
|
@misc{evabyte, |
|
title = {EvaByte: Efficient Byte-level Language Models at Scale}, |
|
url = {}, |
|
author = {Lin Zheng and Xueliang Zhao and Guangtao Wang and Chen Wu and David Dong and Angela Wang and Mingran Wang and Haige Bo and Tony Zhang and Changran Hu and Urmish Thakker and Lingpeng Kong}, |
|
year = {2025} |
|
} |
|
``` |
|
|