monology/pile-uncopyrighted
Viewer • Updated • 177M • 59.5k • 174
How to use MiniLLM/VanillaKD-Pretrain-Qwen-1.2B with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="MiniLLM/VanillaKD-Pretrain-Qwen-1.2B")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("MiniLLM/VanillaKD-Pretrain-Qwen-1.2B")
model = AutoModelForCausalLM.from_pretrained("MiniLLM/VanillaKD-Pretrain-Qwen-1.2B", device_map="auto")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use MiniLLM/VanillaKD-Pretrain-Qwen-1.2B with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "MiniLLM/VanillaKD-Pretrain-Qwen-1.2B"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "MiniLLM/VanillaKD-Pretrain-Qwen-1.2B",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/MiniLLM/VanillaKD-Pretrain-Qwen-1.2B
How to use MiniLLM/VanillaKD-Pretrain-Qwen-1.2B with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "MiniLLM/VanillaKD-Pretrain-Qwen-1.2B" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "MiniLLM/VanillaKD-Pretrain-Qwen-1.2B",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "MiniLLM/VanillaKD-Pretrain-Qwen-1.2B" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "MiniLLM/VanillaKD-Pretrain-Qwen-1.2B",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use MiniLLM/VanillaKD-Pretrain-Qwen-1.2B with Docker Model Runner:
docker model run hf.co/MiniLLM/VanillaKD-Pretrain-Qwen-1.2B
# VanillaKD-Pretrain-Qwen-1.2B
[paper](https://arxiv.org/abs/2410.17215) | [code](https://github.com/thu-coai/MiniPLM)
**VanillaKD-Pretrain-Qwen-1.2B** is a 1.2B model with Qwen achitecture pre-trained with vanilla token-level knowledge distillation on [the Pile](https://huggingface.co/datasets/monology/pile-uncopyrighted) for 50B tokens. The teacher model is [Qwen1.5-1.8B](https://huggingface.co/Qwen/Qwen1.5-1.8B).
We also open-source the tokenized [pre-training corpus](https://huggingface.co/datasets/MiniLLM/pile-tokenized) for reproducibility.
**It is used as the baseline for [MiniLLM-Qwen-1.2B](https://huggingface.co/MiniLLM/MiniPLM-Qwen-1.2B)**
## Evaluation
MiniPLM models achieves better performance given the same computation and scales well across model sizes:
<p align='left'>
<img src="https://cdn-uploads.huggingface.co/production/uploads/624ac662102fcdff87be51b9/EOYzajQcwQFT5PobqL3j0.png" width="1000">
</p>
## Other Baselines
+ [Conventional Pre-Training](https://huggingface.co/MiniLLM/Pretrain-Qwen-1.2B)
## Citation
```bibtext
@article{miniplm,
title={MiniPLM: Knowledge Distillation for Pre-Training Language Models},
author={Yuxian Gu and Hao Zhou and Fandong Meng and Jie Zhou and Minlie Huang},
journal={arXiv preprint arXiv:2410.17215},
year={2024}
}