Add improved model card with usage example
#1
by
nielsr
HF Staff
- opened
README.md
CHANGED
|
@@ -1,6 +1,51 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pipeline_tag: text-generation
|
| 3 |
+
library_name: transformers
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
---
|
| 6 |
|
| 7 |
+
# PosS: Position Specialist Generates Better Draft for Speculative Decoding
|
| 8 |
|
| 9 |
+
This repository contains the PosS-2 model described in the paper [POSS: Position Specialist Generates Better Draft for Speculative Decoding](https://huggingface.co/papers/2506.03566).
|
| 10 |
+
|
| 11 |
+
**PosS** proposes several Position Specialists, which are responsible for drafting certain positions. They are trained to generate high-quality draft tokens with certain previous deviated features as inputs. During inference time, these Positions Specialists mitigate feature deviations and make accurate predictions even at large positions.
|
| 12 |
+
|
| 13 |
+
<div align="center">
|
| 14 |
+
<img src="assets/method-intro.png" width="60%">
|
| 15 |
+
</div>
|
| 16 |
+
|
| 17 |
+
**PosS** achieves higher **position-wise acceptance rate** *(acceptance rate at a position given its previous positions are accepted)* than previous methods:
|
| 18 |
+
<div align="center">
|
| 19 |
+
<img src="assets/pos-acc-rate.png" width="60%">
|
| 20 |
+
</div>
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
### PosS Weights
|
| 24 |
+
We also provide our trained parameters in Hugging Face:
|
| 25 |
+
|
| 26 |
+
| Base Model | PosS-1 Weights | PosS-2 Weights | PosS-3 Weights |
|
| 27 |
+
| :---------------------- | :----------------------------------------------------- | :----------------------------------------------------- | :----------------------------------------------------- |
|
| 28 |
+
| Llama3-8B-Instruct | [HINT-lab/PosS1-Llama3-8B-Instruct](https://huggingface.co/HINT-lab/PosS1-Llama3-8B-Instruct) | [HINT-lab/PosS2-Llama3-8B-Instruct](https://huggingface.co/HINT-lab/PosS2-Llama3-8B-Instruct) | [HINT-lab/PosS3-Llama3-8B-Instruct](https://huggingface.co/HINT-lab/PosS3-Llama3-8B-Instruct) |
|
| 29 |
+
| Llama2-13B-Chat | [HINT-lab/PosS1-Llama2-13B-Chat](https://huggingface.co/HINT-lab/PosS1-Llama2-13B-Chat) | [HINT-lab/PosS2-Llama2-13B-Chat](https://huggingface.co/HINT-lab/PosS2-Llama2-13B-Chat) | [HINT-lab/PosS3-Llama2-13B-Chat](https://huggingface.co/HINT-lab/PosS3-Llama2-13B-Chat) |
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
### Simplified Inference Example
|
| 33 |
+
|
| 34 |
+
This example uses the `transformers` library. Make sure to install it first (`pip install transformers`).
|
| 35 |
+
|
| 36 |
+
```python
|
| 37 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 38 |
+
import torch
|
| 39 |
+
|
| 40 |
+
model_id = "HINT-lab/PosS2-Llama3-8B-Instruct" # Or choose another PosS model
|
| 41 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
|
| 42 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 43 |
+
|
| 44 |
+
prompt = "The capital of France is"
|
| 45 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 46 |
+
outputs = model.generate(inputs["input_ids"], max_new_tokens=10) # Adjust max_new_tokens as needed
|
| 47 |
+
generated_text = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
|
| 48 |
+
print(generated_text)
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
Code: [https://github.com/shrango/PosS](https://github.com/shrango/PosS)
|