Instructions to use alibaba-pai/Qwen2-7B-Instruct-Response-Exp with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use alibaba-pai/Qwen2-7B-Instruct-Response-Exp with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="alibaba-pai/Qwen2-7B-Instruct-Response-Exp") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("alibaba-pai/Qwen2-7B-Instruct-Response-Exp") model = AutoModelForCausalLM.from_pretrained("alibaba-pai/Qwen2-7B-Instruct-Response-Exp") 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 alibaba-pai/Qwen2-7B-Instruct-Response-Exp with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "alibaba-pai/Qwen2-7B-Instruct-Response-Exp" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "alibaba-pai/Qwen2-7B-Instruct-Response-Exp", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/alibaba-pai/Qwen2-7B-Instruct-Response-Exp
- SGLang
How to use alibaba-pai/Qwen2-7B-Instruct-Response-Exp 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 "alibaba-pai/Qwen2-7B-Instruct-Response-Exp" \ --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": "alibaba-pai/Qwen2-7B-Instruct-Response-Exp", "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 "alibaba-pai/Qwen2-7B-Instruct-Response-Exp" \ --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": "alibaba-pai/Qwen2-7B-Instruct-Response-Exp", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use alibaba-pai/Qwen2-7B-Instruct-Response-Exp with Docker Model Runner:
docker model run hf.co/alibaba-pai/Qwen2-7B-Instruct-Response-Exp
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
π Introduction
Qwen2-7B-Instruct-Response-Exp is a powerful large language model that can automatically expand datasets and annotations like self-instruct.
We fine-tuned Qwen2-7B-Instruct to obtain Qwen2-7B-Instruct-Response-Exp. We sampled the dataset from OpenHermes and the LCCD dataset, ensuring a balanced task distribution. For training set annotations, we used Qwen-max with incorporated our handwritten examples as in-context prompts.
Example Input
### Instruction
Here are some concepts: car, driving, travel Can you make a sentence with these concepts?
### Response
Of course you can! Here is a sentence: "We drove the car and started an unforgettable journey.
### Instruction
Why does the sun rise in the east every day?
### Response
The sun rises in the east every day because of the direction of the earth's rotation and geographical features. The earth rotates from west to east, so an observer on the surface of the earth will see the sun rise from the eastern horizon, pass through the sky, and finally set on the western horizon. Specifically, the earth's rotation axis refers to an imaginary axis that passes through the north and south poles of the earth, and the earth rotates from west to east around this axis. Because of this rotation, any place on the earth will experience day and night. When a place rotates to the side facing the sun, it will usher in daytime; when it rotates to the side facing away from the sun, it will usher in night. Since the direction of the earth's rotation is from west to east, the sun appears to rise from the east and set in the west. This phenomenon is a direct result of the earth's rotation, not the movement of the sun itself.
### Instruction
Example Output
### Instruction
Here are some concepts: books, learning, knowledge Can you make a sentence with these concepts?
### Response
Of course you can! Here is a sentence that contains these concepts: By reading books, we can continue to learn and enrich our knowledge.
π Quick Start
Here provides a code snippet with apply_chat_template to show you how to load the tokenizer and model and how to generate contents.
from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda" # the device to load the model onto
model = AutoModelForCausalLM.from_pretrained(
"alibaba-pai/Qwen2-7B-Instruct-Response-Exp",
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("alibaba-pai/Qwen2-7B-Instruct-Response-Exp")
prompt = "Give me a short introduction to large language model."
messages = [
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(device)
generated_ids = model.generate(
model_inputs.input_ids,
max_new_tokens=2048οΌ
eos_token_id=151645οΌ
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
π Evaluation
| Diversity | Length | Complexity | Factuality | |
|---|---|---|---|---|
| Self-Instruct | 9.6 | 15.8 | 0.32 | 5.0 |
| Qwen2-7B-Instruct-Response-Exp | 17.2 | 26.3 | 4.97 | 4.9 |
π Citation
If you find our work helpful, please cite it!
@misc{data-augmentation-family,
title={Building a Family of Data Augmentation Models for Low-cost LLM Fine-tuning on the Cloud},
author={Yuanhao Yue and Chengyu Wang and Jun Huang and Peng Wang},
year={2024},
eprint={2412.04871},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2412.04871},
}
- Downloads last month
- 16