Skip to content

Commit 4c78f8c

Browse files
Add instruction tuning example (#691)
* add instruction tuning example. Signed-off-by: Ye, Xinyu <xinyu.ye@intel.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: Ye, Xinyu <xinyu.ye@intel.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent adb157f commit 4c78f8c

File tree

4 files changed

+158
-0
lines changed

4 files changed

+158
-0
lines changed

InstructionTuning/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Instruction Tuning
2+
3+
Instruction tuning is the process of further training LLMs on a dataset consisting of (instruction, output) pairs in a supervised fashion, which bridges the gap between the next-word prediction objective of LLMs and the users' objective of having LLMs adhere to human instructions.
4+
5+
## Deploy Instruction Tuning Service
6+
7+
### Deploy Instruction Tuning Service on Xeon
8+
9+
Refer to the [Xeon Guide](./docker/xeon/README.md) for detail.
10+
11+
### Deploy Instruction Tuning Service on Gaudi
12+
13+
Refer to the [Gaudi Guide](./docker/gaudi/README.md) for detail.
14+
15+
## Consume Instruction Tuning Service
16+
17+
### 1. Upload a training file
18+
19+
Download a training file `alpaca_data.json` and upload it to the server with below command, this file can be downloaded in [here](https://github.com/tatsu-lab/stanford_alpaca/blob/main/alpaca_data.json):
20+
21+
```bash
22+
# upload a training file
23+
curl http://${your_ip}:8005/v1/finetune/upload_training_files -X POST -H "Content-Type: multipart/form-data" -F "files=@./alpaca_data.json"
24+
```
25+
26+
### 2. Create fine-tuning job
27+
28+
After a training file `alpaca_data.json` is uploaded, use the following command to launch a finetuning job using `meta-llama/Llama-2-7b-chat-hf` as base model:
29+
30+
```bash
31+
# create a finetuning job
32+
curl http://${your_ip}:8005/v1/fine_tuning/jobs \
33+
-X POST \
34+
-H "Content-Type: application/json" \
35+
-d '{
36+
"training_file": "alpaca_data.json",
37+
"model": "meta-llama/Llama-2-7b-chat-hf"
38+
}'
39+
```
40+
41+
### 3. Manage fine-tuning job
42+
43+
Below commands show how to list finetuning jobs, retrieve a finetuning job, cancel a finetuning job and list checkpoints of a finetuning job.
44+
45+
```bash
46+
# list finetuning jobs
47+
curl http://${your_ip}:8005/v1/fine_tuning/jobs -X GET
48+
49+
# retrieve one finetuning job
50+
curl http://localhost:8005/v1/fine_tuning/jobs/retrieve -X POST -H "Content-Type: application/json" -d '{
51+
"fine_tuning_job_id": ${fine_tuning_job_id}}'
52+
53+
# cancel one finetuning job
54+
55+
curl http://localhost:8005/v1/fine_tuning/jobs/cancel -X POST -H "Content-Type: application/json" -d '{
56+
"fine_tuning_job_id": ${fine_tuning_job_id}}'
57+
58+
# list checkpoints of a finetuning job
59+
curl http://${your_ip}:8005/v1/finetune/list_checkpoints -X POST -H "Content-Type: application/json" -d '{"fine_tuning_job_id": ${fine_tuning_job_id}}'
60+
```
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Deploy Instruction Tuning Service on Gaudi
2+
3+
This document outlines the deployment process for a Instruction Tuning Service utilizing the [GenAIComps](https://github.com/opea-project/GenAIComps.git) microservice on Intel Gaudi server. The steps include Docker image creation, container deployment. We will publish the Docker images to Docker Hub, it will simplify the deployment process for this service.
4+
5+
## 🚀 Build Docker Images
6+
7+
First of all, you need to build Docker Images locally. This step can be ignored after the Docker images published to Docker hub.
8+
9+
### 1. Source Code install GenAIComps
10+
11+
```bash
12+
git clone https://github.com/opea-project/GenAIComps.git
13+
cd GenAIComps
14+
```
15+
16+
### 2. Build Docker Image
17+
18+
Build docker image with below command:
19+
20+
```bash
21+
docker build -t opea/finetuning-gaudi:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/finetuning/docker/Dockerfile_hpu .
22+
```
23+
24+
### 3. Run Docker with CLI
25+
26+
Start docker container with below command:
27+
28+
```bash
29+
export HF_TOKEN=${your_huggingface_token}
30+
docker run --runtime=habana -e HABANA_VISIBLE_DEVICES=all -p 8005:8005 -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice --net=host --ipc=host -e https_proxy=$https_proxy -e http_proxy=$http_proxy -e no_proxy=$no_proxy -e HF_TOKEN=$HF_TOKEN opea/finetuning-gaudi:latest
31+
```
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Deploy Instruction Tuning Service on Xeon
2+
3+
This document outlines the deployment process for a Instruction Tuning Service utilizing the [GenAIComps](https://github.com/opea-project/GenAIComps.git) microservice on Intel Xeon server. The steps include Docker image creation, container deployment. We will publish the Docker images to Docker Hub, it will simplify the deployment process for this service.
4+
5+
## 🚀 Build Docker Images
6+
7+
First of all, you need to build Docker Images locally. This step can be ignored after the Docker images published to Docker hub.
8+
9+
### 1. Source Code install GenAIComps
10+
11+
```bash
12+
git clone https://github.com/opea-project/GenAIComps.git
13+
cd GenAIComps
14+
```
15+
16+
### 2. Build Docker Image
17+
18+
Build docker image with below command:
19+
20+
```bash
21+
export HF_TOKEN=${your_huggingface_token}
22+
docker build -t opea/finetuning:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy --build-arg HF_TOKEN=$HF_TOKEN -f comps/finetuning/docker/Dockerfile_cpu .
23+
```
24+
25+
### 3. Run Docker with CLI
26+
27+
Start docker container with below command:
28+
29+
```bash
30+
docker run -d --name="finetuning-server" -p 8005:8005 --runtime=runc --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy opea/finetuning:latest
31+
```
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
# Copyright (C) 2024 Intel Corporation
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
set -e
6+
echo "IMAGE_REPO=${IMAGE_REPO}"
7+
8+
WORKPATH=$(dirname "$PWD")
9+
LOG_PATH="$WORKPATH/tests"
10+
ip_address=$(hostname -I | awk '{print $1}')
11+
12+
function build_docker_images() {
13+
cd $WORKPATH/../../
14+
if [ ! -d "GenAIComps" ] ; then
15+
git clone https://github.com/opea-project/GenAIComps.git
16+
fi
17+
cd GenAIComps
18+
git status
19+
20+
docker build -t opea/finetuning:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy --build-arg HF_TOKEN=$HF_TOKEN -f comps/finetuning/docker/Dockerfile_cpu .
21+
}
22+
23+
function start_services() {
24+
# Start Docker Containers
25+
docker run -d --name="finetuning-server" -p 8005:8005 --runtime=runc --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy opea/finetuning:latest
26+
27+
sleep 20
28+
}
29+
30+
31+
function main() {
32+
33+
34+
}
35+
36+
main

0 commit comments

Comments
 (0)