{"cells":[{"cell_type":"code","source":["%load_ext autoreload\n","%autoreload 2"],"metadata":{"id":"uWKRSV6eZsCn","executionInfo":{"status":"ok","timestamp":1720711613956,"user_tz":-480,"elapsed":2,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"colab":{"base_uri":"https://localhost:8080/"},"outputId":"10de0285-c19b-4aff-b2cd-b89e259adc47"},"execution_count":21,"outputs":[{"output_type":"stream","name":"stdout","text":["The autoreload extension is already loaded. To reload it, use:\n"," %reload_ext autoreload\n"]}]},{"cell_type":"code","execution_count":22,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{"byteLimit":2048000,"rowLimit":10000},"inputWidgets":{},"nuid":"eb33b19f-1206-41ee-84e2-e6258a12eef7","showTitle":false,"title":""},"colab":{"base_uri":"https://localhost:8080/"},"id":"xwFh14uiZBrI","executionInfo":{"status":"ok","timestamp":1720711640125,"user_tz":-480,"elapsed":13209,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"a308789f-8ca4-46ca-b535-a662dfb45082"},"outputs":[{"output_type":"stream","name":"stdout","text":["Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n"]}],"source":["from google.colab import drive\n","drive.mount('/content/drive')"]},{"cell_type":"code","execution_count":23,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{"byteLimit":2048000,"rowLimit":10000},"inputWidgets":{},"nuid":"6d394937-6c99-4a7c-9d32-7600a280032f","showTitle":false,"title":""},"colab":{"base_uri":"https://localhost:8080/"},"id":"G5pNu3zgZBrL","executionInfo":{"status":"ok","timestamp":1720711640125,"user_tz":-480,"elapsed":9,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"e0f0ac3f-6bbb-4381-a527-5c679b67300f"},"outputs":[{"output_type":"stream","name":"stdout","text":["workding dir: /content/drive/MyDrive/logical-reasoning/\n"]}],"source":["import os\n","import sys\n","from pathlib import Path\n","\n","workding_dir = \"/content/drive/MyDrive/logical-reasoning/\"\n","os.chdir(workding_dir)\n","sys.path.append(workding_dir)\n","print(\"workding dir:\", workding_dir)"]},{"cell_type":"code","execution_count":24,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{"byteLimit":2048000,"rowLimit":10000},"inputWidgets":{},"nuid":"ac667aba-076e-4de6-9984-8f6a67cb09cd","showTitle":false,"title":""},"colab":{"base_uri":"https://localhost:8080/"},"id":"0dVRAabNZBrL","executionInfo":{"status":"ok","timestamp":1720711640125,"user_tz":-480,"elapsed":7,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"d97dd29b-ab43-4fc3-8e38-571280e598de"},"outputs":[{"output_type":"execute_result","data":{"text/plain":["False"]},"metadata":{},"execution_count":24}],"source":["need_to_setup_env = False\n","need_to_setup_env"]},{"cell_type":"code","execution_count":25,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{"byteLimit":2048000,"rowLimit":10000},"inputWidgets":{},"nuid":"72f9cf79-7b0d-4d9e-90a0-1fa5251b947f","showTitle":false,"title":""},"id":"hKUOfP2HZBrL","executionInfo":{"status":"ok","timestamp":1720711640126,"user_tz":-480,"elapsed":7,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}}},"outputs":[],"source":["if need_to_setup_env:\n"," %pip install -r requirements.txt\n"," %cd /content/\n"," %rm -rf LLaMA-Factory\n"," !git clone https://github.com/hiyouga/LLaMA-Factory.git\n"," %cd LLaMA-Factory\n"," %ls\n"," %pip install -e .[torch,bitsandbytes]"]},{"cell_type":"code","execution_count":26,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{"byteLimit":2048000,"rowLimit":10000},"inputWidgets":{},"nuid":"c06c61fd-4c6f-4099-bd3b-46188ab835d7","showTitle":false,"title":""},"colab":{"base_uri":"https://localhost:8080/"},"id":"txOgnjwYZBrL","executionInfo":{"status":"ok","timestamp":1720711640126,"user_tz":-480,"elapsed":7,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"21f082c1-5cf8-4292-c18d-868f03fc5d8d"},"outputs":[{"output_type":"stream","name":"stdout","text":["workding dir: /content/drive/MyDrive/logical-reasoning/\n"]}],"source":["os.chdir(workding_dir)\n","sys.path.append(workding_dir)\n","print(\"workding dir:\", workding_dir)"]},{"cell_type":"code","execution_count":27,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{"byteLimit":2048000,"rowLimit":10000},"inputWidgets":{},"nuid":"9f67ec60-2f24-411c-84eb-0dd664b44775","showTitle":false,"title":""},"colab":{"base_uri":"https://localhost:8080/"},"id":"hPCC-6m7ZBrM","executionInfo":{"status":"ok","timestamp":1720711640126,"user_tz":-480,"elapsed":7,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"96d5a6cf-988d-4f21-dc30-bfeb52d61dd1"},"outputs":[{"output_type":"stream","name":"stdout","text":["loading env vars from: /content/drive/MyDrive/logical-reasoning/.env\n"]},{"output_type":"execute_result","data":{"text/plain":["True"]},"metadata":{},"execution_count":27}],"source":["from dotenv import find_dotenv, load_dotenv\n","\n","found_dotenv = find_dotenv(\".env\")\n","\n","if len(found_dotenv) == 0:\n"," found_dotenv = find_dotenv(\".env.example\")\n","print(f\"loading env vars from: {found_dotenv}\")\n","load_dotenv(found_dotenv, override=True)"]},{"cell_type":"code","execution_count":28,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{"byteLimit":2048000,"rowLimit":10000},"inputWidgets":{},"nuid":"f1597656-8042-4878-9d3b-9ebfb8dd86dc","showTitle":false,"title":""},"colab":{"base_uri":"https://localhost:8080/"},"id":"1M3IraVtZBrM","executionInfo":{"status":"ok","timestamp":1720711640126,"user_tz":-480,"elapsed":6,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"9f129c9e-7293-4c25-cca5-7ae4fdcab979"},"outputs":[{"output_type":"stream","name":"stdout","text":["internlm/internlm2_5-7b-chat-1m None True datasets/mgtv results/mgtv-results_colab_p2.csv False\n"]}],"source":["import os\n","\n","model_name = os.getenv(\"MODEL_NAME\")\n","adapter_name_or_path = os.getenv(\"ADAPTER_NAME_OR_PATH\")\n","load_in_4bit = os.getenv(\"LOAD_IN_4BIT\") == \"true\"\n","data_path = os.getenv(\"LOGICAL_REASONING_DATA_PATH\")\n","results_path = os.getenv(\"LOGICAL_REASONING_RESULTS_PATH\")\n","use_english_datasets = os.getenv(\"USE_ENGLISH_DATASETS\") == \"true\"\n","\n","print(model_name, adapter_name_or_path, load_in_4bit, data_path, results_path, use_english_datasets)"]},{"cell_type":"code","execution_count":29,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{"byteLimit":2048000,"rowLimit":10000},"inputWidgets":{},"nuid":"e3ab54ba-7b6d-4817-bf2e-c5d711508b58","showTitle":false,"title":""},"colab":{"base_uri":"https://localhost:8080/"},"id":"mrVEz6UsZBrM","executionInfo":{"status":"ok","timestamp":1720711640126,"user_tz":-480,"elapsed":6,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"57e472ec-cdee-47d3-b1da-5a5ca3e58131"},"outputs":[{"output_type":"stream","name":"stdout","text":["Thu Jul 11 15:27:19 2024 \n","+---------------------------------------------------------------------------------------+\n","| NVIDIA-SMI 535.104.05 Driver Version: 535.104.05 CUDA Version: 12.2 |\n","|-----------------------------------------+----------------------+----------------------+\n","| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |\n","| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |\n","| | | MIG M. |\n","|=========================================+======================+======================|\n","| 0 NVIDIA L4 Off | 00000000:00:03.0 Off | 0 |\n","| N/A 39C P8 12W / 72W | 1MiB / 23034MiB | 0% Default |\n","| | | N/A |\n","+-----------------------------------------+----------------------+----------------------+\n"," \n","+---------------------------------------------------------------------------------------+\n","| Processes: |\n","| GPU GI CI PID Type Process name GPU Memory |\n","| ID ID Usage |\n","|=======================================================================================|\n","| No running processes found |\n","+---------------------------------------------------------------------------------------+\n"]}],"source":["!nvidia-smi"]},{"cell_type":"code","execution_count":30,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{"byteLimit":2048000,"rowLimit":10000},"inputWidgets":{},"nuid":"b2a43943-9324-4839-9a47-cfa72de2244b","showTitle":false,"title":""},"colab":{"base_uri":"https://localhost:8080/"},"id":"UgMvt6dIZBrM","executionInfo":{"status":"ok","timestamp":1720711640126,"user_tz":-480,"elapsed":5,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"f7790506-b806-43ca-89eb-24c7f5471bfc"},"outputs":[{"output_type":"stream","name":"stdout","text":["Python 3.10.12\n","\u001b[33mWARNING: Package(s) not found: flash-attn\u001b[0m\u001b[33m\n","\u001b[0mCPU times: user 10.1 ms, sys: 1.94 ms, total: 12 ms\n","Wall time: 610 ms\n"]}],"source":["%%time\n","!python --version\n","!pip show flash-attn"]},{"cell_type":"code","execution_count":31,"metadata":{"id":"ZuS_FsLyZBrN","executionInfo":{"status":"ok","timestamp":1720711640126,"user_tz":-480,"elapsed":4,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}}},"outputs":[],"source":["from llm_toolkit.logical_reasoning_utils import *"]},{"cell_type":"code","execution_count":32,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":224},"id":"muFDE9DpZBrN","executionInfo":{"status":"ok","timestamp":1720711642271,"user_tz":-480,"elapsed":2149,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"00ed5651-ae27-4292-a23c-f1c9952b9197"},"outputs":[{"output_type":"stream","name":"stdout","text":["loading existing data from: llama-factory/data/alpaca_mgtv_p2.json\n"]},{"output_type":"execute_result","data":{"text/plain":[" instruction input output\n","0 你是一个情景猜谜游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜面,谜面会描述一... 不是\n","1 你是一个情景猜谜游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜面,谜面会描述一... 不是\n","2 你是一个情景猜谜游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜面,谜面会描述一... 不重要\n","3 你是一个情景猜谜游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜面,谜面会描述一... 不是\n","4 你是一个情景猜谜游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜面,谜面会描述一... 是"],"text/html":["\n","
\n"," | instruction | \n","input | \n","output | \n","
---|---|---|---|
0 | \n","你是一个情景猜谜游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜面,谜面会描述一... | \n","\n"," | 不是 | \n","
1 | \n","你是一个情景猜谜游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜面,谜面会描述一... | \n","\n"," | 不是 | \n","
2 | \n","你是一个情景猜谜游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜面,谜面会描述一... | \n","\n"," | 不重要 | \n","
3 | \n","你是一个情景猜谜游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜面,谜面会描述一... | \n","\n"," | 不是 | \n","
4 | \n","你是一个情景猜谜游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜面,谜面会描述一... | \n","\n"," | 是 | \n","