Text Generation
Transformers
Safetensors
English
qwen2
llama-factory
full
Generated from Trainer
conversational
text-generation-inference
Instructions to use thu-ml/STAIR-Qwen2-7B-SFT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use thu-ml/STAIR-Qwen2-7B-SFT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="thu-ml/STAIR-Qwen2-7B-SFT") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("thu-ml/STAIR-Qwen2-7B-SFT") model = AutoModelForCausalLM.from_pretrained("thu-ml/STAIR-Qwen2-7B-SFT", 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use thu-ml/STAIR-Qwen2-7B-SFT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "thu-ml/STAIR-Qwen2-7B-SFT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thu-ml/STAIR-Qwen2-7B-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/thu-ml/STAIR-Qwen2-7B-SFT
- SGLang
How to use thu-ml/STAIR-Qwen2-7B-SFT with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "thu-ml/STAIR-Qwen2-7B-SFT" \ --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": "thu-ml/STAIR-Qwen2-7B-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
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 "thu-ml/STAIR-Qwen2-7B-SFT" \ --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": "thu-ml/STAIR-Qwen2-7B-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use thu-ml/STAIR-Qwen2-7B-SFT with Docker Model Runner:
docker model run hf.co/thu-ml/STAIR-Qwen2-7B-SFT
| {"current_steps": 30, "total_steps": 468, "loss": 1.4404, "learning_rate": 4.94947663010567e-06, "epoch": 0.192, "percentage": 6.41, "elapsed_time": "0:02:03", "remaining_time": "0:30:00"} | |
| {"current_steps": 60, "total_steps": 468, "loss": 1.2087, "learning_rate": 4.799948609147061e-06, "epoch": 0.384, "percentage": 12.82, "elapsed_time": "0:04:01", "remaining_time": "0:27:25"} | |
| {"current_steps": 90, "total_steps": 468, "loss": 1.1543, "learning_rate": 4.5574596647341414e-06, "epoch": 0.576, "percentage": 19.23, "elapsed_time": "0:05:53", "remaining_time": "0:24:44"} | |
| {"current_steps": 120, "total_steps": 468, "loss": 1.1191, "learning_rate": 4.231810883773999e-06, "epoch": 0.768, "percentage": 25.64, "elapsed_time": "0:08:40", "remaining_time": "0:25:10"} | |
| {"current_steps": 150, "total_steps": 468, "loss": 1.1091, "learning_rate": 3.836164565319503e-06, "epoch": 0.96, "percentage": 32.05, "elapsed_time": "0:10:39", "remaining_time": "0:22:34"} | |
| {"current_steps": 180, "total_steps": 468, "loss": 1.0086, "learning_rate": 3.386512217606339e-06, "epoch": 1.152, "percentage": 38.46, "elapsed_time": "0:12:34", "remaining_time": "0:20:07"} | |
| {"current_steps": 210, "total_steps": 468, "loss": 0.984, "learning_rate": 2.9010282021444008e-06, "epoch": 1.3439999999999999, "percentage": 44.87, "elapsed_time": "0:15:15", "remaining_time": "0:18:44"} | |
| {"current_steps": 240, "total_steps": 468, "loss": 0.9717, "learning_rate": 2.399335149726463e-06, "epoch": 1.536, "percentage": 51.28, "elapsed_time": "0:17:07", "remaining_time": "0:16:16"} | |
| {"current_steps": 270, "total_steps": 468, "loss": 0.9689, "learning_rate": 1.9017108392811065e-06, "epoch": 1.728, "percentage": 57.69, "elapsed_time": "0:19:05", "remaining_time": "0:14:00"} | |
| {"current_steps": 300, "total_steps": 468, "loss": 0.9723, "learning_rate": 1.4282685964923643e-06, "epoch": 1.92, "percentage": 64.1, "elapsed_time": "0:21:06", "remaining_time": "0:11:49"} | |
| {"current_steps": 330, "total_steps": 468, "loss": 0.9206, "learning_rate": 9.981443394050525e-07, "epoch": 2.112, "percentage": 70.51, "elapsed_time": "0:23:47", "remaining_time": "0:09:57"} | |
| {"current_steps": 360, "total_steps": 468, "loss": 0.8778, "learning_rate": 6.28723129572247e-07, "epoch": 2.304, "percentage": 76.92, "elapsed_time": "0:25:44", "remaining_time": "0:07:43"} | |
| {"current_steps": 390, "total_steps": 468, "loss": 0.8836, "learning_rate": 3.3493649053890325e-07, "epoch": 2.496, "percentage": 83.33, "elapsed_time": "0:27:42", "remaining_time": "0:05:32"} | |
| {"current_steps": 420, "total_steps": 468, "loss": 0.8826, "learning_rate": 1.286588951321363e-07, "epoch": 2.6879999999999997, "percentage": 89.74, "elapsed_time": "0:30:20", "remaining_time": "0:03:28"} | |
| {"current_steps": 450, "total_steps": 468, "loss": 0.8867, "learning_rate": 1.822781475486507e-08, "epoch": 2.88, "percentage": 96.15, "elapsed_time": "0:32:19", "remaining_time": "0:01:17"} | |
| {"current_steps": 468, "total_steps": 468, "epoch": 2.9952, "percentage": 100.0, "elapsed_time": "0:34:15", "remaining_time": "0:00:00"} | |