FR-Spec: Accelerating Large-Vocabulary Language Models via Frequency-Ranked Speculative Sampling
Paper • 2502.14856 • Published • 8
How to use thunlp/LLaMA3-Instruct-8B-FR-Spec with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="thunlp/LLaMA3-Instruct-8B-FR-Spec") # Load model directly
from transformers import AutoTokenizer, LlamaForCausalLMEagle
tokenizer = AutoTokenizer.from_pretrained("thunlp/LLaMA3-Instruct-8B-FR-Spec")
model = LlamaForCausalLMEagle.from_pretrained("thunlp/LLaMA3-Instruct-8B-FR-Spec")How to use thunlp/LLaMA3-Instruct-8B-FR-Spec with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "thunlp/LLaMA3-Instruct-8B-FR-Spec"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "thunlp/LLaMA3-Instruct-8B-FR-Spec",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/thunlp/LLaMA3-Instruct-8B-FR-Spec
How to use thunlp/LLaMA3-Instruct-8B-FR-Spec with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "thunlp/LLaMA3-Instruct-8B-FR-Spec" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "thunlp/LLaMA3-Instruct-8B-FR-Spec",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "thunlp/LLaMA3-Instruct-8B-FR-Spec" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "thunlp/LLaMA3-Instruct-8B-FR-Spec",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use thunlp/LLaMA3-Instruct-8B-FR-Spec with Docker Model Runner:
docker model run hf.co/thunlp/LLaMA3-Instruct-8B-FR-Spec
# Load model directly
from transformers import AutoTokenizer, LlamaForCausalLMEagle
tokenizer = AutoTokenizer.from_pretrained("thunlp/LLaMA3-Instruct-8B-FR-Spec")
model = LlamaForCausalLMEagle.from_pretrained("thunlp/LLaMA3-Instruct-8B-FR-Spec")Token frequency statistics based on SlimPajama-627B, used for FR-Spec (https://arxiv.org/abs/2502.14856), see more at https://github.com/thunlp/FR-Spec.
freq_32768.pt can be loaded by torch.load(), and it is a list of high-frequency tokens.
config.json and pytorch_model.bin are the same as https://huggingface.co/yuhuili/EAGLE-LLaMA3-Instruct-8B, and can be downloaded from their repo.
Base model
meta-llama/Meta-Llama-3-8B-Instruct
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="thunlp/LLaMA3-Instruct-8B-FR-Spec")