{"cells":[{"cell_type":"code","source":["%load_ext autoreload\n","%autoreload 2"],"metadata":{"id":"uWKRSV6eZsCn","executionInfo":{"status":"ok","timestamp":1720679526275,"user_tz":-480,"elapsed":476,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}}},"execution_count":1,"outputs":[]},{"cell_type":"code","execution_count":2,"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":1720679529344,"user_tz":-480,"elapsed":2534,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"d767799c-34c2-46a5-f052-378146a55321"},"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":3,"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":1720679529345,"user_tz":-480,"elapsed":5,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"160a554f-fb08-4aa0-bc00-0422fb7c1fac"},"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":4,"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":1720679529345,"user_tz":-480,"elapsed":4,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"b977e116-df16-47cd-9160-a24f611da687"},"outputs":[{"output_type":"execute_result","data":{"text/plain":["False"]},"metadata":{},"execution_count":4}],"source":["need_to_setup_env = False\n","need_to_setup_env"]},{"cell_type":"code","execution_count":5,"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":1720679529345,"user_tz":-480,"elapsed":4,"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":6,"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":1720679529345,"user_tz":-480,"elapsed":4,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"c10df404-fcbf-47bc-8344-637240adb6a2"},"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":7,"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":1720679529345,"user_tz":-480,"elapsed":3,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"c7aa2c96-5e99-440a-c148-201d79465ff9"},"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":7}],"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":8,"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":1720679529345,"user_tz":-480,"elapsed":3,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"29ab35f6-2970-4ade-d85d-3174acf8cda0"},"outputs":[{"output_type":"stream","name":"stdout","text":["Qwen2/Qwen2-7B-Instruct None True datasets/mgtv results/mgtv-results_colab_p1.csv\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)"]},{"cell_type":"code","execution_count":9,"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":1720679529345,"user_tz":-480,"elapsed":2,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"8bcff769-2573-4dae-e124-d5b5d2382d71"},"outputs":[{"output_type":"stream","name":"stdout","text":["Thu Jul 11 06:32:08 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 55C P8 17W / 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":10,"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":1720679529907,"user_tz":-480,"elapsed":564,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"ce37581c-fd26-46c2-ad87-d933d99f68f7"},"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 11 ms, sys: 1.41 ms, total: 12.4 ms\n","Wall time: 609 ms\n"]}],"source":["%%time\n","!python --version\n","!pip show flash-attn"]},{"cell_type":"code","execution_count":11,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"ZuS_FsLyZBrN","executionInfo":{"status":"ok","timestamp":1720679531591,"user_tz":-480,"elapsed":1685,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"2cba0105-c505-4395-afbd-2f2fee6581d0"},"outputs":[{"output_type":"stream","name":"stdout","text":["loading /content/drive/MyDrive/logical-reasoning/llm_toolkit/logical_reasoning_utils.py\n"]}],"source":["from llm_toolkit.logical_reasoning_utils import *"]},{"cell_type":"code","execution_count":12,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":311},"id":"muFDE9DpZBrN","executionInfo":{"status":"ok","timestamp":1720679532304,"user_tz":-480,"elapsed":715,"user":{"displayName":"HUANG DONGHAO _","userId":"00977795705617022768"}},"outputId":"95672b22-99b7-41b7-f992-18b193994f66"},"outputs":[{"output_type":"stream","name":"stdout","text":["loading existing data from: llama-factory/data/alpaca_mgtv_p1.json\n"]},{"output_type":"execute_result","data":{"text/plain":[" instruction input output\n","0 你是一个逻辑游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜题。\\n2. 参与者... 不是\n","1 你是一个逻辑游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜题。\\n2. 参与者... 不是\n","2 你是一个逻辑游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜题。\\n2. 参与者... 不重要\n","3 你是一个逻辑游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜题。\\n2. 参与者... 不是\n","4 你是一个逻辑游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜题。\\n2. 参与者... 是"],"text/html":["\n","
\n"," | instruction | \n","input | \n","output | \n","
---|---|---|---|
0 | \n","你是一个逻辑游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜题。\\n2. 参与者... | \n","\n"," | 不是 | \n","
1 | \n","你是一个逻辑游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜题。\\n2. 参与者... | \n","\n"," | 不是 | \n","
2 | \n","你是一个逻辑游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜题。\\n2. 参与者... | \n","\n"," | 不重要 | \n","
3 | \n","你是一个逻辑游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜题。\\n2. 参与者... | \n","\n"," | 不是 | \n","
4 | \n","你是一个逻辑游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜题。\\n2. 参与者... | \n","\n"," | 是 | \n","