Improve model card: add pipeline tag, library name, code link, and usage example
Browse filesThis PR significantly enhances the model card for `ycwu97/mamba2-distilled-small` by:
- Adding the `pipeline_tag: text-generation` to improve discoverability and classification.
- Specifying `library_name: transformers` as evidenced by the `config.json` and GitHub repository's setup, enabling automated "How to use" snippets on the Hub.
- Including a direct link to the GitHub repository.
- Integrating a comprehensive sample usage code snippet, derived from the project's official GitHub repository, demonstrating how to use this model as a draft model within the STree framework.
Please review these changes.
README.md
CHANGED
|
@@ -1,12 +1,61 @@
|
|
| 1 |
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
language:
|
| 4 |
-
- en
|
| 5 |
base_model:
|
| 6 |
- JunxiongWang/Llama3.2-Mamba2-3B-distill
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
---
|
|
|
|
| 8 |
# Description
|
| 9 |
|
| 10 |
2 layer mamba2 models distilled from JunxiongWang/Llama3.2-Mamba2-3B-distill. Early stop at 48000 step.
|
| 11 |
|
| 12 |
-
Used in [STree](https://arxiv.org/abs/2505.14969) as a draft model for speculative decoding for hybrid models.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
| 2 |
base_model:
|
| 3 |
- JunxiongWang/Llama3.2-Mamba2-3B-distill
|
| 4 |
+
language:
|
| 5 |
+
- en
|
| 6 |
+
license: apache-2.0
|
| 7 |
+
pipeline_tag: text-generation
|
| 8 |
+
library_name: transformers
|
| 9 |
---
|
| 10 |
+
|
| 11 |
# Description
|
| 12 |
|
| 13 |
2 layer mamba2 models distilled from JunxiongWang/Llama3.2-Mamba2-3B-distill. Early stop at 48000 step.
|
| 14 |
|
| 15 |
+
Used in [STree: Speculative Tree Decoding for Hybrid State-Space Models](https://arxiv.org/abs/2505.14969) as a draft model for speculative decoding for hybrid models.
|
| 16 |
+
|
| 17 |
+
For more details on installation, training, and evaluation, please refer to the [GitHub repository](https://github.com/wyc1997/stree).
|
| 18 |
+
|
| 19 |
+
## Usage
|
| 20 |
+
|
| 21 |
+
You can use `EaModel.from_pretrained` for accelerated text generation, similar to `generate` from Hugging Face Transformers. Here is an example:
|
| 22 |
+
|
| 23 |
+
```python
|
| 24 |
+
import torch
|
| 25 |
+
from eagle.model.ea_model import EaModel
|
| 26 |
+
from fastchat.model import get_conversation_template
|
| 27 |
+
|
| 28 |
+
# Load the base model and EAGLE acceleration model
|
| 29 |
+
base_model_path = "JunxiongWang/Llama3.2-Mamba2-3B-distill" # Replace with your base model path
|
| 30 |
+
EAGLE_model_path = "ycwu97/mamba2-distilled-small" # Replace with your EAGLE weights path
|
| 31 |
+
|
| 32 |
+
model = EaModel.from_pretrained(
|
| 33 |
+
base_model_path=base_model_path,
|
| 34 |
+
ea_model_path=EAGLE_model_path,
|
| 35 |
+
torch_dtype=torch.float16,
|
| 36 |
+
low_cpu_mem_usage=True,
|
| 37 |
+
device_map="auto",
|
| 38 |
+
total_token=-1 # -1 for auto configuration of draft tokens
|
| 39 |
+
)
|
| 40 |
+
model.eval()
|
| 41 |
+
|
| 42 |
+
# Prepare your message using a conversation template (e.g., Vicuna)
|
| 43 |
+
your_message="Hello"
|
| 44 |
+
conv = get_conversation_template("vicuna") # Use the correct chat template for your base model
|
| 45 |
+
conv.append_message(conv.roles[0], your_message)
|
| 46 |
+
conv.append_message(conv.roles[1], None)
|
| 47 |
+
prompt = conv.get_prompt()
|
| 48 |
+
|
| 49 |
+
# Tokenize the input prompt
|
| 50 |
+
input_ids = model.tokenizer([prompt]).input_ids
|
| 51 |
+
input_ids = torch.as_tensor(input_ids).cuda()
|
| 52 |
+
|
| 53 |
+
# Generate output using EAGLE's accelerated decoding
|
| 54 |
+
output_ids = model.eagenerate(input_ids, temperature=0.5, max_new_tokens=512)
|
| 55 |
+
|
| 56 |
+
# Decode and print the generated text
|
| 57 |
+
output = model.tokenizer.decode(output_ids[0])
|
| 58 |
+
print(output)
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
**Note:** For chat models like Vicuna, LLaMA2-Chat, and LLaMA3-Instruct, you must use the correct chat template to ensure proper model output and EAGLE's performance.
|