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>
This commit is contained in:
60
InstructionTuning/README.md
Normal file
60
InstructionTuning/README.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# Instruction Tuning
|
||||
|
||||
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.
|
||||
|
||||
## Deploy Instruction Tuning Service
|
||||
|
||||
### Deploy Instruction Tuning Service on Xeon
|
||||
|
||||
Refer to the [Xeon Guide](./docker/xeon/README.md) for detail.
|
||||
|
||||
### Deploy Instruction Tuning Service on Gaudi
|
||||
|
||||
Refer to the [Gaudi Guide](./docker/gaudi/README.md) for detail.
|
||||
|
||||
## Consume Instruction Tuning Service
|
||||
|
||||
### 1. Upload a training file
|
||||
|
||||
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):
|
||||
|
||||
```bash
|
||||
# upload a training file
|
||||
curl http://${your_ip}:8005/v1/finetune/upload_training_files -X POST -H "Content-Type: multipart/form-data" -F "files=@./alpaca_data.json"
|
||||
```
|
||||
|
||||
### 2. Create fine-tuning job
|
||||
|
||||
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:
|
||||
|
||||
```bash
|
||||
# create a finetuning job
|
||||
curl http://${your_ip}:8005/v1/fine_tuning/jobs \
|
||||
-X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"training_file": "alpaca_data.json",
|
||||
"model": "meta-llama/Llama-2-7b-chat-hf"
|
||||
}'
|
||||
```
|
||||
|
||||
### 3. Manage fine-tuning job
|
||||
|
||||
Below commands show how to list finetuning jobs, retrieve a finetuning job, cancel a finetuning job and list checkpoints of a finetuning job.
|
||||
|
||||
```bash
|
||||
# list finetuning jobs
|
||||
curl http://${your_ip}:8005/v1/fine_tuning/jobs -X GET
|
||||
|
||||
# retrieve one finetuning job
|
||||
curl http://localhost:8005/v1/fine_tuning/jobs/retrieve -X POST -H "Content-Type: application/json" -d '{
|
||||
"fine_tuning_job_id": ${fine_tuning_job_id}}'
|
||||
|
||||
# cancel one finetuning job
|
||||
|
||||
curl http://localhost:8005/v1/fine_tuning/jobs/cancel -X POST -H "Content-Type: application/json" -d '{
|
||||
"fine_tuning_job_id": ${fine_tuning_job_id}}'
|
||||
|
||||
# list checkpoints of a finetuning job
|
||||
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}}'
|
||||
```
|
||||
31
InstructionTuning/docker/gaudi/README.md
Normal file
31
InstructionTuning/docker/gaudi/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Deploy Instruction Tuning Service on Gaudi
|
||||
|
||||
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.
|
||||
|
||||
## 🚀 Build Docker Images
|
||||
|
||||
First of all, you need to build Docker Images locally. This step can be ignored after the Docker images published to Docker hub.
|
||||
|
||||
### 1. Source Code install GenAIComps
|
||||
|
||||
```bash
|
||||
git clone https://github.com/opea-project/GenAIComps.git
|
||||
cd GenAIComps
|
||||
```
|
||||
|
||||
### 2. Build Docker Image
|
||||
|
||||
Build docker image with below command:
|
||||
|
||||
```bash
|
||||
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 .
|
||||
```
|
||||
|
||||
### 3. Run Docker with CLI
|
||||
|
||||
Start docker container with below command:
|
||||
|
||||
```bash
|
||||
export HF_TOKEN=${your_huggingface_token}
|
||||
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
InstructionTuning/docker/xeon/README.md
Normal file
31
InstructionTuning/docker/xeon/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Deploy Instruction Tuning Service on Xeon
|
||||
|
||||
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.
|
||||
|
||||
## 🚀 Build Docker Images
|
||||
|
||||
First of all, you need to build Docker Images locally. This step can be ignored after the Docker images published to Docker hub.
|
||||
|
||||
### 1. Source Code install GenAIComps
|
||||
|
||||
```bash
|
||||
git clone https://github.com/opea-project/GenAIComps.git
|
||||
cd GenAIComps
|
||||
```
|
||||
|
||||
### 2. Build Docker Image
|
||||
|
||||
Build docker image with below command:
|
||||
|
||||
```bash
|
||||
export HF_TOKEN=${your_huggingface_token}
|
||||
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 .
|
||||
```
|
||||
|
||||
### 3. Run Docker with CLI
|
||||
|
||||
Start docker container with below command:
|
||||
|
||||
```bash
|
||||
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
|
||||
```
|
||||
36
InstructionTuning/tests/test_instruction_tuning_on_xeon.sh
Normal file
36
InstructionTuning/tests/test_instruction_tuning_on_xeon.sh
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
# Copyright (C) 2024 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set -e
|
||||
echo "IMAGE_REPO=${IMAGE_REPO}"
|
||||
|
||||
WORKPATH=$(dirname "$PWD")
|
||||
LOG_PATH="$WORKPATH/tests"
|
||||
ip_address=$(hostname -I | awk '{print $1}')
|
||||
|
||||
function build_docker_images() {
|
||||
cd $WORKPATH/../../
|
||||
if [ ! -d "GenAIComps" ] ; then
|
||||
git clone https://github.com/opea-project/GenAIComps.git
|
||||
fi
|
||||
cd GenAIComps
|
||||
git status
|
||||
|
||||
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 .
|
||||
}
|
||||
|
||||
function start_services() {
|
||||
# Start Docker Containers
|
||||
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
|
||||
|
||||
sleep 20
|
||||
}
|
||||
|
||||
|
||||
function main() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
main
|
||||
Reference in New Issue
Block a user