-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from sotopia-lab/feature/llama2-13b-train
support llama2 13b train and inference pipeline in fastchat
- Loading branch information
Showing
14 changed files
with
140 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,4 @@ tests/state_of_the_union.txt | |
|
||
# Build | ||
build | ||
!dummy_file | ||
!dummy_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import json | ||
|
||
dummy_qa = {"id": "", "conversations": [{"from": "human", "value": "How old is Haofei?"}, {"from": "gpt", "value": "He is one year old."}]} | ||
|
||
res = [] | ||
for i in range(1000): | ||
new_qa = dict(dummy_qa) | ||
new_qa["id"] = f"identity_{i}" | ||
res.append(new_qa) | ||
|
||
with open("./dummy_convs.json", "w") as f: | ||
json.dump(res, f, indent=4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import json | ||
import transformers | ||
|
||
INPUT_PATH = "fastchat-ft-gpt4-gpt4-easy-2-side-partial-speak.json" | ||
OUTPUT_PATH = "fastchat-ft-gpt4-gpt4-easy-2-side-partial-speak-no-long.json" | ||
MODEL_CHECKPOINT = "meta-llama/Llama-2-13b-chat-hf" | ||
HF_TOKEN = "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" | ||
|
||
with open(INPUT_PATH, 'r') as f: | ||
data = json.load(f) | ||
|
||
tokenizer = transformers.AutoTokenizer.from_pretrained( | ||
MODEL_CHECKPOINT, | ||
padding = False, | ||
truncation = False, | ||
token=HF_TOKEN, | ||
) | ||
|
||
res = [] | ||
for d in data: | ||
for conv in d['conversations']: | ||
if conv['from'] == "human": | ||
input_ids = tokenizer(conv['value']) | ||
if len(input_ids) <= 2048: | ||
res.append(d) | ||
|
||
with open(OUTPUT_PATH, 'w') as f: | ||
json.dump(res, f, indent=4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import json | ||
|
||
INPUT_PATH = "fastchat-ft-gpt4-gpt4-easy-2-side-partial.json" | ||
OUTPUT_PATH = "fastchat-ft-gpt4-gpt4-easy-2-side-partial-speak.json" | ||
|
||
with open(INPUT_PATH, 'r') as f: | ||
data = json.load(f) | ||
|
||
res = [] | ||
for d in data: | ||
for conv in d['conversations']: | ||
if conv['from'] == "gpt" and "'action_type': 'speak'" in conv['value']: | ||
res.append(d) | ||
|
||
with open(OUTPUT_PATH, 'w') as f: | ||
json.dump(res, f, indent=4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python3 -m fastchat.serve.cli --model-path ./checkpoint-shuffle/checkpoint-161 --hf-access-token "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" --conv-template "vicuna_v1.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
deepspeed --num_gpus=1 fastchat/train/train_lora.py \ | ||
--model_name_or_path meta-llama/Llama-2-13b-chat-hf \ | ||
--lora_r 8 \ | ||
--lora_alpha 16 \ | ||
--lora_dropout 0.05 \ | ||
--data_path ./data/fastchat-ft-gpt4-gpt4-easy-2-side-partial-speak-drop-long.json \ | ||
--shuffle True \ | ||
--bf16 True \ | ||
--output_dir ./checkpoint-shuffle-speak-drop-long \ | ||
--num_train_epochs 4 \ | ||
--per_device_train_batch_size 1 \ | ||
--per_device_eval_batch_size 1 \ | ||
--gradient_accumulation_steps 32 \ | ||
--evaluation_strategy "no" \ | ||
--save_strategy "epoch" \ | ||
--save_total_limit 6 \ | ||
--learning_rate 5e-5 \ | ||
--weight_decay 0. \ | ||
--warmup_ratio 0.03 \ | ||
--lr_scheduler_type "cosine" \ | ||
--logging_steps 1 \ | ||
--model_max_length 2048 \ | ||
--q_lora True \ | ||
--deepspeed ./deepspeed_config_s2.json \ | ||
--hf_access_token "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" \ | ||
--tf32 True \ | ||
--flash_attn True \ | ||
--abort_long_seq True \ | ||
|
||
# Possible other options | ||
# --flash_attn True \ | ||
# --tf32 True \ | ||
# --save_strategy "steps" \ | ||
# --save_steps 1200 \ | ||
# --abort_long_seq True \ | ||
# --lazy_preprocess True \ |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ datasets | |
names | ||
together | ||
pydantic==1.10.12 | ||
|