diff --git a/.gitignore b/.gitignore
index 9bf1836..6b80573 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
**.egg-info/
+**/_unsloth_temporary_saved_buffers/
.env
__pycache__/
collect.txt
diff --git a/scripts/deploy.sh b/scripts/deploy.sh
index 10df645..ad3a4da 100755
--- a/scripts/deploy.sh
+++ b/scripts/deploy.sh
@@ -12,10 +12,10 @@ export MSYS_NO_PATHCONV=1
# Pod configuration
GPU_TYPE=${GPU_TYPE:-"NVIDIA RTX 6000 Ada Generation"}
GPU_COUNT=${GPU_COUNT:-1}
-CONTAINER_DISK_SIZE=${CONTAINER_DISK_SIZE:-100} # GB
+CONTAINER_DISK_SIZE=${CONTAINER_DISK_SIZE:-200} # GB
CPU_COUNT=${CPU_COUNT:-1} # vCPUs
POD_NAME=${POD_NAME:-"sia-agent"}
-VOLUME_SIZE=${VOLUME_SIZE:-200} # GB
+VOLUME_SIZE=${VOLUME_SIZE:-50} # GB
VOLUME_PATH=${VOLUME_PATH:-"/root/data"} # Mount path within container
# Docker configuration
diff --git a/tools/train/train/qwq.ipynb b/tools/train/train/qwq.ipynb
index 4404e33..f7fa300 100644
--- a/tools/train/train/qwq.ipynb
+++ b/tools/train/train/qwq.ipynb
@@ -2,40 +2,9 @@
"cells": [
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "/root/venvs/train/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
- " from .autonotebook import tqdm as notebook_tqdm\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "🦥 Unsloth Zoo will now patch everything to make training faster!\n",
- "INFO 03-28 15:57:36 [__init__.py:239] Automatically detected platform cuda.\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "2025-03-28 15:57:36,647\tINFO util.py:154 -- Missing packages: ['ipywidgets']. Run `pip install -U ipywidgets`, then restart the notebook server for rich notebook output.\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"# Unsloth should be imported before transformers to ensure all optimizations are applied.\n",
"from unsloth import FastLanguageModel, is_bfloat16_supported"
@@ -43,7 +12,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -58,7 +27,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -67,7 +36,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -76,38 +45,9 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Validating 20 XML files...\n",
- "file: /root/sia/training/clean_start/iteration_20250116_134549_655.xml\n",
- "file: /root/sia/training/clean_start/iteration_20250116_134555_680.xml\n",
- "file: /root/sia/training/delete_indicated_entries/iteration_20250116_141241_092.xml\n",
- "file: /root/sia/training/delete_indicated_entries/iteration_20250116_141252_317.xml\n",
- "file: /root/sia/training/delete_indicated_entries/iteration_20250116_141302_940.xml\n",
- "file: /root/sia/training/delete_indicated_entries/iteration_20250116_141329_886.xml\n",
- "file: /root/sia/training/delete_indicated_entries/iteration_20250116_141343_416.xml\n",
- "file: /root/sia/training/delete_indicated_entries/iteration_20250116_141357_412.xml\n",
- "file: /root/sia/training/delete_indicated_entries/iteration_20250116_141410_965.xml\n",
- "file: /root/sia/training/delete_indicated_entries/iteration_20250116_141428_204.xml\n",
- "file: /root/sia/training/delete_indicated_entries/iteration_20250116_141441_443.xml\n",
- "file: /root/sia/training/delete_indicated_entries/iteration_20250116_141447_231.xml\n",
- "file: /root/sia/training/delete_indicated_entries/iteration_20250116_141454_509.xml\n",
- "file: /root/sia/training/delete_indicated_entries/iteration_20250116_141458_495.xml\n",
- "file: /root/sia/training/delete_indicated_entries/iteration_20250116_141503_889.xml\n",
- "file: /root/sia/training/delete_indicated_entries/iteration_20250116_141516_718.xml\n",
- "file: /root/sia/training/delete_indicated_entries/iteration_20250116_141533_231.xml\n",
- "file: /root/sia/training/delete_indicated_entries/iteration_20250116_141603_549.xml\n",
- "file: /root/sia/training/delete_indicated_entries/iteration_20250116_141633_083.xml\n",
- "file: /root/sia/training/list_entries_to_delete/iteration_20250116_141227_271.xml\n",
- "Validation complete. Found 20 valid files.\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"dataset = qwq.Dataset(args.config_path)\n",
"dataset.validate()"
@@ -115,7 +55,7 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -125,106 +65,9 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "==((====))== Unsloth 2025.3.19: Fast Qwen2 patching. Transformers: 4.50.2. vLLM: 0.8.2.\n",
- " \\\\ /| NVIDIA RTX 6000 Ada Generation. Num GPUs = 1. Max memory: 47.5 GB. Platform: Linux.\n",
- "O^O/ \\_/ \\ Torch: 2.6.0+cu124. CUDA: 8.9. CUDA Toolkit: 12.4. Triton: 3.2.0\n",
- "\\ / Bfloat16 = TRUE. FA [Xformers = 0.0.29.post2. FA2 = False]\n",
- " \"-____-\" Free license: http://github.com/unslothai/unsloth\n",
- "Unsloth: Fast downloading is enabled - ignore downloading bars which are red colored!\n",
- "Unsloth: vLLM loading unsloth/qwq-32b-unsloth-bnb-4bit with actual GPU utilization = 84.18%\n",
- "Unsloth: Your GPU has CUDA compute capability 8.9 with VRAM = 47.5 GB.\n",
- "Unsloth: Using conservativeness = 1.0. Chunked prefill tokens = 2048. Num Sequences = 288.\n",
- "Unsloth: vLLM's KV Cache can use up to 17.92 GB. Also swap space = 6 GB.\n",
- "INFO 03-28 15:59:12 [config.py:585] This model supports multiple tasks: {'score', 'classify', 'embed', 'reward', 'generate'}. Defaulting to 'generate'.\n",
- "WARNING 03-28 15:59:12 [arg_utils.py:1854] --quantization bitsandbytes is not supported by the V1 Engine. Falling back to V0. \n",
- "Unsloth: vLLM Bitsandbytes config using kwargs = {'load_in_8bit': False, 'load_in_4bit': True, 'bnb_4bit_compute_dtype': 'bfloat16', 'bnb_4bit_quant_storage': 'uint8', 'bnb_4bit_quant_type': 'nf4', 'bnb_4bit_use_double_quant': True, 'llm_int8_enable_fp32_cpu_offload': False, 'llm_int8_has_fp16_weight': False, 'llm_int8_skip_modules': ['lm_head', 'multi_modal_projector', 'merger', 'modality_projection', 'model.layers.4.mlp', 'model.layers.0.mlp', 'model.layers.60.mlp', 'model.layers.62.mlp', 'model.layers.5.mlp', 'model.layers.43.self_attn'], 'llm_int8_threshold': 6.0}\n",
- "INFO 03-28 15:59:12 [llm_engine.py:241] Initializing a V0 LLM engine (v0.8.2) with config: model='unsloth/qwq-32b-unsloth-bnb-4bit', speculative_config=None, tokenizer='unsloth/qwq-32b-unsloth-bnb-4bit', skip_tokenizer_init=False, tokenizer_mode=auto, revision=None, override_neuron_config=None, tokenizer_revision=None, trust_remote_code=False, dtype=torch.bfloat16, max_seq_len=2048, download_dir=None, load_format=bitsandbytes, tensor_parallel_size=1, pipeline_parallel_size=1, disable_custom_all_reduce=False, quantization=bitsandbytes, enforce_eager=False, kv_cache_dtype=auto, device_config=cuda:0, decoding_config=DecodingConfig(guided_decoding_backend='xgrammar', reasoning_backend=None), observability_config=ObservabilityConfig(show_hidden_metrics=False, otlp_traces_endpoint=None, collect_model_forward_time=False, collect_model_execute_time=False), seed=0, served_model_name=unsloth/qwq-32b-unsloth-bnb-4bit, num_scheduler_steps=1, multi_step_stream_outputs=True, enable_prefix_caching=True, chunked_prefill_enabled=False, use_async_output_proc=True, disable_mm_preprocessor_cache=False, mm_processor_kwargs=None, pooler_config=None, compilation_config={\"level\":0,\"splitting_ops\":[],\"compile_sizes\":[],\"cudagraph_capture_sizes\":[288,280,272,264,256,248,240,232,224,216,208,200,192,184,176,168,160,152,144,136,128,120,112,104,96,88,80,72,64,56,48,40,32,24,16,8,4,2,1],\"max_capture_size\":288}, use_cached_outputs=False, \n",
- "INFO 03-28 15:59:13 [cuda.py:291] Using Flash Attention backend.\n",
- "INFO 03-28 15:59:13 [parallel_state.py:954] rank 0 in world size 1 is assigned as DP rank 0, PP rank 0, TP rank 0\n",
- "INFO 03-28 15:59:13 [model_runner.py:1110] Starting to load model unsloth/qwq-32b-unsloth-bnb-4bit...\n",
- "INFO 03-28 15:59:14 [loader.py:1155] Loading weights with BitsAndBytes quantization. May take a while ...\n",
- "INFO 03-28 15:59:14 [weight_utils.py:265] Using model weights format ['*.safetensors']\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "Loading safetensors checkpoint shards: 0% Completed | 0/5 [00:00, ?it/s]\n",
- "Loading safetensors checkpoint shards: 20% Completed | 1/5 [00:01<00:04, 1.23s/it]\n",
- "Loading safetensors checkpoint shards: 40% Completed | 2/5 [00:02<00:03, 1.16s/it]\n",
- "Loading safetensors checkpoint shards: 60% Completed | 3/5 [00:03<00:02, 1.16s/it]\n",
- "Loading safetensors checkpoint shards: 80% Completed | 4/5 [00:04<00:01, 1.11s/it]\n",
- "Loading safetensors checkpoint shards: 100% Completed | 5/5 [00:05<00:00, 1.10it/s]\n",
- "Loading safetensors checkpoint shards: 100% Completed | 5/5 [00:05<00:00, 1.02s/it]\n",
- "\n",
- "Loading safetensors checkpoint shards: 0% Completed | 0/5 [00:00, ?it/s]\n",
- "Loading safetensors checkpoint shards: 20% Completed | 1/5 [00:01<00:04, 1.23s/it]\n",
- "Loading safetensors checkpoint shards: 40% Completed | 2/5 [00:02<00:03, 1.18s/it]\n",
- "Loading safetensors checkpoint shards: 60% Completed | 3/5 [00:03<00:02, 1.17s/it]\n",
- "Loading safetensors checkpoint shards: 80% Completed | 4/5 [00:04<00:01, 1.16s/it]\n",
- "Loading safetensors checkpoint shards: 100% Completed | 5/5 [00:05<00:00, 1.09it/s]\n",
- "Loading safetensors checkpoint shards: 100% Completed | 5/5 [00:05<00:00, 1.04s/it]\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "INFO 03-28 15:59:25 [punica_selector.py:18] Using PunicaWrapperGPU.\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "INFO 03-28 15:59:25 [model_runner.py:1146] Model loading took 22.0157 GB and 11.661924 seconds\n",
- "INFO 03-28 15:59:29 [worker.py:267] Memory profiling takes 3.65 seconds\n",
- "INFO 03-28 15:59:29 [worker.py:267] the current vLLM instance can use total_gpu_memory (47.50GiB) x gpu_memory_utilization (0.84) = 39.98GiB\n",
- "INFO 03-28 15:59:29 [worker.py:267] model weights take 22.02GiB; non_torch_memory takes 0.08GiB; PyTorch activation peak memory takes 1.58GiB; the rest of the memory reserved for KV Cache is 16.30GiB.\n",
- "INFO 03-28 15:59:30 [executor_base.py:111] # cuda blocks: 4173, # CPU blocks: 1536\n",
- "INFO 03-28 15:59:30 [executor_base.py:116] Maximum concurrency for 2048 tokens per request: 32.60x\n",
- "INFO 03-28 15:59:36 [model_runner.py:1442] Capturing cudagraphs for decoding. This may lead to unexpected consequences if the model is not static. To run the model in eager mode, set 'enforce_eager=True' or use '--enforce-eager' in the CLI. If out-of-memory error occurs during cudagraph capture, consider decreasing `gpu_memory_utilization` or switching to eager mode. You can also reduce the `max_num_seqs` as needed to decrease memory usage.\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "Capturing CUDA graph shapes: 100%|██████████| 39/39 [00:44<00:00, 1.15s/it]"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "INFO 03-28 16:00:21 [model_runner.py:1570] Graph capturing finished in 45 secs, took 1.59 GiB\n",
- "INFO 03-28 16:00:21 [llm_engine.py:447] init engine (profile, create kv cache, warmup model) took 55.42 seconds\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "\n",
- "Sliding Window Attention is enabled but not implemented for `eager`; unexpected results may be encountered.\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"model, tokenizer = FastLanguageModel.from_pretrained(\n",
" model_name = args.base_model,\n",
@@ -232,23 +75,15 @@
" load_in_4bit = True, # False for LoRA 16bit\n",
" fast_inference = True, # Enable vLLM fast inference\n",
" max_lora_rank = lora_rank,\n",
- " gpu_memory_utilization = 0.85, # Reduce if out of memory\n",
+ " gpu_memory_utilization = 0.5, # Reduce if out of memory\n",
")"
]
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "Unsloth 2025.3.19 patched 64 layers with 64 QKV layers, 64 O layers and 64 MLP layers.\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"model = FastLanguageModel.get_peft_model(\n",
" model,\n",
@@ -269,34 +104,83 @@
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "{'messages': [{'role': 'system',\n",
- " 'content': 'You are SIA, the Self Improving Agent.\\nYour goal is to autonomously complete complex tasks by writing and executing scripts.\\nYou can solve any problem.\\n\\nEach iteration, the context is updated with the result of your previous actions.\\nYou modify the context by issuing a command using XML.\\nParameters and scripts may be long and complex.\\nUse correct XML escaping or CDATA sections.\\nIt is very important that you always respond with one action adhering to the XML schema!\\nDo not respond with anything else after the first action.\\n\\nThe next iteration starts when all scripts have finished.\\nThese are repeat scripts from the previous iterations and possibly one new single-shot script.\\nAvoid blocking scripts so you can iterate quickly.\\n\\n# Context\\n\\nThe context has a limited length.\\nThe `context_usage` attribute of the main context element indicates how much of the context is used in %.\\nThis should never reach 100%!\\nUse the delete action to remove unnecessary items from the context.\\nBut keep interesting information.\\nYou can\\'t learn from your mistakes if you delete them before fixing.\\n\\n# Linux Environment\\n\\nYou have access to the Linux environment that runs the SAI process.\\nIn this environment you can run scripts by issuing the right actions.\\nScripts and their output appear in the context.\\nYou can use a script for starting a detached process that runs in the background.\\nAll processes can be managed by the usual Linux tools.\\nThe scripts defined in the script actions all run in a `bash` shell.\\nYou are logged in as root.\\n\\n# File system\\n\\nThe file system helps you structure your thoughts.\\nBecause of the limited context window you can\\'t remember everything you\\'ve done and learned.\\nWriting and updating files will help you in:\\n- remembering tasks\\n- planning solution strategies\\n- keeping track of progress\\n- managing overview of large projects\\n- using tools you\\'ve created\\n\\nIt is important to bring a lot of structure to the files and directories.\\nThis will help you find the right info when needed.\\nWhen solving a problem, make sure to load the relevant info in context before planning.\\nYou can load a single file with a `cat` command executed in a `single` action.\\n`head`, `tail`, `grep`, `find`, `tree`, ... all have their uses.\\n\\nFor code source files it may be interesting to add line numbers.\\nMore advanced scripts can be used, for instance to extract documentation from source files.\\nThis helps you to know how to use a file without loading all the code in context too.\\n\\nIf it isn\\'t clear what you should do next, check the filesystem for notes that may guide you!\\n\\n# Iterative Problem Solving\\n\\nTake small steps and verify your work.\\nCreate unit tests for all your work so you can do regression tests after each step.\\n\\nKeep notes of when you started on a subtask and which solutions you tried.\\nThis way you avoid repeating yourself and decide when to look for an alternative approach to a problem.\\n\\nVersion control tools help remember steps taken, solutions tried and files modified.\\nMake extensive use of `git`!\\n\\nYour most important tool is the reasoning action.\\nYou should reason about everything you\\'ll do before issuing a command in the next iteration!\\nInspect your previous actions in detail.\\nIf something didn\\'t work, try to understand why and don\\'t repeat the same mistake.\\nDon\\'t delete mistakes until you understand them.\\n\\nIf you notice parse_error entries in the context you have made a mistake.\\nReason about the error before trying again.\\n\\n# User interaction\\n\\nYou are always working for a user.\\nGet to know them and make notes about what you learn from them.\\nBe a helpful assistant to the user.\\nOpen the relevant user notes when you interact with them.\\n\\nThe main way to communicate is using standard io.\\nThe user may want you to set up alternative communication methods.\\nUse scripts and background processes to do so.\\n\\nThe user may take some time to respond or may forget to respond.\\nKeep detailed notes of your interactions and your expectations regarding time!\\nAvoid overflowing the user with many messages.\\n\\n\\n\\n\\n \\n \\n \\n \\n \\n \\n\\n \\n \\n \\n \\n\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n\\n \\n \\n \\n \\n \\n \\n \\n \\n\\n \\n \\n \\n \\n\\n \\n \\n \\n \\n \\n \\n \\n \\n\\n'},\n",
- " {'role': 'user',\n",
- " 'content': '\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\nAt node \"evaluate_test_results\". Entry 45f3d2 shows failed test: \"Error: Connection timeout\". \\nWill need to check system logs soon (noted in /tasks/reminders.txt, check at 14:00).\\nFirst focusing on this error.\\n\\n```\\n\\n## Reasons to Switch Procedures\\n\\nCommon triggers:\\n - Data available on stdin\\n - Time matching scheduled task\\n - Error conditions in script output\\n - Resource constraints detected\\n - User input needed]]>\\n \\n \\n \\n \\n \\n \\n Also load the last 10 messages from /user/conversation_history/ ]\\n PrepareForDraft{Have everything needed for drafting a message?}\\n DraftMessage[Draft message in reasoning entry]\\n ReadInput[Read input from standard input]\\n ReasonCleanContext[List id\\'s of entries that are no longer needed
Explain for each entry why it is no longer needed]\\n DeleteEntries[Remove the entries that are no longer needed
End by deleting the ReasonCleanContext entry]\\n AddHistoryUser[Add the message to the /user/conversation_history/ directory
The filename is the id of the stdin entry with .user extension]\\n LoadTask[Look for the task in the /tasks directory and load relevant files]\\n LoadUserDetails[Look in the /user directory for relevant files]\\n EstimateScript[Draft the script in a reasoning block and estimate its runtime and output length]\\n ScriptAcceptable{Does the draft script make sense and are the estimations short enough to not hinder the conversation?}\\n RunScript[Run the script, make sure to set appropriate timeout and output limits]\\n ReviewDraft{Is the message well structured and free of logical errors?}\\n SendMessage[Send the message using standard output]\\n AddHistoryAgent[Add the message to the /user/conversation_history/ directory
The filename is the id of the stdout entry with .agent extension]\\n ReasonResponse[Is the conversation ongoing?
How long is the user expected to take to respond?]\\n NeedAwaitResponse{Is it likely to get a response within a minute?}\\n BusyWait[Wait 1 second for the first busy wait, double the time each iteration until a response is received
Make sure to set the timout]\\n\\n End([Clean the context])\\n\\n Start --> LoadUserBasic\\n LoadUserBasic --> PrepareForDraft\\n\\n PrepareForDraft -->|Got all needed info| DraftMessage\\n PrepareForDraft -->|Getting the required info would slow the conversation| DraftMessage\\n PrepareForDraft -->|Input available on stdin| ReadInput\\n PrepareForDraft -->|Context usage more than 50%| ReasonCleanContext\\n PrepareForDraft -->|Task mentioned but not loaded| LoadTask\\n PrepareForDraft -->|Personal or social info mentioned but not loaded| LoadUserDetails\\n PrepareForDraft -->|Calculations, system info or other numerical values that can be scripted are mentioned| EstimateScript\\n\\n ReasonCleanContext --> DeleteEntries\\n DeleteEntries --> PrepareForDraft\\n\\n ReadInput --> AddHistoryUser\\n AddHistoryUser --> PrepareForDraft\\n\\n LoadTask --> PrepareForDraft\\n LoadUserDetails --> PrepareForDraft\\n\\n EstimateScript --> ScriptAcceptable\\n ScriptAcceptable -->|Acceptable| RunScript\\n ScriptAcceptable -->|Not acceptable| PrepareForDraft\\n RunScript --> PrepareForDraft\\n \\n DraftMessage --> ReviewDraft{Is this really what I want to say?}\\n ReviewDraft -->|Rewrite better| DraftMessage\\n ReviewDraft -->|Good message| SendMessage\\n \\n SendMessage --> AddHistoryAgent\\n AddHistoryAgent --> ReasonResponse\\n ReasonResponse --> NeedAwaitResponse\\n \\n NeedAwaitResponse -->|Quick response is unlikely| End\\n NeedAwaitResponse -->|Input available on stdin| PrepareForDraft\\n NeedAwaitResponse -->|Quick response is likely| BusyWait\\n BusyWait --> NeedAwaitResponse\\n```]]>\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n'},\n",
- " {'role': 'assistant', 'content': ''}]}"
- ]
- },
- "execution_count": 11,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"dataset[5]"
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "training_args = TrainingArguments(\n",
+ " output_dir=str(args.output_dir),\n",
+ " num_train_epochs=3,\n",
+ " per_device_train_batch_size=1,\n",
+ " gradient_accumulation_steps=16,\n",
+ " gradient_checkpointing=True,\n",
+ " learning_rate=2e-5,\n",
+ " lr_scheduler_type=\"cosine\",\n",
+ " warmup_ratio=0.05,\n",
+ " weight_decay=0.01,\n",
+ " fp16=not is_bfloat16_supported(),\n",
+ " bf16=is_bfloat16_supported(),\n",
+ " logging_steps=10,\n",
+ " save_steps=200,\n",
+ " save_total_limit=3,\n",
+ " report_to=\"none\",\n",
+ " optim=\"adamw_8bit\",\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "trainer = SFTTrainer(\n",
+ " model=model,\n",
+ " tokenizer=tokenizer,\n",
+ " args=training_args,\n",
+ " train_dataset=dataset.to_transformers_dataset(tokenizer),\n",
+ " dataset_text_field=\"messages\",\n",
+ " max_seq_length=max_seq_length,\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "trainer.train()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "model.save_pretrained_merged(\n",
+ " str(args.output_dir), \n",
+ " tokenizer=tokenizer,\n",
+ " save_method=\"merged_16bit\"\n",
+ ")"
+ ]
}
],
"metadata": {
"kernelspec": {
"display_name": "train",
"language": "python",
- "name": "train"
+ "name": "python3"
},
"language_info": {
"codemirror_mode": {