From 7938f131dd06ea7fff5fdfc2e9a9a8028643d6d8 Mon Sep 17 00:00:00 2001 From: Jasonqi146 Date: Sun, 15 Oct 2023 18:18:19 +0000 Subject: [PATCH] finished training pipeline; need to fix inference --- llm_ft/data/create_dummy.py | 24 ++++++++++++++++++++++++ llm_ft/fastchat/train/train_lora.py | 1 - llm_ft/inference.sh | 2 +- llm_ft/llama2-13b_qlora_train.sh | 17 ++++++++++------- llm_ft/vicuna-7b-1.5/dummy_file | 0 5 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 llm_ft/data/create_dummy.py delete mode 100644 llm_ft/vicuna-7b-1.5/dummy_file diff --git a/llm_ft/data/create_dummy.py b/llm_ft/data/create_dummy.py new file mode 100644 index 00000000..431e3977 --- /dev/null +++ b/llm_ft/data/create_dummy.py @@ -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) \ No newline at end of file diff --git a/llm_ft/fastchat/train/train_lora.py b/llm_ft/fastchat/train/train_lora.py index 841ae0d6..65cc23bc 100644 --- a/llm_ft/fastchat/train/train_lora.py +++ b/llm_ft/fastchat/train/train_lora.py @@ -34,7 +34,6 @@ make_supervised_data_module, ) -# access_token = "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" @dataclass class TrainingArguments(transformers.TrainingArguments): diff --git a/llm_ft/inference.sh b/llm_ft/inference.sh index 492aa4f0..759a157b 100644 --- a/llm_ft/inference.sh +++ b/llm_ft/inference.sh @@ -1 +1 @@ -python3 -m fastchat.serve.cli --model-path ./checkpoints/checkpoint-1200/ \ No newline at end of file +python3 -m fastchat.serve.cli --model-path ./checkpoint/checkpoint-124 \ No newline at end of file diff --git a/llm_ft/llama2-13b_qlora_train.sh b/llm_ft/llama2-13b_qlora_train.sh index e055f060..a24dfe7a 100644 --- a/llm_ft/llama2-13b_qlora_train.sh +++ b/llm_ft/llama2-13b_qlora_train.sh @@ -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. \ @@ -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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" \ No newline at end of file + --hf_access_token "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" + +# Possible other options +# --save_strategy "steps" \ +# --save_steps 1200 \ \ No newline at end of file diff --git a/llm_ft/vicuna-7b-1.5/dummy_file b/llm_ft/vicuna-7b-1.5/dummy_file deleted file mode 100644 index e69de29b..00000000