Qwen2.5-7B-Instruct
Qwen
Qwen2.5-7B-Instruct is a 7 billion parameter large language model optimized for instruction following. Run this model with TheStage AI "ElasticModels" framework for the fastest performance.
Deploy
Serving with Docker Image
For serving with Nvidia GPUs, we provide ready-to-go Docker containers with OpenAI-compatible API endpoints.
Using our containers you can set up an inference endpoint on any desired cloud/serverless providers as well as on-premise servers.
You can also use this container to run inference through TheStage AI platform.
Prebuilt image from ECR
Pull docker image and start inference container:
docker pull public.ecr.aws/i3f7g5s7/thestage/elastic-models:0.2.1.post0-llm-24.09a
docker run --rm -ti \ --name serving_thestage_model \ -p 8000:80 \ -e AUTH_TOKEN=<AUTH_TOKEN> \ -e MODEL_REPO=Qwen/Qwen2.5-7B-Instruct \ -e MODEL_SIZE=<MODEL_SIZE> \ -e MODEL_BATCH=<MAX_BATCH_SIZE> \ -e HUGGINGFACE_ACCESS_TOKEN=<HUGGINGFACE_ACCESS_TOKEN> \ -e THESTAGE_AUTH_TOKEN=<THESTAGE_ACCESS_TOKEN> \ -v /mnt/hf_cache:/root/.cache/huggingface \ public.ecr.aws/i3f7g5s7/thestage/elastic-models:0.2.1.post0-llm-24.09a
| Parameter | Description |
|---|---|
| Available: S, M, L, XL. | |
| Maximum batch size to process in parallel. | |
| Hugging Face access token. | |
| TheStage token generated on the platform (Profile -> Access tokens). | |
| Token for endpoint authentication. You can set it to any random string; it must match the value used by the client. |
Invocation
You can invoke the endpoint using CURL as follows:
curl -X POST 'http://127.0.0.1:8000/v1/chat/completions' \
-H 'Authorization: Bearer 123' \
-H 'Content-Type: application/json' \
-H "X-Model-Name: qwen-2-5-7b-instruct-<MODEL_SIZE>-bs<MAX_BATCH_SIZE>-paged" \
-d '{
"messages":[{"role":"user","content":"Define AI"}]
}'Or using OpenAI python client:
import os, base64, pathlib, json
from openai import OpenAI
BASE_URL = "http://<your_ip>/v1"
API_KEY = "123"
MODEL = "qwen-2-5-7b-instruct-<MODEL_SIZE>-bs<MAX_BATCH_SIZE>-paged"
client = OpenAI(
api_key=API_KEY,
base_url=BASE_URL,
default_headers={"X-Model-Name": MODEL}
)
response = client.chat.completions.create(
model=MODEL,
messages=[
{"role": "user", "content": "Define AI"}
]
)
print(response.choices[0].message.content)Endpoint Parameters
Method
POST /v1/chat/completions
Header Parameters
Authorization: string
Bearer token for authentication. Should match the AUTH_TOKEN set during container startup.
Content-Type: string
Must be set to application/json.
X-Model-Name: string
Specifies the model to use for generation. Format: qwen-2-5-7b-instruct- -bs , where is one of S, M, L, XL, original and is the maximum batch size configured during container startup.
Input Body
messages : string
The input text prompt.
Deploy on Modal
For more details please use the tutorial Modal deployment
Clone modal serving code
git clone https://github.com/TheStageAI/ElasticModels.git cd ElasticModels/examples/modal
Configuration of environment variables
Set your environment variables in modal_serving.py:
# modal_serving.py
ENVS = {
"MODEL_REPO": "Qwen/Qwen2.5-7B-Instruct",
"MODEL_BATCH": "4",
"THESTAGE_AUTH_TOKEN": "",
"HUGGINGFACE_ACCESS_TOKEN": "",
"PORT": "80",
"PORT_HEALTH": "80",
"HF_HOME": "/cache/huggingface",
}Configuration of GPUs
Set your desired GPU type and autoscaling variables in modal_serving.py:
# modal_serving.py
@app.function(
image=image,
gpu="B200",
min_containers=8,
max_containers=8,
timeout=10000,
ephemeral_disk=600 * 1024,
volumes={"/opt/project/.cache": HF_CACHE},
startup_timeout=60*20
)
@modal.web_server(
80,
label="Qwen/Qwen2.5-7B-Instruct-test",
startup_timeout=60*20
)
def serve():
passRun serving
modal serve modal_serving.py