{ "cells": [ { "cell_type": "code", "execution_count": 2, "id": "9524095d", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: pandas in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (2.3.0)\n", "Requirement already satisfied: numpy in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (2.3.1)\n", "Requirement already satisfied: matplotlib in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (3.10.3)\n", "Requirement already satisfied: seaborn in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (0.13.2)\n", "Requirement already satisfied: datasets in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (3.6.0)\n", "Requirement already satisfied: python-dateutil>=2.8.2 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from pandas) (2.9.0.post0)\n", "Requirement already satisfied: pytz>=2020.1 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from pandas) (2025.2)\n", "Requirement already satisfied: tzdata>=2022.7 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from pandas) (2025.2)\n", "Requirement already satisfied: contourpy>=1.0.1 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from matplotlib) (1.3.2)\n", "Requirement already satisfied: cycler>=0.10 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from matplotlib) (0.12.1)\n", "Requirement already satisfied: fonttools>=4.22.0 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from matplotlib) (4.58.4)\n", "Requirement already satisfied: kiwisolver>=1.3.1 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from matplotlib) (1.4.8)\n", "Requirement already satisfied: packaging>=20.0 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from matplotlib) (25.0)\n", "Requirement already satisfied: pillow>=8 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from matplotlib) (11.2.1)\n", "Requirement already satisfied: pyparsing>=2.3.1 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from matplotlib) (3.2.3)\n", "Requirement already satisfied: filelock in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from datasets) (3.18.0)\n", "Requirement already satisfied: pyarrow>=15.0.0 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from datasets) (20.0.0)\n", "Requirement already satisfied: dill<0.3.9,>=0.3.0 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from datasets) (0.3.8)\n", "Requirement already satisfied: requests>=2.32.2 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from datasets) (2.32.4)\n", "Requirement already satisfied: tqdm>=4.66.3 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from datasets) (4.67.1)\n", "Requirement already satisfied: xxhash in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from datasets) (3.5.0)\n", "Requirement already satisfied: multiprocess<0.70.17 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from datasets) (0.70.16)\n", "Requirement already satisfied: fsspec<=2025.3.0,>=2023.1.0 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (2025.3.0)\n", "Requirement already satisfied: huggingface-hub>=0.24.0 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from datasets) (0.33.1)\n", "Requirement already satisfied: pyyaml>=5.1 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from datasets) (6.0.2)\n", "Requirement already satisfied: aiohttp!=4.0.0a0,!=4.0.0a1 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (3.12.13)\n", "Requirement already satisfied: aiohappyeyeballs>=2.5.0 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (2.6.1)\n", "Requirement already satisfied: aiosignal>=1.1.2 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (1.3.2)\n", "Requirement already satisfied: attrs>=17.3.0 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (25.3.0)\n", "Requirement already satisfied: frozenlist>=1.1.1 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (1.7.0)\n", "Requirement already satisfied: multidict<7.0,>=4.5 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (6.6.0)\n", "Requirement already satisfied: propcache>=0.2.0 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (0.3.2)\n", "Requirement already satisfied: yarl<2.0,>=1.17.0 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (1.20.1)\n", "Requirement already satisfied: idna>=2.0 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from yarl<2.0,>=1.17.0->aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (3.10)\n", "Requirement already satisfied: typing-extensions>=3.7.4.3 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from huggingface-hub>=0.24.0->datasets) (4.14.0)\n", "Requirement already satisfied: six>=1.5 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from python-dateutil>=2.8.2->pandas) (1.17.0)\n", "Requirement already satisfied: charset_normalizer<4,>=2 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from requests>=2.32.2->datasets) (3.4.2)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from requests>=2.32.2->datasets) (2.5.0)\n", "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from requests>=2.32.2->datasets) (2025.6.15)\n", "Requirement already satisfied: colorama in c:\\users\\a.s.ivanov\\pycharmprojects\\1c_coder\\.venv\\lib\\site-packages (from tqdm>=4.66.3->datasets) (0.4.6)\n", "Note: you may need to restart the kernel to use updated packages.\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "c:\\Users\\a.s.ivanov\\PycharmProjects\\1C_CODER\\.venv\\Lib\\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" ] } ], "source": [ "%pip install pandas numpy matplotlib seaborn datasets\n", "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", "import datasets\n" ] }, { "cell_type": "code", "execution_count": 3, "id": "a889b205", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
sourcein_source_idpromptthink_processsolutionis_answer_a_linkhas_linktags_service
0forum_infostarttopic328184Здравствуйте. УНФ, есть запрос\\n\\n```1c\\n \"...<think>\\nЗдравствуйте. УНФ, есть запрос\\n\\n```...# Код Реализации\\n```1c\\n ВЫБРАТЬ\\n Това...FalseNaNУТ
1forum_infostarttopic328235Задача простая. Необходимо заполнить документ ...<think>\\nЗадача простая. Необходимо заполнить ...Для РН можно получить только весь набор регист...FalseNaNNaN
2forum_infostarttopic327650Доброго времени суток.\\nПосле обновления УТ на...<think>\\nДоброго времени суток.\\nПосле обновле...Может кому пригодится в последнем релизе не уд...FalseNaNERP
3forum_infostarttopic328246Здравствуйте, столкнулся с такой проблемой. Пр...<think>\\nЗдравствуйте, столкнулся с такой проб...Если оплата кредита, тогда без НДС.FalseNaNБухгалтерия
4forum_infostarttopic328236Доброго дня всем!\\n\\nСохраняю данные Таблицы з...<think>\\nДоброго дня всем!\\n\\nСохраняю данные ...Да зачем все эти построители-шмостроители для ...FalseNaNNaN
\n", "
" ], "text/plain": [ " source in_source_id \\\n", "0 forum_infostart topic328184 \n", "1 forum_infostart topic328235 \n", "2 forum_infostart topic327650 \n", "3 forum_infostart topic328246 \n", "4 forum_infostart topic328236 \n", "\n", " prompt \\\n", "0 Здравствуйте. УНФ, есть запрос\\n\\n```1c\\n \"... \n", "1 Задача простая. Необходимо заполнить документ ... \n", "2 Доброго времени суток.\\nПосле обновления УТ на... \n", "3 Здравствуйте, столкнулся с такой проблемой. Пр... \n", "4 Доброго дня всем!\\n\\nСохраняю данные Таблицы з... \n", "\n", " think_process \\\n", "0 \\nЗдравствуйте. УНФ, есть запрос\\n\\n```... \n", "1 \\nЗадача простая. Необходимо заполнить ... \n", "2 \\nДоброго времени суток.\\nПосле обновле... \n", "3 \\nЗдравствуйте, столкнулся с такой проб... \n", "4 \\nДоброго дня всем!\\n\\nСохраняю данные ... \n", "\n", " solution is_answer_a_link \\\n", "0 # Код Реализации\\n```1c\\n ВЫБРАТЬ\\n Това... False \n", "1 Для РН можно получить только весь набор регист... False \n", "2 Может кому пригодится в последнем релизе не уд... False \n", "3 Если оплата кредита, тогда без НДС. False \n", "4 Да зачем все эти построители-шмостроители для ... False \n", "\n", " has_link tags_service \n", "0 NaN УТ \n", "1 NaN NaN \n", "2 NaN ERP \n", "3 NaN Бухгалтерия \n", "4 NaN NaN " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_think = pd.read_csv('result_forums_infostart_WITH_CODE.csv')\n", "df_think.head()" ] }, { "cell_type": "code", "execution_count": 4, "id": "6078c4af", "metadata": {}, "outputs": [], "source": [ "df_regular = pd.read_csv('result_forums_fastcode.csv')" ] }, { "cell_type": "code", "execution_count": 7, "id": "aa0275f3", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\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", " \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", " \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", "
sourcein_source_idpromptthink_processsolutionis_answer_a_linkhas_linktags_servicetags
0forum_infostarttopic328184Здравствуйте. УНФ, есть запрос\\n\\n```1c\\n \"...<think>\\nЗдравствуйте. УНФ, есть запрос\\n\\n```...# Код Реализации\\n```1c\\n ВЫБРАТЬ\\n Това...FalseNaNУТNaN
1forum_infostarttopic328235Задача простая. Необходимо заполнить документ ...<think>\\nЗадача простая. Необходимо заполнить ...Для РН можно получить только весь набор регист...FalseNaNNaNNaN
2forum_infostarttopic327650Доброго времени суток.\\nПосле обновления УТ на...<think>\\nДоброго времени суток.\\nПосле обновле...Может кому пригодится в последнем релизе не уд...FalseNaNERPNaN
3forum_infostarttopic328246Здравствуйте, столкнулся с такой проблемой. Пр...<think>\\nЗдравствуйте, столкнулся с такой проб...Если оплата кредита, тогда без НДС.FalseNaNБухгалтерияNaN
4forum_infostarttopic328236Доброго дня всем!\\n\\nСохраняю данные Таблицы з...<think>\\nДоброго дня всем!\\n\\nСохраняю данные ...Да зачем все эти построители-шмостроители для ...FalseNaNNaNNaN
..............................
19036fastcode_Templates13ЗаполнитьМассивУникальнымиЗначениямиNaNЗаполняет массив-приемник уникальными значения...FalseNaNЗУП1С,Коллекции
19037fastcode_Templates12ДобавитьИтераторТаблицеNaNДобавляет колонку в таблицу значений. Заполняе...FalseNaNNaN
19038fastcode_Templates7ТаблицаЗначенийВМассивNaNПреобразует таблицу значений в массив.\\n\\n# Ко...FalseNaNУТ1С,Коллекции
19039fastcode_Templates5Получить дату файлаNaNФункция определяет дату последней модификации ...FalseNaNРозница1С,Дата
19040fastcode_Templates4Получить имя файлаNaNСоставляет полное имя файла из имени каталога ...FalseNaNУТ
\n", "

19041 rows × 9 columns

\n", "
" ], "text/plain": [ " source in_source_id \\\n", "0 forum_infostart topic328184 \n", "1 forum_infostart topic328235 \n", "2 forum_infostart topic327650 \n", "3 forum_infostart topic328246 \n", "4 forum_infostart topic328236 \n", "... ... ... \n", "19036 fastcode_Templates 13 \n", "19037 fastcode_Templates 12 \n", "19038 fastcode_Templates 7 \n", "19039 fastcode_Templates 5 \n", "19040 fastcode_Templates 4 \n", "\n", " prompt \\\n", "0 Здравствуйте. УНФ, есть запрос\\n\\n```1c\\n \"... \n", "1 Задача простая. Необходимо заполнить документ ... \n", "2 Доброго времени суток.\\nПосле обновления УТ на... \n", "3 Здравствуйте, столкнулся с такой проблемой. Пр... \n", "4 Доброго дня всем!\\n\\nСохраняю данные Таблицы з... \n", "... ... \n", "19036 ЗаполнитьМассивУникальнымиЗначениями \n", "19037 ДобавитьИтераторТаблице \n", "19038 ТаблицаЗначенийВМассив \n", "19039 Получить дату файла \n", "19040 Получить имя файла \n", "\n", " think_process \\\n", "0 \\nЗдравствуйте. УНФ, есть запрос\\n\\n```... \n", "1 \\nЗадача простая. Необходимо заполнить ... \n", "2 \\nДоброго времени суток.\\nПосле обновле... \n", "3 \\nЗдравствуйте, столкнулся с такой проб... \n", "4 \\nДоброго дня всем!\\n\\nСохраняю данные ... \n", "... ... \n", "19036 NaN \n", "19037 NaN \n", "19038 NaN \n", "19039 NaN \n", "19040 NaN \n", "\n", " solution is_answer_a_link \\\n", "0 # Код Реализации\\n```1c\\n ВЫБРАТЬ\\n Това... False \n", "1 Для РН можно получить только весь набор регист... False \n", "2 Может кому пригодится в последнем релизе не уд... False \n", "3 Если оплата кредита, тогда без НДС. False \n", "4 Да зачем все эти построители-шмостроители для ... False \n", "... ... ... \n", "19036 Заполняет массив-приемник уникальными значения... False \n", "19037 Добавляет колонку в таблицу значений. Заполняе... False \n", "19038 Преобразует таблицу значений в массив.\\n\\n# Ко... False \n", "19039 Функция определяет дату последней модификации ... False \n", "19040 Составляет полное имя файла из имени каталога ... False \n", "\n", " has_link tags_service tags \n", "0 NaN УТ NaN \n", "1 NaN NaN NaN \n", "2 NaN ERP NaN \n", "3 NaN Бухгалтерия NaN \n", "4 NaN NaN NaN \n", "... ... ... ... \n", "19036 NaN ЗУП 1С,Коллекции \n", "19037 NaN NaN 1С \n", "19038 NaN УТ 1С,Коллекции \n", "19039 NaN Розница 1С,Дата \n", "19040 NaN УТ 1С \n", "\n", "[19041 rows x 9 columns]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result_df = pd.concat([df_think, df_regular], ignore_index=True)\n", "result_df" ] }, { "cell_type": "code", "execution_count": 8, "id": "41fce790", "metadata": {}, "outputs": [], "source": [ "result_df.drop(columns=['tags_service'], inplace=True)" ] }, { "cell_type": "code", "execution_count": 9, "id": "2fd66671", "metadata": {}, "outputs": [], "source": [ "result_df.to_csv('result_parsing_forums.csv', index=False)" ] }, { "cell_type": "code", "execution_count": null, "id": "9788c8b5", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "fd259c4b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "''" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\"\"\"\n", "Make dataset from forums to learn LLM\n", "\n", "[\n", "{\n", "\"content\": \"Please summarize the goals for scientists in this text:\\n\\nWithin three days, the intertwined cup nest of grasses was complete, featuring a canopy of overhanging grasses to conceal it. And decades later, it served as Rinkert’s portal to the past inside the California Academy of Sciences. Information gleaned from such nests, woven long ago from species in plant communities called transitional habitat, could help restore the shoreline in the future. Transitional habitat has nearly disappeared from the San Francisco Bay, and scientists need a clearer picture of its original species composition—which was never properly documented. With that insight, conservation research groups like the San Francisco Bay Bird Observatory can help guide best practices when restoring the native habitat that has long served as critical refuge for imperiled birds and animals as adjacent marshes flood more with rising sea levels. “We can’t ask restoration ecologists to plant nonnative species or to just take their best guess and throw things out there,” says Rinkert.\",\n", "\"role\": \"user\"\n", "},\n", "{\n", "\"content\": \"Scientists are studying nests hoping to learn about transitional habitats that could help restore the shoreline of San Francisco Bay.\",\n", "\"role\": \"assistant\"\n", "}\n", "]\n", "\"\"\"\n", "\n", "\"\"\"\n", "For this task, you can use CSV or JSONL data. If you are formatting the data yourself (adding start, end tokens, etc.), you can use CSV or JSONL format. If you do not want to format the data yourself and want --chat-template parameter to format the data for you, you must use JSONL format. In both cases, CSV and JSONL can be used interchangeably but JSONL is the most preferred format.\n", "\n", "To train a chatbot, your data will have content and role. Some models support system role as well.\n", "\n", "Here is an example of a chatbot dataset (single sample):\n", "\n", "Copied\n", "[{'content': 'Help write a letter of 100 -200 words to my future self for '\n", " 'Kyra, reflecting on her goals and aspirations.',\n", " 'role': 'user'},\n", " {'content': 'Dear Future Self,\\n'\n", " '\\n'\n", " \"I hope you're happy and proud of what you've achieved. As I \"\n", " \"write this, I'm excited to think about our goals and how far \"\n", " \"you've come. One goal was to be a machine learning engineer. I \"\n", " \"hope you've worked hard and become skilled in this field. Keep \"\n", " 'learning and innovating. Traveling was important to us. I hope '\n", " \"you've seen different places and enjoyed the beauty of our \"\n", " 'world. Remember the memories and lessons. Starting a family '\n", " 'mattered to us. If you have kids, treasure every moment. Be '\n", " 'patient, loving, and grateful for your family.\\n'\n", " '\\n'\n", " 'Take care of yourself. Rest, reflect, and cherish the time you '\n", " 'spend with loved ones. Remember your dreams and celebrate what '\n", " \"you've achieved. Your determination brought you here. I'm \"\n", " \"excited to see the person you've become, the impact you've made, \"\n", " 'and the love and joy in your life. Embrace opportunities and '\n", " 'keep dreaming big.\\n'\n", " '\\n'\n", " 'With love,\\n'\n", " 'Kyra',\n", " 'role': 'assistant'}]\n", "As you can see, the data has content and role columns. The role column can be user or assistant or system. This data is, however, not formatted for training. You can use the --chat-template parameter to format the data during training.\n", "\n", "--chat-template supports the following kinds of templates:\n", "\n", "none (default)\n", "zephyr\n", "chatml\n", "tokenizer: use chat template mentioned in tokenizer config\n", "A multi-line sample is also shown below:\n", "\n", "Copied\n", "[{\"content\": \"hello\", \"role\": \"user\"}, {\"content\": \"hi nice to meet you\", \"role\": \"assistant\"}]\n", "[{\"content\": \"how are you\", \"role\": \"user\"}, {\"content\": \"I am fine\", \"role\": \"assistant\"}]\n", "[{\"content\": \"What is your name?\", \"role\": \"user\"}, {\"content\": \"My name is Mary\", \"role\": \"assistant\"}]\n", "[{\"content\": \"Which is the best programming language?\", \"role\": \"user\"}, {\"content\": \"Python\", \"role\": \"assistant\"}]\n", ".\n", ".\n", ".\n", "\"\"\"" ] }, { "cell_type": "code", "execution_count": 14, "id": "b7d0bc0b", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import json\n", "\n", "df = result_df.copy()\n", "# Convert DataFrame to training format\n", "training_data = []\n", "\n", "for _, row in df.iterrows():\n", " # Create user message from prompt\n", " user_msg = {\n", " \"content\": row[\"prompt\"],\n", " \"role\": \"user\"\n", " }\n", " \n", " # Create assistant message from solution\n", " assistant_msg = {\n", " \"content\": row[\"solution\"],\n", " \"role\": \"assistant\" \n", " }\n", " \n", " # Add think process as system message if present\n", " if pd.notna(row[\"think_process\"]):\n", " system_msg = {\n", " \"content\": row[\"think_process\"],\n", " \"role\": \"assistant\"\n", " }\n", " training_data.append([user_msg, system_msg, assistant_msg])\n", " else:\n", " training_data.append([user_msg, assistant_msg])\n", "\n", "# Save to JSONL file\n", "with open('training_data.jsonl', 'w', encoding='utf-8') as f:\n", " for messages in training_data:\n", " f.write(json.dumps(messages, ensure_ascii=False) + '\\n')\n" ] }, { "cell_type": "code", "execution_count": null, "id": "8cc4e93b", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "705b1d94", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.7" } }, "nbformat": 4, "nbformat_minor": 5 }