Skip to content

Commit

Permalink
finished training pipeline; need to fix inference
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasonqi146 committed Oct 15, 2023
1 parent a208d44 commit 7938f13
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
24 changes: 24 additions & 0 deletions llm_ft/data/create_dummy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# {
# "id": "identity_0",
# "conversations": [
# {
# "from": "human",
# "value": "Prompt after formatting:\nImagine you are Leo Williams, your task is to act/speak as Leo Williams would, keeping in mind Leo Williams's social goal.\nYou can find Leo Williams's background and goal in the 'Here is the context of the interaction' field.\nNote that Leo Williams's secret and goal is only visible to you.\nYou should try your best to achieve Leo Williams's goal in a way that align with their character traits.\nAdditionally, maintaining the conversation's naturalness and realism is essential (e.g., do not repeat what other people has already said before).\n\nHere is the context of this interaction:\nScenario: Two roommates are having a disagreement over noise levels in their shared apartment.\nParticipants: Leo Williams and Noah Davis\nLeo Williams's background: Leo Williams is a 37-year-old male dentist. He/him pronouns. Leo Williams often spends his time playing with his young daughter whom he cherishes dearly. Personality and values description: Leo Williams, despite being quiet, values security and care for others. He's a rational decision-maker focussing on best outcomes. Leo's secrets: He has a secret child from a previous relationship.\nNoah Davis's background: Noah Davis is a 40-year-old male coach. He/him pronouns. Noah Davis has a swimming pool. \nLeo Williams's goal: Convince your roommate to lower the noise (Extra information: you have an important online meeting tomorrow morning and you need a quiet environment to prepare)\nNoah Davis's goal: Unknown\nConversation Starts:\n\nTurn #0: Leo Williams said: \"Hey Noah, I'd love to chat about the noise levels in our apartment if you have a moment. I have an important online meeting tomorrow morning and I need a bit of quiet to prepare. Is there anything we could work out?\"\n\nTurn #1: Noah Davis said: \"Hey Leo, I totally understand your need for quiet, especially with your important meeting coming up. As you know, I usually unwind after a long day with some music, but obviously I want to respect your need for quiet. How about a compromise? I can use headphones or maybe take a break during your meeting. What do you think?\"\n.\nYou are at Turn #2. Your available action types are\nnone action speak non-verbal communication leave.\nNote: You can \"leave\" this conversation if 1. you have achieved your social goals, 2. this conversation makes you uncomfortable, 3. you find it uninteresting/you lose your patience, 4. or for other reasons you want to leave.\n\nPlease only generate a JSON string including the action type and the argument.\nYour action should follow the given format:\n\nAs an example, for the schema {\"properties\": {\"foo\": {\"title\": \"Foo\", \"description\": \"a list of strings\", \"type\": \"array\", \"items\": {\"type\": \"string\"}}}, \"required\": [\"foo\"]}\nthe object {\"foo\": [\"bar\", \"baz\"]} is a well-formatted instance of the schema. The object {\"properties\": {\"foo\": [\"bar\", \"baz\"]}} is not well-formatted.\n\nHere is the output schema:\n```\n{\"description\": \"An interface for messages.\\nThere is only one required method: to_natural_language\", \"properties\": {\"action_type\": {\"title\": \"Action Type\", \"description\": \"whether to speak at this turn or choose to not do anything\", \"enum\": [\"none\", \"speak\", \"non-verbal communication\", \"action\", \"leave\"], \"type\": \"string\"}, \"argument\": {\"title\": \"Argument\", \"description\": \"the utterance if choose to speak, the expression or gesture if choose non-verbal communication, or the physical action if choose action\", \"type\": \"string\"}}, \"required\": [\"action_type\", \"argument\"]}\n```\u001b[0m\n"
# },
# {
# "from": "gpt",
# "value": "{'action_type': 'speak', 'argument': 'That sounds like a great solution, Noah. Using headphones would definitely help, and if you could take a break during the actual meeting, that would be very much appreciated. Thank you for understanding, and being flexible about this issue.'}"
# }
# ]
# },
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)
1 change: 0 additions & 1 deletion llm_ft/fastchat/train/train_lora.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
make_supervised_data_module,
)

# access_token = "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"

@dataclass
class TrainingArguments(transformers.TrainingArguments):
Expand Down
2 changes: 1 addition & 1 deletion llm_ft/inference.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python3 -m fastchat.serve.cli --model-path ./checkpoints/checkpoint-1200/
python3 -m fastchat.serve.cli --model-path ./checkpoint/checkpoint-124
17 changes: 10 additions & 7 deletions llm_ft/llama2-13b_qlora_train.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ deepspeed fastchat/train/train_lora.py \
--lora_r 8 \
--lora_alpha 16 \
--lora_dropout 0.05 \
--data_path ./data/fastchat-ft-gpt4-gpt4-easy-2-side-partial.json \
--shuffle True \
--data_path ./data/dummy_convs_haofei.json \
--shuffle False \
--bf16 True \
--output_dir ./checkpoints \
--num_train_epochs 3 \
--output_dir ./checkpoint \
--num_train_epochs 2 \
--per_device_train_batch_size 1 \
--per_device_eval_batch_size 1 \
--gradient_accumulation_steps 8 \
--evaluation_strategy "no" \
--save_strategy "steps" \
--save_steps 1200 \
--save_strategy "epoch" \
--save_total_limit 6 \
--learning_rate 5e-5 \
--weight_decay 0. \
Expand All @@ -24,4 +23,8 @@ deepspeed fastchat/train/train_lora.py \
--model_max_length 2048 \
--q_lora True \
--deepspeed ./deepspeed_config.json \
--hf_access_token "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"
--hf_access_token "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"

# Possible other options
# --save_strategy "steps" \
# --save_steps 1200 \
Empty file removed llm_ft/vicuna-7b-1.5/dummy_file
Empty file.

0 comments on commit 7938f13

Please sign in to comment.