danhtran2mind commited on
Commit
739fa89
·
verified ·
1 Parent(s): 3254cd5

Upload gemma-3-1b-it-vi-medical-lora.ipynb

Browse files
notebooks/gemma-3-1b-it-vi-medical-lora.ipynb ADDED
@@ -0,0 +1,2669 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {
7
+ "execution": {
8
+ "iopub.execute_input": "2025-07-01T00:43:44.761300Z",
9
+ "iopub.status.busy": "2025-07-01T00:43:44.760658Z"
10
+ },
11
+ "trusted": true
12
+ },
13
+ "outputs": [
14
+ {
15
+ "name": "stdout",
16
+ "output_type": "stream",
17
+ "text": [
18
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m664.8/664.8 MB\u001b[0m \u001b[31m2.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m0:00:01\u001b[0m00:01\u001b[0m\n",
19
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m363.4/363.4 MB\u001b[0m \u001b[31m4.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m0:00:01\u001b[0m00:01\u001b[0m\n",
20
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m211.5/211.5 MB\u001b[0m \u001b[31m8.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m0:00:01\u001b[0m00:01\u001b[0m\n",
21
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m56.3/56.3 MB\u001b[0m \u001b[31m30.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m00:01\u001b[0m\n",
22
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m127.9/127.9 MB\u001b[0m \u001b[31m13.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m00:01\u001b[0m\n",
23
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m207.5/207.5 MB\u001b[0m \u001b[31m8.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m0:00:01\u001b[0m00:01\u001b[0m\n",
24
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m21.1/21.1 MB\u001b[0m \u001b[31m80.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m00:01\u001b[0m\n",
25
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m43.4/43.4 MB\u001b[0m \u001b[31m40.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m00:01\u001b[0m\n",
26
+ "\u001b[?25h"
27
+ ]
28
+ }
29
+ ],
30
+ "source": [
31
+ "import os\n",
32
+ "os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"0\"\n",
33
+ "\n",
34
+ "!pip install pip3-autoremove -q\n",
35
+ "!pip install torch torchvision torchaudio xformers --index-url https://download.pytorch.org/whl/cu124 -q\n",
36
+ "!pip install unsloth -q\n",
37
+ "!pip install --upgrade transformers==4.52.4 -q"
38
+ ]
39
+ },
40
+ {
41
+ "cell_type": "code",
42
+ "execution_count": 3,
43
+ "metadata": {
44
+ "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19",
45
+ "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5",
46
+ "execution": {
47
+ "iopub.execute_input": "2025-06-29T14:17:21.211986Z",
48
+ "iopub.status.busy": "2025-06-29T14:17:21.211758Z",
49
+ "iopub.status.idle": "2025-06-29T14:17:21.215729Z",
50
+ "shell.execute_reply": "2025-06-29T14:17:21.214988Z",
51
+ "shell.execute_reply.started": "2025-06-29T14:17:21.211963Z"
52
+ },
53
+ "trusted": true
54
+ },
55
+ "outputs": [],
56
+ "source": [
57
+ "# !pip install -q unsloth"
58
+ ]
59
+ },
60
+ {
61
+ "cell_type": "code",
62
+ "execution_count": 4,
63
+ "metadata": {
64
+ "execution": {
65
+ "iopub.execute_input": "2025-06-29T14:17:21.217031Z",
66
+ "iopub.status.busy": "2025-06-29T14:17:21.216786Z",
67
+ "iopub.status.idle": "2025-06-29T14:17:21.232729Z",
68
+ "shell.execute_reply": "2025-06-29T14:17:21.232151Z",
69
+ "shell.execute_reply.started": "2025-06-29T14:17:21.217009Z"
70
+ },
71
+ "trusted": true
72
+ },
73
+ "outputs": [],
74
+ "source": [
75
+ "# unsloth.__version__ 2025.6.3\n",
76
+ "# torch.__version__ 2.7.0+cu126\n",
77
+ "# transformers.__version__ 4.51.3"
78
+ ]
79
+ },
80
+ {
81
+ "cell_type": "code",
82
+ "execution_count": 2,
83
+ "metadata": {
84
+ "execution": {
85
+ "iopub.execute_input": "2025-06-30T11:12:18.756914Z",
86
+ "iopub.status.busy": "2025-06-30T11:12:18.756665Z",
87
+ "iopub.status.idle": "2025-06-30T11:12:56.778348Z",
88
+ "shell.execute_reply": "2025-06-30T11:12:56.777554Z",
89
+ "shell.execute_reply.started": "2025-06-30T11:12:18.756889Z"
90
+ },
91
+ "trusted": true
92
+ },
93
+ "outputs": [
94
+ {
95
+ "name": "stdout",
96
+ "output_type": "stream",
97
+ "text": [
98
+ "🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.\n"
99
+ ]
100
+ },
101
+ {
102
+ "name": "stderr",
103
+ "output_type": "stream",
104
+ "text": [
105
+ "2025-06-30 11:12:34.293119: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:477] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n",
106
+ "WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n",
107
+ "E0000 00:00:1751281954.642221 35 cuda_dnn.cc:8310] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n",
108
+ "E0000 00:00:1751281954.741210 35 cuda_blas.cc:1418] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n"
109
+ ]
110
+ },
111
+ {
112
+ "name": "stdout",
113
+ "output_type": "stream",
114
+ "text": [
115
+ "🦥 Unsloth Zoo will now patch everything to make training faster!\n",
116
+ "datasets.__version__ 3.6.0\n",
117
+ "numpy.__version__ 1.26.4\n",
118
+ "unsloth.__version__ 2025.6.8\n",
119
+ "torch.__version__ 2.6.0+cu124\n",
120
+ "transformers.__version__ 4.52.4\n",
121
+ "trl.__version__ 0.19.0\n"
122
+ ]
123
+ }
124
+ ],
125
+ "source": [
126
+ "import datasets\n",
127
+ "import numpy as np\n",
128
+ "import unsloth\n",
129
+ "import torch\n",
130
+ "import trl \n",
131
+ "import transformers\n",
132
+ "import unsloth\n",
133
+ "\n",
134
+ "print(\"datasets.__version__\", datasets.__version__)\n",
135
+ "print(\"numpy.__version__\", np.__version__)\n",
136
+ "print(\"unsloth.__version__\", unsloth.__version__)\n",
137
+ "print(\"torch.__version__\", torch.__version__)\n",
138
+ "print(\"transformers.__version__\", transformers.__version__)\n",
139
+ "print(\"trl.__version__\", trl.__version__)\n",
140
+ "\n",
141
+ "# datasets.__version__ 3.6.0\n",
142
+ "# numpy.__version__ 1.26.4\n",
143
+ "# unsloth.__version__ 2025.6.3\n",
144
+ "# torch.__version__ 2.7.0+cu126\n",
145
+ "# transformers.__version__ 4.51.3\n",
146
+ "# trl.__version__ 0.19.0"
147
+ ]
148
+ },
149
+ {
150
+ "cell_type": "code",
151
+ "execution_count": 2,
152
+ "metadata": {
153
+ "execution": {
154
+ "iopub.status.idle": "2025-07-01T00:46:24.938147Z",
155
+ "shell.execute_reply": "2025-07-01T00:46:24.937610Z",
156
+ "shell.execute_reply.started": "2025-07-01T00:45:37.385513Z"
157
+ },
158
+ "trusted": true
159
+ },
160
+ "outputs": [
161
+ {
162
+ "name": "stdout",
163
+ "output_type": "stream",
164
+ "text": [
165
+ "🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.\n"
166
+ ]
167
+ },
168
+ {
169
+ "name": "stderr",
170
+ "output_type": "stream",
171
+ "text": [
172
+ "2025-07-01 00:45:57.117936: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:477] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n",
173
+ "WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n",
174
+ "E0000 00:00:1751330757.494502 35 cuda_dnn.cc:8310] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n",
175
+ "E0000 00:00:1751330757.608435 35 cuda_blas.cc:1418] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n"
176
+ ]
177
+ },
178
+ {
179
+ "name": "stdout",
180
+ "output_type": "stream",
181
+ "text": [
182
+ "🦥 Unsloth Zoo will now patch everything to make training faster!\n"
183
+ ]
184
+ }
185
+ ],
186
+ "source": [
187
+ "import numpy as np\n",
188
+ "from datasets import concatenate_datasets, load_dataset\n",
189
+ "\n",
190
+ "# from unsloth import FastLanguageModel\n",
191
+ "from unsloth import is_bfloat16_supported\n",
192
+ "from unsloth.chat_templates import train_on_responses_only \n",
193
+ "import torch\n",
194
+ "\n",
195
+ "from trl import SFTTrainer\n",
196
+ "from transformers import TrainingArguments, DataCollatorForSeq2Seq\n",
197
+ "\n",
198
+ "from unsloth import FastModel\n",
199
+ "from unsloth.chat_templates import get_chat_template"
200
+ ]
201
+ },
202
+ {
203
+ "cell_type": "code",
204
+ "execution_count": 3,
205
+ "metadata": {
206
+ "execution": {
207
+ "iopub.execute_input": "2025-07-01T00:46:24.939341Z",
208
+ "iopub.status.busy": "2025-07-01T00:46:24.938843Z",
209
+ "iopub.status.idle": "2025-07-01T00:46:27.456270Z",
210
+ "shell.execute_reply": "2025-07-01T00:46:27.455585Z",
211
+ "shell.execute_reply.started": "2025-07-01T00:46:24.939317Z"
212
+ },
213
+ "trusted": true
214
+ },
215
+ "outputs": [
216
+ {
217
+ "data": {
218
+ "application/vnd.jupyter.widget-view+json": {
219
+ "model_id": "6b25027f3202421187304cc74a99db43",
220
+ "version_major": 2,
221
+ "version_minor": 0
222
+ },
223
+ "text/plain": [
224
+ "README.md: 0.00B [00:00, ?B/s]"
225
+ ]
226
+ },
227
+ "metadata": {},
228
+ "output_type": "display_data"
229
+ },
230
+ {
231
+ "data": {
232
+ "application/vnd.jupyter.widget-view+json": {
233
+ "model_id": "3e38dc9e2d6846c18670dc9092532e9f",
234
+ "version_major": 2,
235
+ "version_minor": 0
236
+ },
237
+ "text/plain": [
238
+ "train-00000-of-00001.parquet: 0%| | 0.00/8.68M [00:00<?, ?B/s]"
239
+ ]
240
+ },
241
+ "metadata": {},
242
+ "output_type": "display_data"
243
+ },
244
+ {
245
+ "data": {
246
+ "application/vnd.jupyter.widget-view+json": {
247
+ "model_id": "127258aacffd49aca900769ed881115b",
248
+ "version_major": 2,
249
+ "version_minor": 0
250
+ },
251
+ "text/plain": [
252
+ "test-00000-of-00001.parquet: 0%| | 0.00/501k [00:00<?, ?B/s]"
253
+ ]
254
+ },
255
+ "metadata": {},
256
+ "output_type": "display_data"
257
+ },
258
+ {
259
+ "data": {
260
+ "application/vnd.jupyter.widget-view+json": {
261
+ "model_id": "9cf1f2206e7a4badae148e952ba680f8",
262
+ "version_major": 2,
263
+ "version_minor": 0
264
+ },
265
+ "text/plain": [
266
+ "validation-00000-of-00001.parquet: 0%| | 0.00/478k [00:00<?, ?B/s]"
267
+ ]
268
+ },
269
+ "metadata": {},
270
+ "output_type": "display_data"
271
+ },
272
+ {
273
+ "data": {
274
+ "application/vnd.jupyter.widget-view+json": {
275
+ "model_id": "c02509dbdc784f55ac9410ceb97c3b8d",
276
+ "version_major": 2,
277
+ "version_minor": 0
278
+ },
279
+ "text/plain": [
280
+ "Generating train split: 0%| | 0/14121 [00:00<?, ? examples/s]"
281
+ ]
282
+ },
283
+ "metadata": {},
284
+ "output_type": "display_data"
285
+ },
286
+ {
287
+ "data": {
288
+ "application/vnd.jupyter.widget-view+json": {
289
+ "model_id": "93ee47a6b07348c2befe067843d2d5d9",
290
+ "version_major": 2,
291
+ "version_minor": 0
292
+ },
293
+ "text/plain": [
294
+ "Generating test split: 0%| | 0/785 [00:00<?, ? examples/s]"
295
+ ]
296
+ },
297
+ "metadata": {},
298
+ "output_type": "display_data"
299
+ },
300
+ {
301
+ "data": {
302
+ "application/vnd.jupyter.widget-view+json": {
303
+ "model_id": "0f224c2daf65432b8b69767dff475999",
304
+ "version_major": 2,
305
+ "version_minor": 0
306
+ },
307
+ "text/plain": [
308
+ "Generating validation split: 0%| | 0/784 [00:00<?, ? examples/s]"
309
+ ]
310
+ },
311
+ "metadata": {},
312
+ "output_type": "display_data"
313
+ }
314
+ ],
315
+ "source": [
316
+ "dataset_id = \"tmnam20/ViMedAQA\"\n",
317
+ "subset = \"disease\"\n",
318
+ "dataset = load_dataset(dataset_id, subset)"
319
+ ]
320
+ },
321
+ {
322
+ "cell_type": "code",
323
+ "execution_count": 4,
324
+ "metadata": {
325
+ "execution": {
326
+ "iopub.execute_input": "2025-07-01T00:46:27.457881Z",
327
+ "iopub.status.busy": "2025-07-01T00:46:27.457664Z",
328
+ "iopub.status.idle": "2025-07-01T00:46:27.472441Z",
329
+ "shell.execute_reply": "2025-07-01T00:46:27.471596Z",
330
+ "shell.execute_reply.started": "2025-07-01T00:46:27.457864Z"
331
+ },
332
+ "trusted": true
333
+ },
334
+ "outputs": [
335
+ {
336
+ "name": "stdout",
337
+ "output_type": "stream",
338
+ "text": [
339
+ "Number of training samples: 14121\n",
340
+ "Number of test samples: 1569\n"
341
+ ]
342
+ }
343
+ ],
344
+ "source": [
345
+ "# Merge training and validation samples\n",
346
+ "test_samples = concatenate_datasets([dataset['validation'],\n",
347
+ " dataset['test']])\n",
348
+ "\n",
349
+ "# Shuffle the merged dataset with a fixed random seed\n",
350
+ "training_samples = dataset['train']\n",
351
+ "test_samples = test_samples.shuffle(seed=42)\n",
352
+ "\n",
353
+ "print(\"Number of training samples:\", training_samples.num_rows)\n",
354
+ "print(\"Number of test samples:\", test_samples.num_rows)"
355
+ ]
356
+ },
357
+ {
358
+ "cell_type": "code",
359
+ "execution_count": 9,
360
+ "metadata": {
361
+ "execution": {
362
+ "iopub.execute_input": "2025-06-29T14:18:00.140694Z",
363
+ "iopub.status.busy": "2025-06-29T14:18:00.140365Z",
364
+ "iopub.status.idle": "2025-06-29T14:18:00.153352Z",
365
+ "shell.execute_reply": "2025-06-29T14:18:00.152782Z",
366
+ "shell.execute_reply.started": "2025-06-29T14:18:00.140666Z"
367
+ },
368
+ "trusted": true
369
+ },
370
+ "outputs": [
371
+ {
372
+ "data": {
373
+ "text/plain": [
374
+ "{'question_idx': 'disease_13345',\n",
375
+ " 'question': 'Khi soi bằng đèn thường, triệu chứng điển hình của viêm mống mắt là gì?',\n",
376
+ " 'answer': 'Đồng tử 2 bên không đều nhau, đồng tử bên bệnh nhỏ hơn bên bình thường.',\n",
377
+ " 'context': '5.1 Nhìn về mặt đại thể (khi soi bằng đèn thường) - Đồng tử 2 bên không đều nhau (bên bệnh nhỏ hơn) Có thể phát hiện đồng tử co bên bệnh lý co nhiều hơn bên bình thường, điều này có thể do viêm nhiều dẫn đến dính thành sau mống mắt lại với nhau và với thuỷ tinh thể. Thông thường kích thường đồng tử là 2 – 3 mm, đều 2 bên. - Mủ ở đáy mống mắt (mủ tiền phòng) Đây là hiện tượng các tế bào viêm cùng với chất tiết (chứa nhiều fibrin). Mủ nằm ở dưới là do nguyên nhân trọng lực. 5.2 Khám mắt qua đèn khe: (split lamp) Đây là công cụ chuyên dụng của bác sĩ chuyên khoa Mắt. Qua đèn khe, bác sĩ có thể phát hiện: - Các tế bào nằm giữa giác mạc và mống mắt Số lượng tế bào này trên diện tích 1 mm² giúp phân độ nặng của viêm màng bồ đào. - Độ mờ thuỷ dịch Như đã miêu tả, thuỷ dịch là dịch trong suốt nằm giữa giác mạc ở ngoài cùng và mống mắt ở trong. Khi viêm màng bồ đào trước, dịch này sẽ bị vẩn đục. Tương tự như việc đếm số lượng tế bào ở thuỷ dịch, ta cũng phân độ nhờ vào mức độ đục của nó. - Sự lắng đọng keratic Sự lắng đọng keratic tạo thành tam giác Arlt. Tam giác Arlt được tạo thành nhờ các kết tụ tế bào viêm nằm ngay sau giác mạc. Trên đèn khe tam giác này có đỉnh nằm trên, đáy nằm dưới. Tạo hình này do trọng lực gây ra. - Xơ hoá fibrin Do mủ trong thuỷ dịch + viêm màng bồ đào trước diễn ra lâu dài, không điều trị kịp thời. - Ngoài ra còn nhiều dấu hiệu khác trên đèn khe Nốt mống mắt, dính mống mắt – thuỷ tinh thế, thiểu sản mống mắt, tăng sinh mạch máu mống mắt.',\n",
378
+ " 'title': 'Triệu chứng - Triệu chứng qua thăm khám',\n",
379
+ " 'keyword': 'Viêm mống mắt',\n",
380
+ " 'topic': 1,\n",
381
+ " 'article_url': 'https://youmed.vn/tin-tuc/viem-mong-mat-nguyen-nhan-gay-mu-loa/',\n",
382
+ " 'author': 'Bác sĩ Nguyễn Đoàn Trọng Nhân',\n",
383
+ " 'author_url': 'https://youmed.vn/tin-tuc/bac-si/nguyen-doan-trong-nhan/'}"
384
+ ]
385
+ },
386
+ "execution_count": 9,
387
+ "metadata": {},
388
+ "output_type": "execute_result"
389
+ }
390
+ ],
391
+ "source": [
392
+ "dataset['train'][0]"
393
+ ]
394
+ },
395
+ {
396
+ "cell_type": "code",
397
+ "execution_count": null,
398
+ "metadata": {
399
+ "execution": {
400
+ "iopub.execute_input": "2025-07-01T00:46:27.473675Z",
401
+ "iopub.status.busy": "2025-07-01T00:46:27.473397Z",
402
+ "iopub.status.idle": "2025-07-01T00:46:27.569951Z",
403
+ "shell.execute_reply": "2025-07-01T00:46:27.569278Z",
404
+ "shell.execute_reply.started": "2025-07-01T00:46:27.473652Z"
405
+ },
406
+ "trusted": true
407
+ },
408
+ "outputs": [],
409
+ "source": [
410
+ "# To temporary Model hub\n",
411
+ "from huggingface_hub import HfApi\n",
412
+ "from huggingface_hub import login\n",
413
+ "# Initialize API\n",
414
+ "login(\"\")\n",
415
+ "api = HfApi()"
416
+ ]
417
+ },
418
+ {
419
+ "cell_type": "code",
420
+ "execution_count": null,
421
+ "metadata": {
422
+ "execution": {
423
+ "iopub.execute_input": "2025-07-01T00:46:27.571055Z",
424
+ "iopub.status.busy": "2025-07-01T00:46:27.570798Z",
425
+ "iopub.status.idle": "2025-07-01T00:46:33.994389Z",
426
+ "shell.execute_reply": "2025-07-01T00:46:33.993805Z",
427
+ "shell.execute_reply.started": "2025-07-01T00:46:27.571034Z"
428
+ },
429
+ "trusted": true
430
+ },
431
+ "outputs": [
432
+ {
433
+ "data": {
434
+ "application/vnd.jupyter.widget-view+json": {
435
+ "model_id": "ba4d2adccf17476380c70e4807fa3932",
436
+ "version_major": 2,
437
+ "version_minor": 0
438
+ },
439
+ "text/plain": [
440
+ "Fetching 100 files: 0%| | 0/100 [00:00<?, ?it/s]"
441
+ ]
442
+ },
443
+ "metadata": {},
444
+ "output_type": "display_data"
445
+ },
446
+ {
447
+ "data": {
448
+ "application/vnd.jupyter.widget-view+json": {
449
+ "model_id": "10cb68b5ad4946b1935b74a2c7b02d97",
450
+ "version_major": 2,
451
+ "version_minor": 0
452
+ },
453
+ "text/plain": [
454
+ "README.md: 0.00B [00:00, ?B/s]"
455
+ ]
456
+ },
457
+ "metadata": {},
458
+ "output_type": "display_data"
459
+ },
460
+ {
461
+ "data": {
462
+ "application/vnd.jupyter.widget-view+json": {
463
+ "model_id": "b844665181b74b26aabecef25b296e05",
464
+ "version_major": 2,
465
+ "version_minor": 0
466
+ },
467
+ "text/plain": [
468
+ "chat_template.jinja: 0.00B [00:00, ?B/s]"
469
+ ]
470
+ },
471
+ "metadata": {},
472
+ "output_type": "display_data"
473
+ },
474
+ {
475
+ "data": {
476
+ "application/vnd.jupyter.widget-view+json": {
477
+ "model_id": "5561c4ab02754b4d9fa7dab9508837ef",
478
+ "version_major": 2,
479
+ "version_minor": 0
480
+ },
481
+ "text/plain": [
482
+ "adapter_config.json: 0.00B [00:00, ?B/s]"
483
+ ]
484
+ },
485
+ "metadata": {},
486
+ "output_type": "display_data"
487
+ },
488
+ {
489
+ "data": {
490
+ "application/vnd.jupyter.widget-view+json": {
491
+ "model_id": "8725719f426d4783a7f759108069ebb3",
492
+ "version_major": 2,
493
+ "version_minor": 0
494
+ },
495
+ "text/plain": [
496
+ "README.md: 0.00B [00:00, ?B/s]"
497
+ ]
498
+ },
499
+ "metadata": {},
500
+ "output_type": "display_data"
501
+ },
502
+ {
503
+ "data": {
504
+ "application/vnd.jupyter.widget-view+json": {
505
+ "model_id": "b8a78caafbad4cf59fe50c031609342e",
506
+ "version_major": 2,
507
+ "version_minor": 0
508
+ },
509
+ "text/plain": [
510
+ "optimizer.pt: 0%| | 0.00/27.9M [00:00<?, ?B/s]"
511
+ ]
512
+ },
513
+ "metadata": {},
514
+ "output_type": "display_data"
515
+ },
516
+ {
517
+ "data": {
518
+ "application/vnd.jupyter.widget-view+json": {
519
+ "model_id": "e9b15a7df8e04b24971240e494c04694",
520
+ "version_major": 2,
521
+ "version_minor": 0
522
+ },
523
+ "text/plain": [
524
+ "adapter_model.safetensors: 0%| | 0.00/52.2M [00:00<?, ?B/s]"
525
+ ]
526
+ },
527
+ "metadata": {},
528
+ "output_type": "display_data"
529
+ },
530
+ {
531
+ "data": {
532
+ "application/vnd.jupyter.widget-view+json": {
533
+ "model_id": "254b14d3a8974e56b61c4915f71bfe92",
534
+ "version_major": 2,
535
+ "version_minor": 0
536
+ },
537
+ "text/plain": [
538
+ ".gitattributes: 0.00B [00:00, ?B/s]"
539
+ ]
540
+ },
541
+ "metadata": {},
542
+ "output_type": "display_data"
543
+ },
544
+ {
545
+ "data": {
546
+ "application/vnd.jupyter.widget-view+json": {
547
+ "model_id": "f8d1f1ba5bba47028883eb480be977f9",
548
+ "version_major": 2,
549
+ "version_minor": 0
550
+ },
551
+ "text/plain": [
552
+ "scheduler.pt: 0%| | 0.00/1.06k [00:00<?, ?B/s]"
553
+ ]
554
+ },
555
+ "metadata": {},
556
+ "output_type": "display_data"
557
+ },
558
+ {
559
+ "data": {
560
+ "application/vnd.jupyter.widget-view+json": {
561
+ "model_id": "08a0f2686022428787ec43d83d744b8a",
562
+ "version_major": 2,
563
+ "version_minor": 0
564
+ },
565
+ "text/plain": [
566
+ "rng_state.pth: 0%| | 0.00/14.2k [00:00<?, ?B/s]"
567
+ ]
568
+ },
569
+ "metadata": {},
570
+ "output_type": "display_data"
571
+ },
572
+ {
573
+ "data": {
574
+ "application/vnd.jupyter.widget-view+json": {
575
+ "model_id": "4cad8b0972024b2b91dc0ab100215c87",
576
+ "version_major": 2,
577
+ "version_minor": 0
578
+ },
579
+ "text/plain": [
580
+ "added_tokens.json: 0%| | 0.00/35.0 [00:00<?, ?B/s]"
581
+ ]
582
+ },
583
+ "metadata": {},
584
+ "output_type": "display_data"
585
+ },
586
+ {
587
+ "data": {
588
+ "application/vnd.jupyter.widget-view+json": {
589
+ "model_id": "43e032a289e04cadbb871b4ca5e56c64",
590
+ "version_major": 2,
591
+ "version_minor": 0
592
+ },
593
+ "text/plain": [
594
+ "special_tokens_map.json: 0%| | 0.00/670 [00:00<?, ?B/s]"
595
+ ]
596
+ },
597
+ "metadata": {},
598
+ "output_type": "display_data"
599
+ },
600
+ {
601
+ "data": {
602
+ "application/vnd.jupyter.widget-view+json": {
603
+ "model_id": "1dd45cecd76341bf907eee1b1e0c2f51",
604
+ "version_major": 2,
605
+ "version_minor": 0
606
+ },
607
+ "text/plain": [
608
+ "training_args.bin: 0%| | 0.00/5.69k [00:00<?, ?B/s]"
609
+ ]
610
+ },
611
+ "metadata": {},
612
+ "output_type": "display_data"
613
+ },
614
+ {
615
+ "data": {
616
+ "application/vnd.jupyter.widget-view+json": {
617
+ "model_id": "56893242e0384c39b6eb1de63187b60a",
618
+ "version_major": 2,
619
+ "version_minor": 0
620
+ },
621
+ "text/plain": [
622
+ "tokenizer.json: 0%| | 0.00/33.4M [00:00<?, ?B/s]"
623
+ ]
624
+ },
625
+ "metadata": {},
626
+ "output_type": "display_data"
627
+ },
628
+ {
629
+ "data": {
630
+ "application/vnd.jupyter.widget-view+json": {
631
+ "model_id": "5ac31d72ef3c485089280955323677ad",
632
+ "version_major": 2,
633
+ "version_minor": 0
634
+ },
635
+ "text/plain": [
636
+ "tokenizer_config.json: 0.00B [00:00, ?B/s]"
637
+ ]
638
+ },
639
+ "metadata": {},
640
+ "output_type": "display_data"
641
+ },
642
+ {
643
+ "data": {
644
+ "application/vnd.jupyter.widget-view+json": {
645
+ "model_id": "9c61816796bf4cdc9f07edd1f1b49b31",
646
+ "version_major": 2,
647
+ "version_minor": 0
648
+ },
649
+ "text/plain": [
650
+ "tokenizer.model: 0%| | 0.00/4.69M [00:00<?, ?B/s]"
651
+ ]
652
+ },
653
+ "metadata": {},
654
+ "output_type": "display_data"
655
+ },
656
+ {
657
+ "data": {
658
+ "application/vnd.jupyter.widget-view+json": {
659
+ "model_id": "70da8f17a602474394da533173d4cac5",
660
+ "version_major": 2,
661
+ "version_minor": 0
662
+ },
663
+ "text/plain": [
664
+ "trainer_state.json: 0.00B [00:00, ?B/s]"
665
+ ]
666
+ },
667
+ "metadata": {},
668
+ "output_type": "display_data"
669
+ },
670
+ {
671
+ "data": {
672
+ "application/vnd.jupyter.widget-view+json": {
673
+ "model_id": "9b626b67fd7146fbbf75315ad0f39f57",
674
+ "version_major": 2,
675
+ "version_minor": 0
676
+ },
677
+ "text/plain": [
678
+ "README.md: 0.00B [00:00, ?B/s]"
679
+ ]
680
+ },
681
+ "metadata": {},
682
+ "output_type": "display_data"
683
+ },
684
+ {
685
+ "data": {
686
+ "application/vnd.jupyter.widget-view+json": {
687
+ "model_id": "39a9166305b648f2ae2eaf9699832d94",
688
+ "version_major": 2,
689
+ "version_minor": 0
690
+ },
691
+ "text/plain": [
692
+ "adapter_config.json: 0.00B [00:00, ?B/s]"
693
+ ]
694
+ },
695
+ "metadata": {},
696
+ "output_type": "display_data"
697
+ },
698
+ {
699
+ "data": {
700
+ "application/vnd.jupyter.widget-view+json": {
701
+ "model_id": "3a21f96c70624984b91efb4acaf47e35",
702
+ "version_major": 2,
703
+ "version_minor": 0
704
+ },
705
+ "text/plain": [
706
+ "adapter_model.safetensors: 0%| | 0.00/52.2M [00:00<?, ?B/s]"
707
+ ]
708
+ },
709
+ "metadata": {},
710
+ "output_type": "display_data"
711
+ },
712
+ {
713
+ "data": {
714
+ "application/vnd.jupyter.widget-view+json": {
715
+ "model_id": "865960a08ae64765aadae367f260af39",
716
+ "version_major": 2,
717
+ "version_minor": 0
718
+ },
719
+ "text/plain": [
720
+ "added_tokens.json: 0%| | 0.00/35.0 [00:00<?, ?B/s]"
721
+ ]
722
+ },
723
+ "metadata": {},
724
+ "output_type": "display_data"
725
+ },
726
+ {
727
+ "data": {
728
+ "application/vnd.jupyter.widget-view+json": {
729
+ "model_id": "f00197600dbd4b1f8cfea4e20d821b41",
730
+ "version_major": 2,
731
+ "version_minor": 0
732
+ },
733
+ "text/plain": [
734
+ "rng_state.pth: 0%| | 0.00/14.2k [00:00<?, ?B/s]"
735
+ ]
736
+ },
737
+ "metadata": {},
738
+ "output_type": "display_data"
739
+ },
740
+ {
741
+ "data": {
742
+ "application/vnd.jupyter.widget-view+json": {
743
+ "model_id": "b016258193e8481a9c343781382f2d60",
744
+ "version_major": 2,
745
+ "version_minor": 0
746
+ },
747
+ "text/plain": [
748
+ "scheduler.pt: 0%| | 0.00/1.06k [00:00<?, ?B/s]"
749
+ ]
750
+ },
751
+ "metadata": {},
752
+ "output_type": "display_data"
753
+ },
754
+ {
755
+ "data": {
756
+ "application/vnd.jupyter.widget-view+json": {
757
+ "model_id": "8cce56fb1e6b404e90dfb28070c70986",
758
+ "version_major": 2,
759
+ "version_minor": 0
760
+ },
761
+ "text/plain": [
762
+ "optimizer.pt: 0%| | 0.00/27.9M [00:00<?, ?B/s]"
763
+ ]
764
+ },
765
+ "metadata": {},
766
+ "output_type": "display_data"
767
+ },
768
+ {
769
+ "data": {
770
+ "application/vnd.jupyter.widget-view+json": {
771
+ "model_id": "7926699fad36463798fe02b29b20f45e",
772
+ "version_major": 2,
773
+ "version_minor": 0
774
+ },
775
+ "text/plain": [
776
+ "tokenizer.json: 0%| | 0.00/33.4M [00:00<?, ?B/s]"
777
+ ]
778
+ },
779
+ "metadata": {},
780
+ "output_type": "display_data"
781
+ },
782
+ {
783
+ "data": {
784
+ "application/vnd.jupyter.widget-view+json": {
785
+ "model_id": "1344fe167c4b4a82af62c6b34383b9af",
786
+ "version_major": 2,
787
+ "version_minor": 0
788
+ },
789
+ "text/plain": [
790
+ "chat_template.jinja: 0.00B [00:00, ?B/s]"
791
+ ]
792
+ },
793
+ "metadata": {},
794
+ "output_type": "display_data"
795
+ },
796
+ {
797
+ "data": {
798
+ "application/vnd.jupyter.widget-view+json": {
799
+ "model_id": "d86855ad68244fe888a4fa50c55eec27",
800
+ "version_major": 2,
801
+ "version_minor": 0
802
+ },
803
+ "text/plain": [
804
+ "tokenizer.model: 0%| | 0.00/4.69M [00:00<?, ?B/s]"
805
+ ]
806
+ },
807
+ "metadata": {},
808
+ "output_type": "display_data"
809
+ },
810
+ {
811
+ "data": {
812
+ "application/vnd.jupyter.widget-view+json": {
813
+ "model_id": "22c5c72af3b7489c8554ba577bf5491e",
814
+ "version_major": 2,
815
+ "version_minor": 0
816
+ },
817
+ "text/plain": [
818
+ "special_tokens_map.json: 0%| | 0.00/670 [00:00<?, ?B/s]"
819
+ ]
820
+ },
821
+ "metadata": {},
822
+ "output_type": "display_data"
823
+ },
824
+ {
825
+ "data": {
826
+ "application/vnd.jupyter.widget-view+json": {
827
+ "model_id": "20f8eb7c6d99430cbc9b23c40e782e10",
828
+ "version_major": 2,
829
+ "version_minor": 0
830
+ },
831
+ "text/plain": [
832
+ "training_args.bin: 0%| | 0.00/5.69k [00:00<?, ?B/s]"
833
+ ]
834
+ },
835
+ "metadata": {},
836
+ "output_type": "display_data"
837
+ },
838
+ {
839
+ "data": {
840
+ "application/vnd.jupyter.widget-view+json": {
841
+ "model_id": "fad7ab9bd4414cc6a59aedc8cbee69f8",
842
+ "version_major": 2,
843
+ "version_minor": 0
844
+ },
845
+ "text/plain": [
846
+ "tokenizer_config.json: 0.00B [00:00, ?B/s]"
847
+ ]
848
+ },
849
+ "metadata": {},
850
+ "output_type": "display_data"
851
+ },
852
+ {
853
+ "data": {
854
+ "application/vnd.jupyter.widget-view+json": {
855
+ "model_id": "452245470d894f9fa66b26b70c630a05",
856
+ "version_major": 2,
857
+ "version_minor": 0
858
+ },
859
+ "text/plain": [
860
+ "trainer_state.json: 0.00B [00:00, ?B/s]"
861
+ ]
862
+ },
863
+ "metadata": {},
864
+ "output_type": "display_data"
865
+ },
866
+ {
867
+ "data": {
868
+ "application/vnd.jupyter.widget-view+json": {
869
+ "model_id": "1c96cfecce5d43ccab4d61e9183a6361",
870
+ "version_major": 2,
871
+ "version_minor": 0
872
+ },
873
+ "text/plain": [
874
+ "adapter_config.json: 0.00B [00:00, ?B/s]"
875
+ ]
876
+ },
877
+ "metadata": {},
878
+ "output_type": "display_data"
879
+ },
880
+ {
881
+ "data": {
882
+ "application/vnd.jupyter.widget-view+json": {
883
+ "model_id": "55b71cc0b0714898a1047204c67e3f5e",
884
+ "version_major": 2,
885
+ "version_minor": 0
886
+ },
887
+ "text/plain": [
888
+ "README.md: 0.00B [00:00, ?B/s]"
889
+ ]
890
+ },
891
+ "metadata": {},
892
+ "output_type": "display_data"
893
+ },
894
+ {
895
+ "data": {
896
+ "application/vnd.jupyter.widget-view+json": {
897
+ "model_id": "4cee5356e6be465996094abc47c70931",
898
+ "version_major": 2,
899
+ "version_minor": 0
900
+ },
901
+ "text/plain": [
902
+ "adapter_model.safetensors: 0%| | 0.00/52.2M [00:00<?, ?B/s]"
903
+ ]
904
+ },
905
+ "metadata": {},
906
+ "output_type": "display_data"
907
+ },
908
+ {
909
+ "data": {
910
+ "application/vnd.jupyter.widget-view+json": {
911
+ "model_id": "b8253d204f5e42f092a19c3c6e8316c7",
912
+ "version_major": 2,
913
+ "version_minor": 0
914
+ },
915
+ "text/plain": [
916
+ "rng_state.pth: 0%| | 0.00/14.2k [00:00<?, ?B/s]"
917
+ ]
918
+ },
919
+ "metadata": {},
920
+ "output_type": "display_data"
921
+ },
922
+ {
923
+ "data": {
924
+ "application/vnd.jupyter.widget-view+json": {
925
+ "model_id": "42eee71433504516855d26d13c90ab3b",
926
+ "version_major": 2,
927
+ "version_minor": 0
928
+ },
929
+ "text/plain": [
930
+ "added_tokens.json: 0%| | 0.00/35.0 [00:00<?, ?B/s]"
931
+ ]
932
+ },
933
+ "metadata": {},
934
+ "output_type": "display_data"
935
+ },
936
+ {
937
+ "data": {
938
+ "application/vnd.jupyter.widget-view+json": {
939
+ "model_id": "d6703d7c2c7d419ea430fe3e1f6a56cb",
940
+ "version_major": 2,
941
+ "version_minor": 0
942
+ },
943
+ "text/plain": [
944
+ "tokenizer.json: 0%| | 0.00/33.4M [00:00<?, ?B/s]"
945
+ ]
946
+ },
947
+ "metadata": {},
948
+ "output_type": "display_data"
949
+ },
950
+ {
951
+ "data": {
952
+ "application/vnd.jupyter.widget-view+json": {
953
+ "model_id": "3b10301c21ea4276afdd07993eca0a19",
954
+ "version_major": 2,
955
+ "version_minor": 0
956
+ },
957
+ "text/plain": [
958
+ "optimizer.pt: 0%| | 0.00/27.9M [00:00<?, ?B/s]"
959
+ ]
960
+ },
961
+ "metadata": {},
962
+ "output_type": "display_data"
963
+ },
964
+ {
965
+ "data": {
966
+ "application/vnd.jupyter.widget-view+json": {
967
+ "model_id": "c123b3f172294ba8875cffb3bc6b31b2",
968
+ "version_major": 2,
969
+ "version_minor": 0
970
+ },
971
+ "text/plain": [
972
+ "chat_template.jinja: 0.00B [00:00, ?B/s]"
973
+ ]
974
+ },
975
+ "metadata": {},
976
+ "output_type": "display_data"
977
+ },
978
+ {
979
+ "data": {
980
+ "application/vnd.jupyter.widget-view+json": {
981
+ "model_id": "307e15d3b5714686976b7da62dcaf320",
982
+ "version_major": 2,
983
+ "version_minor": 0
984
+ },
985
+ "text/plain": [
986
+ "scheduler.pt: 0%| | 0.00/1.06k [00:00<?, ?B/s]"
987
+ ]
988
+ },
989
+ "metadata": {},
990
+ "output_type": "display_data"
991
+ },
992
+ {
993
+ "data": {
994
+ "application/vnd.jupyter.widget-view+json": {
995
+ "model_id": "6f82911e58824254831741b3afea0fc3",
996
+ "version_major": 2,
997
+ "version_minor": 0
998
+ },
999
+ "text/plain": [
1000
+ "tokenizer.model: 0%| | 0.00/4.69M [00:00<?, ?B/s]"
1001
+ ]
1002
+ },
1003
+ "metadata": {},
1004
+ "output_type": "display_data"
1005
+ },
1006
+ {
1007
+ "data": {
1008
+ "application/vnd.jupyter.widget-view+json": {
1009
+ "model_id": "90676c23171e42e8be855325401bfe07",
1010
+ "version_major": 2,
1011
+ "version_minor": 0
1012
+ },
1013
+ "text/plain": [
1014
+ "special_tokens_map.json: 0%| | 0.00/670 [00:00<?, ?B/s]"
1015
+ ]
1016
+ },
1017
+ "metadata": {},
1018
+ "output_type": "display_data"
1019
+ },
1020
+ {
1021
+ "data": {
1022
+ "application/vnd.jupyter.widget-view+json": {
1023
+ "model_id": "2f4e1ae04b554da78a0c5015e7d0694c",
1024
+ "version_major": 2,
1025
+ "version_minor": 0
1026
+ },
1027
+ "text/plain": [
1028
+ "training_args.bin: 0%| | 0.00/5.69k [00:00<?, ?B/s]"
1029
+ ]
1030
+ },
1031
+ "metadata": {},
1032
+ "output_type": "display_data"
1033
+ },
1034
+ {
1035
+ "data": {
1036
+ "application/vnd.jupyter.widget-view+json": {
1037
+ "model_id": "f4132763e05c49abafcc2ad0b77e6199",
1038
+ "version_major": 2,
1039
+ "version_minor": 0
1040
+ },
1041
+ "text/plain": [
1042
+ "tokenizer_config.json: 0.00B [00:00, ?B/s]"
1043
+ ]
1044
+ },
1045
+ "metadata": {},
1046
+ "output_type": "display_data"
1047
+ },
1048
+ {
1049
+ "data": {
1050
+ "application/vnd.jupyter.widget-view+json": {
1051
+ "model_id": "c1d9d4a9b47843d4a72f7a7c671fa0c4",
1052
+ "version_major": 2,
1053
+ "version_minor": 0
1054
+ },
1055
+ "text/plain": [
1056
+ "trainer_state.json: 0.00B [00:00, ?B/s]"
1057
+ ]
1058
+ },
1059
+ "metadata": {},
1060
+ "output_type": "display_data"
1061
+ },
1062
+ {
1063
+ "data": {
1064
+ "application/vnd.jupyter.widget-view+json": {
1065
+ "model_id": "73f012af7bb542fd8064d95f21b5c3ca",
1066
+ "version_major": 2,
1067
+ "version_minor": 0
1068
+ },
1069
+ "text/plain": [
1070
+ "README.md: 0.00B [00:00, ?B/s]"
1071
+ ]
1072
+ },
1073
+ "metadata": {},
1074
+ "output_type": "display_data"
1075
+ },
1076
+ {
1077
+ "data": {
1078
+ "application/vnd.jupyter.widget-view+json": {
1079
+ "model_id": "f949ac2771224c4f954e3e5345a9f163",
1080
+ "version_major": 2,
1081
+ "version_minor": 0
1082
+ },
1083
+ "text/plain": [
1084
+ "adapter_model.safetensors: 0%| | 0.00/52.2M [00:00<?, ?B/s]"
1085
+ ]
1086
+ },
1087
+ "metadata": {},
1088
+ "output_type": "display_data"
1089
+ },
1090
+ {
1091
+ "data": {
1092
+ "application/vnd.jupyter.widget-view+json": {
1093
+ "model_id": "f1946bd2b37d405298206ff1044d7008",
1094
+ "version_major": 2,
1095
+ "version_minor": 0
1096
+ },
1097
+ "text/plain": [
1098
+ "adapter_config.json: 0.00B [00:00, ?B/s]"
1099
+ ]
1100
+ },
1101
+ "metadata": {},
1102
+ "output_type": "display_data"
1103
+ },
1104
+ {
1105
+ "data": {
1106
+ "application/vnd.jupyter.widget-view+json": {
1107
+ "model_id": "c61731ac8e1f4e1ab7ed5e5bf8844a23",
1108
+ "version_major": 2,
1109
+ "version_minor": 0
1110
+ },
1111
+ "text/plain": [
1112
+ "added_tokens.json: 0%| | 0.00/35.0 [00:00<?, ?B/s]"
1113
+ ]
1114
+ },
1115
+ "metadata": {},
1116
+ "output_type": "display_data"
1117
+ },
1118
+ {
1119
+ "data": {
1120
+ "application/vnd.jupyter.widget-view+json": {
1121
+ "model_id": "aad5e77aceb947f284ab4b7efb8e8afe",
1122
+ "version_major": 2,
1123
+ "version_minor": 0
1124
+ },
1125
+ "text/plain": [
1126
+ "chat_template.jinja: 0.00B [00:00, ?B/s]"
1127
+ ]
1128
+ },
1129
+ "metadata": {},
1130
+ "output_type": "display_data"
1131
+ },
1132
+ {
1133
+ "data": {
1134
+ "application/vnd.jupyter.widget-view+json": {
1135
+ "model_id": "36826cd34d05477a98b7d85377f3c33d",
1136
+ "version_major": 2,
1137
+ "version_minor": 0
1138
+ },
1139
+ "text/plain": [
1140
+ "scheduler.pt: 0%| | 0.00/1.06k [00:00<?, ?B/s]"
1141
+ ]
1142
+ },
1143
+ "metadata": {},
1144
+ "output_type": "display_data"
1145
+ },
1146
+ {
1147
+ "data": {
1148
+ "application/vnd.jupyter.widget-view+json": {
1149
+ "model_id": "6847af04c0204fc4b006de2a54e25cf6",
1150
+ "version_major": 2,
1151
+ "version_minor": 0
1152
+ },
1153
+ "text/plain": [
1154
+ "rng_state.pth: 0%| | 0.00/14.2k [00:00<?, ?B/s]"
1155
+ ]
1156
+ },
1157
+ "metadata": {},
1158
+ "output_type": "display_data"
1159
+ },
1160
+ {
1161
+ "data": {
1162
+ "application/vnd.jupyter.widget-view+json": {
1163
+ "model_id": "bcc12c14c36c4231847de76808166647",
1164
+ "version_major": 2,
1165
+ "version_minor": 0
1166
+ },
1167
+ "text/plain": [
1168
+ "optimizer.pt: 0%| | 0.00/26.9M [00:00<?, ?B/s]"
1169
+ ]
1170
+ },
1171
+ "metadata": {},
1172
+ "output_type": "display_data"
1173
+ },
1174
+ {
1175
+ "data": {
1176
+ "application/vnd.jupyter.widget-view+json": {
1177
+ "model_id": "82ffd305ffe74273826b96a4fa8dc9ca",
1178
+ "version_major": 2,
1179
+ "version_minor": 0
1180
+ },
1181
+ "text/plain": [
1182
+ "tokenizer.json: 0%| | 0.00/33.4M [00:00<?, ?B/s]"
1183
+ ]
1184
+ },
1185
+ "metadata": {},
1186
+ "output_type": "display_data"
1187
+ },
1188
+ {
1189
+ "data": {
1190
+ "application/vnd.jupyter.widget-view+json": {
1191
+ "model_id": "2fc0d49971004c6a886b65d9cbaf97fc",
1192
+ "version_major": 2,
1193
+ "version_minor": 0
1194
+ },
1195
+ "text/plain": [
1196
+ "tokenizer.model: 0%| | 0.00/4.69M [00:00<?, ?B/s]"
1197
+ ]
1198
+ },
1199
+ "metadata": {},
1200
+ "output_type": "display_data"
1201
+ },
1202
+ {
1203
+ "data": {
1204
+ "application/vnd.jupyter.widget-view+json": {
1205
+ "model_id": "4e264fba49e0418495cf268654fddcb6",
1206
+ "version_major": 2,
1207
+ "version_minor": 0
1208
+ },
1209
+ "text/plain": [
1210
+ "special_tokens_map.json: 0%| | 0.00/670 [00:00<?, ?B/s]"
1211
+ ]
1212
+ },
1213
+ "metadata": {},
1214
+ "output_type": "display_data"
1215
+ },
1216
+ {
1217
+ "data": {
1218
+ "application/vnd.jupyter.widget-view+json": {
1219
+ "model_id": "44860d4b27c7477f8fb3e661ddda8aa1",
1220
+ "version_major": 2,
1221
+ "version_minor": 0
1222
+ },
1223
+ "text/plain": [
1224
+ "trainer_state.json: 0.00B [00:00, ?B/s]"
1225
+ ]
1226
+ },
1227
+ "metadata": {},
1228
+ "output_type": "display_data"
1229
+ },
1230
+ {
1231
+ "data": {
1232
+ "application/vnd.jupyter.widget-view+json": {
1233
+ "model_id": "f5f2fec7db974c3bbee726abbc01b447",
1234
+ "version_major": 2,
1235
+ "version_minor": 0
1236
+ },
1237
+ "text/plain": [
1238
+ "tokenizer_config.json: 0.00B [00:00, ?B/s]"
1239
+ ]
1240
+ },
1241
+ "metadata": {},
1242
+ "output_type": "display_data"
1243
+ },
1244
+ {
1245
+ "data": {
1246
+ "application/vnd.jupyter.widget-view+json": {
1247
+ "model_id": "9e947db3d50f4d0982a59a6f0a871467",
1248
+ "version_major": 2,
1249
+ "version_minor": 0
1250
+ },
1251
+ "text/plain": [
1252
+ "training_args.bin: 0%| | 0.00/5.69k [00:00<?, ?B/s]"
1253
+ ]
1254
+ },
1255
+ "metadata": {},
1256
+ "output_type": "display_data"
1257
+ },
1258
+ {
1259
+ "data": {
1260
+ "application/vnd.jupyter.widget-view+json": {
1261
+ "model_id": "556579c2c7a34c65b0fc5591a69ba5de",
1262
+ "version_major": 2,
1263
+ "version_minor": 0
1264
+ },
1265
+ "text/plain": [
1266
+ "README.md: 0.00B [00:00, ?B/s]"
1267
+ ]
1268
+ },
1269
+ "metadata": {},
1270
+ "output_type": "display_data"
1271
+ },
1272
+ {
1273
+ "data": {
1274
+ "application/vnd.jupyter.widget-view+json": {
1275
+ "model_id": "031d3a4e6b8a4393aaba13845363387f",
1276
+ "version_major": 2,
1277
+ "version_minor": 0
1278
+ },
1279
+ "text/plain": [
1280
+ "adapter_config.json: 0.00B [00:00, ?B/s]"
1281
+ ]
1282
+ },
1283
+ "metadata": {},
1284
+ "output_type": "display_data"
1285
+ },
1286
+ {
1287
+ "data": {
1288
+ "application/vnd.jupyter.widget-view+json": {
1289
+ "model_id": "3b11883b972a453eb450c5503c2600d4",
1290
+ "version_major": 2,
1291
+ "version_minor": 0
1292
+ },
1293
+ "text/plain": [
1294
+ "adapter_model.safetensors: 0%| | 0.00/52.2M [00:00<?, ?B/s]"
1295
+ ]
1296
+ },
1297
+ "metadata": {},
1298
+ "output_type": "display_data"
1299
+ },
1300
+ {
1301
+ "data": {
1302
+ "application/vnd.jupyter.widget-view+json": {
1303
+ "model_id": "60fe0cae525a4b018eef8e8dbdb8b163",
1304
+ "version_major": 2,
1305
+ "version_minor": 0
1306
+ },
1307
+ "text/plain": [
1308
+ "chat_template.jinja: 0.00B [00:00, ?B/s]"
1309
+ ]
1310
+ },
1311
+ "metadata": {},
1312
+ "output_type": "display_data"
1313
+ },
1314
+ {
1315
+ "data": {
1316
+ "application/vnd.jupyter.widget-view+json": {
1317
+ "model_id": "48d98a0ee3c2445da6cfbbb312fc4865",
1318
+ "version_major": 2,
1319
+ "version_minor": 0
1320
+ },
1321
+ "text/plain": [
1322
+ "added_tokens.json: 0%| | 0.00/35.0 [00:00<?, ?B/s]"
1323
+ ]
1324
+ },
1325
+ "metadata": {},
1326
+ "output_type": "display_data"
1327
+ },
1328
+ {
1329
+ "data": {
1330
+ "application/vnd.jupyter.widget-view+json": {
1331
+ "model_id": "002783acbac0477794850f2d776ce4d8",
1332
+ "version_major": 2,
1333
+ "version_minor": 0
1334
+ },
1335
+ "text/plain": [
1336
+ "optimizer.pt: 0%| | 0.00/26.9M [00:00<?, ?B/s]"
1337
+ ]
1338
+ },
1339
+ "metadata": {},
1340
+ "output_type": "display_data"
1341
+ },
1342
+ {
1343
+ "data": {
1344
+ "application/vnd.jupyter.widget-view+json": {
1345
+ "model_id": "40bb634f9aa64882a676dec3ea6be102",
1346
+ "version_major": 2,
1347
+ "version_minor": 0
1348
+ },
1349
+ "text/plain": [
1350
+ "tokenizer.json: 0%| | 0.00/33.4M [00:00<?, ?B/s]"
1351
+ ]
1352
+ },
1353
+ "metadata": {},
1354
+ "output_type": "display_data"
1355
+ },
1356
+ {
1357
+ "data": {
1358
+ "application/vnd.jupyter.widget-view+json": {
1359
+ "model_id": "d2ad9c270e03469cb5ad524e1f90dcab",
1360
+ "version_major": 2,
1361
+ "version_minor": 0
1362
+ },
1363
+ "text/plain": [
1364
+ "scheduler.pt: 0%| | 0.00/1.06k [00:00<?, ?B/s]"
1365
+ ]
1366
+ },
1367
+ "metadata": {},
1368
+ "output_type": "display_data"
1369
+ },
1370
+ {
1371
+ "data": {
1372
+ "application/vnd.jupyter.widget-view+json": {
1373
+ "model_id": "0dbe086e672c48f39ca534979ea62a7e",
1374
+ "version_major": 2,
1375
+ "version_minor": 0
1376
+ },
1377
+ "text/plain": [
1378
+ "rng_state.pth: 0%| | 0.00/14.2k [00:00<?, ?B/s]"
1379
+ ]
1380
+ },
1381
+ "metadata": {},
1382
+ "output_type": "display_data"
1383
+ },
1384
+ {
1385
+ "data": {
1386
+ "application/vnd.jupyter.widget-view+json": {
1387
+ "model_id": "202958e6b5154aa28e825f7f0d76518a",
1388
+ "version_major": 2,
1389
+ "version_minor": 0
1390
+ },
1391
+ "text/plain": [
1392
+ "tokenizer.model: 0%| | 0.00/4.69M [00:00<?, ?B/s]"
1393
+ ]
1394
+ },
1395
+ "metadata": {},
1396
+ "output_type": "display_data"
1397
+ },
1398
+ {
1399
+ "data": {
1400
+ "application/vnd.jupyter.widget-view+json": {
1401
+ "model_id": "72fde697941843f28c62b5a719f55dcc",
1402
+ "version_major": 2,
1403
+ "version_minor": 0
1404
+ },
1405
+ "text/plain": [
1406
+ "training_args.bin: 0%| | 0.00/5.69k [00:00<?, ?B/s]"
1407
+ ]
1408
+ },
1409
+ "metadata": {},
1410
+ "output_type": "display_data"
1411
+ },
1412
+ {
1413
+ "data": {
1414
+ "application/vnd.jupyter.widget-view+json": {
1415
+ "model_id": "e52395d696fa4a7b9b3f053b2b13479c",
1416
+ "version_major": 2,
1417
+ "version_minor": 0
1418
+ },
1419
+ "text/plain": [
1420
+ "special_tokens_map.json: 0%| | 0.00/670 [00:00<?, ?B/s]"
1421
+ ]
1422
+ },
1423
+ "metadata": {},
1424
+ "output_type": "display_data"
1425
+ },
1426
+ {
1427
+ "data": {
1428
+ "application/vnd.jupyter.widget-view+json": {
1429
+ "model_id": "cb2cab545d20446ca9860c6e0c744f08",
1430
+ "version_major": 2,
1431
+ "version_minor": 0
1432
+ },
1433
+ "text/plain": [
1434
+ "tokenizer_config.json: 0.00B [00:00, ?B/s]"
1435
+ ]
1436
+ },
1437
+ "metadata": {},
1438
+ "output_type": "display_data"
1439
+ },
1440
+ {
1441
+ "data": {
1442
+ "application/vnd.jupyter.widget-view+json": {
1443
+ "model_id": "79bb8b57de3d4b92a9b1884841a04f4a",
1444
+ "version_major": 2,
1445
+ "version_minor": 0
1446
+ },
1447
+ "text/plain": [
1448
+ "trainer_state.json: 0.00B [00:00, ?B/s]"
1449
+ ]
1450
+ },
1451
+ "metadata": {},
1452
+ "output_type": "display_data"
1453
+ },
1454
+ {
1455
+ "data": {
1456
+ "application/vnd.jupyter.widget-view+json": {
1457
+ "model_id": "154d6d0220e04e0c86b639060a6042da",
1458
+ "version_major": 2,
1459
+ "version_minor": 0
1460
+ },
1461
+ "text/plain": [
1462
+ "adapter_config.json: 0.00B [00:00, ?B/s]"
1463
+ ]
1464
+ },
1465
+ "metadata": {},
1466
+ "output_type": "display_data"
1467
+ },
1468
+ {
1469
+ "data": {
1470
+ "application/vnd.jupyter.widget-view+json": {
1471
+ "model_id": "0a74b826be3a4178a2d9faf06600b94b",
1472
+ "version_major": 2,
1473
+ "version_minor": 0
1474
+ },
1475
+ "text/plain": [
1476
+ "README.md: 0.00B [00:00, ?B/s]"
1477
+ ]
1478
+ },
1479
+ "metadata": {},
1480
+ "output_type": "display_data"
1481
+ },
1482
+ {
1483
+ "data": {
1484
+ "application/vnd.jupyter.widget-view+json": {
1485
+ "model_id": "5db2bfac9cfa4fd49c782d7a624263f7",
1486
+ "version_major": 2,
1487
+ "version_minor": 0
1488
+ },
1489
+ "text/plain": [
1490
+ "adapter_model.safetensors: 0%| | 0.00/52.2M [00:00<?, ?B/s]"
1491
+ ]
1492
+ },
1493
+ "metadata": {},
1494
+ "output_type": "display_data"
1495
+ },
1496
+ {
1497
+ "data": {
1498
+ "application/vnd.jupyter.widget-view+json": {
1499
+ "model_id": "f3d1fed2dd71454aae8184d3ba918e1b",
1500
+ "version_major": 2,
1501
+ "version_minor": 0
1502
+ },
1503
+ "text/plain": [
1504
+ "optimizer.pt: 0%| | 0.00/26.9M [00:00<?, ?B/s]"
1505
+ ]
1506
+ },
1507
+ "metadata": {},
1508
+ "output_type": "display_data"
1509
+ },
1510
+ {
1511
+ "data": {
1512
+ "application/vnd.jupyter.widget-view+json": {
1513
+ "model_id": "25f57b98bcac40a5818eecb0aed60cc3",
1514
+ "version_major": 2,
1515
+ "version_minor": 0
1516
+ },
1517
+ "text/plain": [
1518
+ "added_tokens.json: 0%| | 0.00/35.0 [00:00<?, ?B/s]"
1519
+ ]
1520
+ },
1521
+ "metadata": {},
1522
+ "output_type": "display_data"
1523
+ },
1524
+ {
1525
+ "data": {
1526
+ "application/vnd.jupyter.widget-view+json": {
1527
+ "model_id": "93ed4767a81b4ee6ab7df93c90acb7d9",
1528
+ "version_major": 2,
1529
+ "version_minor": 0
1530
+ },
1531
+ "text/plain": [
1532
+ "chat_template.jinja: 0.00B [00:00, ?B/s]"
1533
+ ]
1534
+ },
1535
+ "metadata": {},
1536
+ "output_type": "display_data"
1537
+ },
1538
+ {
1539
+ "data": {
1540
+ "application/vnd.jupyter.widget-view+json": {
1541
+ "model_id": "6b35aa4068194222aa5d397781074b38",
1542
+ "version_major": 2,
1543
+ "version_minor": 0
1544
+ },
1545
+ "text/plain": [
1546
+ "tokenizer.json: 0%| | 0.00/33.4M [00:00<?, ?B/s]"
1547
+ ]
1548
+ },
1549
+ "metadata": {},
1550
+ "output_type": "display_data"
1551
+ },
1552
+ {
1553
+ "data": {
1554
+ "application/vnd.jupyter.widget-view+json": {
1555
+ "model_id": "8c34b00945b94454ae3c40cd30b16579",
1556
+ "version_major": 2,
1557
+ "version_minor": 0
1558
+ },
1559
+ "text/plain": [
1560
+ "scheduler.pt: 0%| | 0.00/1.06k [00:00<?, ?B/s]"
1561
+ ]
1562
+ },
1563
+ "metadata": {},
1564
+ "output_type": "display_data"
1565
+ },
1566
+ {
1567
+ "data": {
1568
+ "application/vnd.jupyter.widget-view+json": {
1569
+ "model_id": "4e1c1c2e2a6941f48c33994faf886383",
1570
+ "version_major": 2,
1571
+ "version_minor": 0
1572
+ },
1573
+ "text/plain": [
1574
+ "tokenizer.model: 0%| | 0.00/4.69M [00:00<?, ?B/s]"
1575
+ ]
1576
+ },
1577
+ "metadata": {},
1578
+ "output_type": "display_data"
1579
+ },
1580
+ {
1581
+ "data": {
1582
+ "application/vnd.jupyter.widget-view+json": {
1583
+ "model_id": "687fab083e164ae4a270660822484485",
1584
+ "version_major": 2,
1585
+ "version_minor": 0
1586
+ },
1587
+ "text/plain": [
1588
+ "rng_state.pth: 0%| | 0.00/14.2k [00:00<?, ?B/s]"
1589
+ ]
1590
+ },
1591
+ "metadata": {},
1592
+ "output_type": "display_data"
1593
+ },
1594
+ {
1595
+ "data": {
1596
+ "application/vnd.jupyter.widget-view+json": {
1597
+ "model_id": "e20bcf60b1f64edb856d8acd901fcdd1",
1598
+ "version_major": 2,
1599
+ "version_minor": 0
1600
+ },
1601
+ "text/plain": [
1602
+ "special_tokens_map.json: 0%| | 0.00/670 [00:00<?, ?B/s]"
1603
+ ]
1604
+ },
1605
+ "metadata": {},
1606
+ "output_type": "display_data"
1607
+ },
1608
+ {
1609
+ "data": {
1610
+ "application/vnd.jupyter.widget-view+json": {
1611
+ "model_id": "6ca2c051ed67417189dc1ac32c010707",
1612
+ "version_major": 2,
1613
+ "version_minor": 0
1614
+ },
1615
+ "text/plain": [
1616
+ "tokenizer_config.json: 0.00B [00:00, ?B/s]"
1617
+ ]
1618
+ },
1619
+ "metadata": {},
1620
+ "output_type": "display_data"
1621
+ },
1622
+ {
1623
+ "data": {
1624
+ "application/vnd.jupyter.widget-view+json": {
1625
+ "model_id": "9a5af95d6d914872ada37387e1c1f156",
1626
+ "version_major": 2,
1627
+ "version_minor": 0
1628
+ },
1629
+ "text/plain": [
1630
+ "training_args.bin: 0%| | 0.00/5.69k [00:00<?, ?B/s]"
1631
+ ]
1632
+ },
1633
+ "metadata": {},
1634
+ "output_type": "display_data"
1635
+ },
1636
+ {
1637
+ "data": {
1638
+ "application/vnd.jupyter.widget-view+json": {
1639
+ "model_id": "4aa58f9a73a444a89e5838fb82fed160",
1640
+ "version_major": 2,
1641
+ "version_minor": 0
1642
+ },
1643
+ "text/plain": [
1644
+ "trainer_state.json: 0.00B [00:00, ?B/s]"
1645
+ ]
1646
+ },
1647
+ "metadata": {},
1648
+ "output_type": "display_data"
1649
+ },
1650
+ {
1651
+ "data": {
1652
+ "application/vnd.jupyter.widget-view+json": {
1653
+ "model_id": "6cd3993a245c4e8b928628522b04dac2",
1654
+ "version_major": 2,
1655
+ "version_minor": 0
1656
+ },
1657
+ "text/plain": [
1658
+ "README.md: 0.00B [00:00, ?B/s]"
1659
+ ]
1660
+ },
1661
+ "metadata": {},
1662
+ "output_type": "display_data"
1663
+ },
1664
+ {
1665
+ "data": {
1666
+ "application/vnd.jupyter.widget-view+json": {
1667
+ "model_id": "055ce4ba2cac4733aca57706e79c1683",
1668
+ "version_major": 2,
1669
+ "version_minor": 0
1670
+ },
1671
+ "text/plain": [
1672
+ "adapter_config.json: 0.00B [00:00, ?B/s]"
1673
+ ]
1674
+ },
1675
+ "metadata": {},
1676
+ "output_type": "display_data"
1677
+ },
1678
+ {
1679
+ "data": {
1680
+ "application/vnd.jupyter.widget-view+json": {
1681
+ "model_id": "32fca4f49911486c8cc297634a04157f",
1682
+ "version_major": 2,
1683
+ "version_minor": 0
1684
+ },
1685
+ "text/plain": [
1686
+ "rng_state.pth: 0%| | 0.00/14.2k [00:00<?, ?B/s]"
1687
+ ]
1688
+ },
1689
+ "metadata": {},
1690
+ "output_type": "display_data"
1691
+ },
1692
+ {
1693
+ "data": {
1694
+ "application/vnd.jupyter.widget-view+json": {
1695
+ "model_id": "68e13028ce7f4320bdf0b9335d51c6f2",
1696
+ "version_major": 2,
1697
+ "version_minor": 0
1698
+ },
1699
+ "text/plain": [
1700
+ "tokenizer.json: 0%| | 0.00/33.4M [00:00<?, ?B/s]"
1701
+ ]
1702
+ },
1703
+ "metadata": {},
1704
+ "output_type": "display_data"
1705
+ },
1706
+ {
1707
+ "data": {
1708
+ "application/vnd.jupyter.widget-view+json": {
1709
+ "model_id": "efdf554a1ccd4b5d9c113f8901e3d430",
1710
+ "version_major": 2,
1711
+ "version_minor": 0
1712
+ },
1713
+ "text/plain": [
1714
+ "added_tokens.json: 0%| | 0.00/35.0 [00:00<?, ?B/s]"
1715
+ ]
1716
+ },
1717
+ "metadata": {},
1718
+ "output_type": "display_data"
1719
+ },
1720
+ {
1721
+ "data": {
1722
+ "application/vnd.jupyter.widget-view+json": {
1723
+ "model_id": "86bdbff7352249688119c2b1cc462ea4",
1724
+ "version_major": 2,
1725
+ "version_minor": 0
1726
+ },
1727
+ "text/plain": [
1728
+ "chat_template.jinja: 0.00B [00:00, ?B/s]"
1729
+ ]
1730
+ },
1731
+ "metadata": {},
1732
+ "output_type": "display_data"
1733
+ },
1734
+ {
1735
+ "data": {
1736
+ "application/vnd.jupyter.widget-view+json": {
1737
+ "model_id": "7e65f555310c4edeb2ab116b59ac31e0",
1738
+ "version_major": 2,
1739
+ "version_minor": 0
1740
+ },
1741
+ "text/plain": [
1742
+ "optimizer.pt: 0%| | 0.00/26.9M [00:00<?, ?B/s]"
1743
+ ]
1744
+ },
1745
+ "metadata": {},
1746
+ "output_type": "display_data"
1747
+ },
1748
+ {
1749
+ "data": {
1750
+ "application/vnd.jupyter.widget-view+json": {
1751
+ "model_id": "ddbaef03044940b793150c8824b4c2f0",
1752
+ "version_major": 2,
1753
+ "version_minor": 0
1754
+ },
1755
+ "text/plain": [
1756
+ "scheduler.pt: 0%| | 0.00/1.06k [00:00<?, ?B/s]"
1757
+ ]
1758
+ },
1759
+ "metadata": {},
1760
+ "output_type": "display_data"
1761
+ },
1762
+ {
1763
+ "data": {
1764
+ "application/vnd.jupyter.widget-view+json": {
1765
+ "model_id": "72f635a821c54a248dffb183f0a5647e",
1766
+ "version_major": 2,
1767
+ "version_minor": 0
1768
+ },
1769
+ "text/plain": [
1770
+ "adapter_model.safetensors: 0%| | 0.00/52.2M [00:00<?, ?B/s]"
1771
+ ]
1772
+ },
1773
+ "metadata": {},
1774
+ "output_type": "display_data"
1775
+ },
1776
+ {
1777
+ "data": {
1778
+ "application/vnd.jupyter.widget-view+json": {
1779
+ "model_id": "e804e55275374353824efae70cd11644",
1780
+ "version_major": 2,
1781
+ "version_minor": 0
1782
+ },
1783
+ "text/plain": [
1784
+ "special_tokens_map.json: 0%| | 0.00/670 [00:00<?, ?B/s]"
1785
+ ]
1786
+ },
1787
+ "metadata": {},
1788
+ "output_type": "display_data"
1789
+ },
1790
+ {
1791
+ "data": {
1792
+ "application/vnd.jupyter.widget-view+json": {
1793
+ "model_id": "bf93017804e44e8387f56ece0ab26652",
1794
+ "version_major": 2,
1795
+ "version_minor": 0
1796
+ },
1797
+ "text/plain": [
1798
+ "tokenizer.model: 0%| | 0.00/4.69M [00:00<?, ?B/s]"
1799
+ ]
1800
+ },
1801
+ "metadata": {},
1802
+ "output_type": "display_data"
1803
+ },
1804
+ {
1805
+ "data": {
1806
+ "application/vnd.jupyter.widget-view+json": {
1807
+ "model_id": "1a222f15ee7f4c83a9083e89b12b908d",
1808
+ "version_major": 2,
1809
+ "version_minor": 0
1810
+ },
1811
+ "text/plain": [
1812
+ "training_args.bin: 0%| | 0.00/5.69k [00:00<?, ?B/s]"
1813
+ ]
1814
+ },
1815
+ "metadata": {},
1816
+ "output_type": "display_data"
1817
+ },
1818
+ {
1819
+ "data": {
1820
+ "application/vnd.jupyter.widget-view+json": {
1821
+ "model_id": "5e7b82b2fca442fe8a90ad1429a5c6eb",
1822
+ "version_major": 2,
1823
+ "version_minor": 0
1824
+ },
1825
+ "text/plain": [
1826
+ "tokenizer_config.json: 0.00B [00:00, ?B/s]"
1827
+ ]
1828
+ },
1829
+ "metadata": {},
1830
+ "output_type": "display_data"
1831
+ },
1832
+ {
1833
+ "data": {
1834
+ "application/vnd.jupyter.widget-view+json": {
1835
+ "model_id": "28015ab4e08046e18042414523edb196",
1836
+ "version_major": 2,
1837
+ "version_minor": 0
1838
+ },
1839
+ "text/plain": [
1840
+ "trainer_state.json: 0.00B [00:00, ?B/s]"
1841
+ ]
1842
+ },
1843
+ "metadata": {},
1844
+ "output_type": "display_data"
1845
+ },
1846
+ {
1847
+ "data": {
1848
+ "text/plain": [
1849
+ "'/kaggle/working/Gemma-3-1B-Instruct-Vi-Medical-LoRA'"
1850
+ ]
1851
+ },
1852
+ "execution_count": 6,
1853
+ "metadata": {},
1854
+ "output_type": "execute_result"
1855
+ }
1856
+ ],
1857
+ "source": [
1858
+ "from huggingface_hub import HfApi\n",
1859
+ "from huggingface_hub import snapshot_download\n",
1860
+ "import os\n",
1861
+ "api = HfApi()\n",
1862
+ "\n",
1863
+ "repo_id = \"danhtran2mind/Gemma-3-1B-Instruct-Vi-Medical-LoRA\"\n",
1864
+ "save_path = \"Gemma-3-1B-Instruct-Vi-Medical-LoRA\"\n",
1865
+ "\n",
1866
+ "# Create the directory if it doesn't exist\n",
1867
+ "os.makedirs(save_path, exist_ok=True)\n",
1868
+ "\n",
1869
+ "# Download the dataset\n",
1870
+ "snapshot_download(repo_id=repo_id, repo_type=\"model\", local_dir=save_path)"
1871
+ ]
1872
+ },
1873
+ {
1874
+ "cell_type": "code",
1875
+ "execution_count": 7,
1876
+ "metadata": {
1877
+ "execution": {
1878
+ "iopub.execute_input": "2025-07-01T00:46:33.995484Z",
1879
+ "iopub.status.busy": "2025-07-01T00:46:33.995208Z",
1880
+ "iopub.status.idle": "2025-07-01T00:46:57.755887Z",
1881
+ "shell.execute_reply": "2025-07-01T00:46:57.755331Z",
1882
+ "shell.execute_reply.started": "2025-07-01T00:46:33.995460Z"
1883
+ },
1884
+ "trusted": true
1885
+ },
1886
+ "outputs": [
1887
+ {
1888
+ "name": "stdout",
1889
+ "output_type": "stream",
1890
+ "text": [
1891
+ "==((====))== Unsloth 2025.6.9: Fast Gemma3 patching. Transformers: 4.52.4.\n",
1892
+ " \\\\ /| Tesla T4. Num GPUs = 1. Max memory: 14.741 GB. Platform: Linux.\n",
1893
+ "O^O/ \\_/ \\ Torch: 2.6.0+cu124. CUDA: 7.5. CUDA Toolkit: 12.4. Triton: 3.2.0\n",
1894
+ "\\ / Bfloat16 = FALSE. FA [Xformers = 0.0.29.post3. FA2 = False]\n",
1895
+ " \"-____-\" Free license: http://github.com/unslothai/unsloth\n",
1896
+ "Unsloth: Fast downloading is enabled - ignore downloading bars which are red colored!\n",
1897
+ "Unsloth: Using float16 precision for gemma3 won't work! Using float32.\n"
1898
+ ]
1899
+ },
1900
+ {
1901
+ "data": {
1902
+ "application/vnd.jupyter.widget-view+json": {
1903
+ "model_id": "b180e4eaf5e94ab8abbd842e3e3daf74",
1904
+ "version_major": 2,
1905
+ "version_minor": 0
1906
+ },
1907
+ "text/plain": [
1908
+ "model.safetensors: 0%| | 0.00/1.00G [00:00<?, ?B/s]"
1909
+ ]
1910
+ },
1911
+ "metadata": {},
1912
+ "output_type": "display_data"
1913
+ },
1914
+ {
1915
+ "data": {
1916
+ "application/vnd.jupyter.widget-view+json": {
1917
+ "model_id": "1e2dd9b3cfbd4382a4af06689c1f1872",
1918
+ "version_major": 2,
1919
+ "version_minor": 0
1920
+ },
1921
+ "text/plain": [
1922
+ "generation_config.json: 0%| | 0.00/233 [00:00<?, ?B/s]"
1923
+ ]
1924
+ },
1925
+ "metadata": {},
1926
+ "output_type": "display_data"
1927
+ },
1928
+ {
1929
+ "data": {
1930
+ "application/vnd.jupyter.widget-view+json": {
1931
+ "model_id": "9ec77310502d43f4aef8fc3f76a210c0",
1932
+ "version_major": 2,
1933
+ "version_minor": 0
1934
+ },
1935
+ "text/plain": [
1936
+ "tokenizer_config.json: 0.00B [00:00, ?B/s]"
1937
+ ]
1938
+ },
1939
+ "metadata": {},
1940
+ "output_type": "display_data"
1941
+ },
1942
+ {
1943
+ "data": {
1944
+ "application/vnd.jupyter.widget-view+json": {
1945
+ "model_id": "744ba5c715a24db596a570fb801a9929",
1946
+ "version_major": 2,
1947
+ "version_minor": 0
1948
+ },
1949
+ "text/plain": [
1950
+ "tokenizer.model: 0%| | 0.00/4.69M [00:00<?, ?B/s]"
1951
+ ]
1952
+ },
1953
+ "metadata": {},
1954
+ "output_type": "display_data"
1955
+ },
1956
+ {
1957
+ "data": {
1958
+ "application/vnd.jupyter.widget-view+json": {
1959
+ "model_id": "bc3e4cec4e9a4fefb58f4dd1b2441771",
1960
+ "version_major": 2,
1961
+ "version_minor": 0
1962
+ },
1963
+ "text/plain": [
1964
+ "tokenizer.json: 0%| | 0.00/33.4M [00:00<?, ?B/s]"
1965
+ ]
1966
+ },
1967
+ "metadata": {},
1968
+ "output_type": "display_data"
1969
+ },
1970
+ {
1971
+ "data": {
1972
+ "application/vnd.jupyter.widget-view+json": {
1973
+ "model_id": "ad8be6fe12c34919ab05f89e65b59aa9",
1974
+ "version_major": 2,
1975
+ "version_minor": 0
1976
+ },
1977
+ "text/plain": [
1978
+ "added_tokens.json: 0%| | 0.00/35.0 [00:00<?, ?B/s]"
1979
+ ]
1980
+ },
1981
+ "metadata": {},
1982
+ "output_type": "display_data"
1983
+ },
1984
+ {
1985
+ "data": {
1986
+ "application/vnd.jupyter.widget-view+json": {
1987
+ "model_id": "5c102f79e0614d7384d922076b85c962",
1988
+ "version_major": 2,
1989
+ "version_minor": 0
1990
+ },
1991
+ "text/plain": [
1992
+ "special_tokens_map.json: 0%| | 0.00/670 [00:00<?, ?B/s]"
1993
+ ]
1994
+ },
1995
+ "metadata": {},
1996
+ "output_type": "display_data"
1997
+ },
1998
+ {
1999
+ "name": "stdout",
2000
+ "output_type": "stream",
2001
+ "text": [
2002
+ "Unsloth: Making `model.base_model.model.model` require gradients\n"
2003
+ ]
2004
+ }
2005
+ ],
2006
+ "source": [
2007
+ "from unsloth import FastLanguageModel\n",
2008
+ "import torch\n",
2009
+ "\n",
2010
+ "model_id = \"google/gemma-3-1b-it\"\n",
2011
+ "\n",
2012
+ "# Load the model and tokenizer\n",
2013
+ "model, tokenizer = FastModel.from_pretrained(\n",
2014
+ " model_name = model_id,\n",
2015
+ " max_seq_length = 2048, # Choose any for long context!\n",
2016
+ " load_in_4bit = True, # 4 bit quantization to reduce memory\n",
2017
+ " load_in_8bit = False, # [NEW!] A bit more accurate, uses 2x memory\n",
2018
+ " full_finetuning = False, # [NEW!] We have full finetuning now!\n",
2019
+ " # token = \"hf_...\", # use one if using gated models\n",
2020
+ ")\n",
2021
+ "\n",
2022
+ "model = FastModel.get_peft_model(\n",
2023
+ " model,\n",
2024
+ " finetune_vision_layers = False, # Turn off for just text!\n",
2025
+ " finetune_language_layers = True, # Should leave on!\n",
2026
+ " finetune_attention_modules = True, # Attention good for GRPO\n",
2027
+ " finetune_mlp_modules = True, # SHould leave on always!\n",
2028
+ "\n",
2029
+ " r = 16, # Larger = higher accuracy, but might overfit\n",
2030
+ " lora_alpha = 8, # Recommended alpha == r at least\n",
2031
+ " lora_dropout = 0,\n",
2032
+ " bias = \"none\",\n",
2033
+ " random_state = 42,\n",
2034
+ ")\n",
2035
+ "\n",
2036
+ "tokenizer = get_chat_template(\n",
2037
+ " tokenizer,\n",
2038
+ " chat_template = \"gemma-3\",\n",
2039
+ ")"
2040
+ ]
2041
+ },
2042
+ {
2043
+ "cell_type": "code",
2044
+ "execution_count": 8,
2045
+ "metadata": {
2046
+ "execution": {
2047
+ "iopub.execute_input": "2025-07-01T00:46:57.756794Z",
2048
+ "iopub.status.busy": "2025-07-01T00:46:57.756575Z",
2049
+ "iopub.status.idle": "2025-07-01T00:46:57.762128Z",
2050
+ "shell.execute_reply": "2025-07-01T00:46:57.761350Z",
2051
+ "shell.execute_reply.started": "2025-07-01T00:46:57.756777Z"
2052
+ },
2053
+ "trusted": true
2054
+ },
2055
+ "outputs": [],
2056
+ "source": [
2057
+ "def convert_squad_sample_to_conversation(sample):\n",
2058
+ " # get the question and context for this sample\n",
2059
+ " question = sample['question']\n",
2060
+ " context = sample['context']\n",
2061
+ "\n",
2062
+ " answers = sample['answer']\n",
2063
+ " if len(answers) == 0 :\n",
2064
+ " answer = \"The context does not provide an answer...\"\n",
2065
+ " else:\n",
2066
+ " answer = sample['answer']\n",
2067
+ "\n",
2068
+ " # now we define an initial model prompt defining the task and giving the model the context passage\n",
2069
+ " instruction_prompt_template = '''Bạn là một trợ lý hữu ích được giao nhiệm vụ trích xuất các đoạn văn trả lời câu hỏi của người dùng từ một ngữ cảnh cho trước. Xuất ra các đoạn văn chính xác từng từ một trả lời câu hỏi của người dùng. Không xuất ra bất kỳ văn bản nào khác ngoài các đoạn văn trong ngữ cảnh. Xuất ra lượng tối thiểu để trả lời câu hỏi, ví dụ chỉ 2-3 từ từ đoạn văn. Nếu không thể tìm thấy câu trả lời trong ngữ cảnh, xuất ra 'Ngữ cảnh không cung cấp câu trả lời...'\n",
2070
+ "\n",
2071
+ " Ngữ cảnh: {context}'''\n",
2072
+ "\n",
2073
+ " # now we'll convert these into a list of messages for our conversation\n",
2074
+ " messages = [\n",
2075
+ " {\"role\": \"system\", \"content\": instruction_prompt_template.format(context=context)},\n",
2076
+ " {\"role\": \"user\", \"content\": question},\n",
2077
+ " {\"role\": \"assistant\", \"content\": answer}\n",
2078
+ " ]\n",
2079
+ " \n",
2080
+ " sample_conversation = tokenizer.apply_chat_template(messages, tokenize=False)\n",
2081
+ " return {\"text\": sample_conversation, \"messages\": messages, \"answer\": answer}\n"
2082
+ ]
2083
+ },
2084
+ {
2085
+ "cell_type": "code",
2086
+ "execution_count": 9,
2087
+ "metadata": {
2088
+ "execution": {
2089
+ "iopub.execute_input": "2025-07-01T00:46:57.763088Z",
2090
+ "iopub.status.busy": "2025-07-01T00:46:57.762898Z",
2091
+ "iopub.status.idle": "2025-07-01T00:47:02.542535Z",
2092
+ "shell.execute_reply": "2025-07-01T00:47:02.541604Z",
2093
+ "shell.execute_reply.started": "2025-07-01T00:46:57.763073Z"
2094
+ },
2095
+ "trusted": true
2096
+ },
2097
+ "outputs": [
2098
+ {
2099
+ "data": {
2100
+ "application/vnd.jupyter.widget-view+json": {
2101
+ "model_id": "22ce1399fdb3466d84838d2bd8fa37dc",
2102
+ "version_major": 2,
2103
+ "version_minor": 0
2104
+ },
2105
+ "text/plain": [
2106
+ "Map: 0%| | 0/14121 [00:00<?, ? examples/s]"
2107
+ ]
2108
+ },
2109
+ "metadata": {},
2110
+ "output_type": "display_data"
2111
+ },
2112
+ {
2113
+ "data": {
2114
+ "application/vnd.jupyter.widget-view+json": {
2115
+ "model_id": "3877df89e22a4c45a6490e5003e96aa4",
2116
+ "version_major": 2,
2117
+ "version_minor": 0
2118
+ },
2119
+ "text/plain": [
2120
+ "Map: 0%| | 0/1569 [00:00<?, ? examples/s]"
2121
+ ]
2122
+ },
2123
+ "metadata": {},
2124
+ "output_type": "display_data"
2125
+ }
2126
+ ],
2127
+ "source": [
2128
+ "conversation_training_samples = training_samples.map(convert_squad_sample_to_conversation)\n",
2129
+ "conversation_test_samples = test_samples.map(convert_squad_sample_to_conversation)"
2130
+ ]
2131
+ },
2132
+ {
2133
+ "cell_type": "code",
2134
+ "execution_count": 14,
2135
+ "metadata": {
2136
+ "execution": {
2137
+ "iopub.execute_input": "2025-06-29T14:18:25.035583Z",
2138
+ "iopub.status.busy": "2025-06-29T14:18:25.035345Z",
2139
+ "iopub.status.idle": "2025-06-29T14:18:25.040691Z",
2140
+ "shell.execute_reply": "2025-06-29T14:18:25.040024Z",
2141
+ "shell.execute_reply.started": "2025-06-29T14:18:25.035567Z"
2142
+ },
2143
+ "trusted": true
2144
+ },
2145
+ "outputs": [
2146
+ {
2147
+ "data": {
2148
+ "text/plain": [
2149
+ "'Nếu bạn có các triệu chứng nghi ngờ của nhiễm nấm da chân, hãy liên hệ với bác sĩ ngay để được tham vấn điều trị sớm. Điều này sẽ giúp bạn kiểm soát bệnh tình và ngăn ngừa các biến chứng nghiêm trọng.'"
2150
+ ]
2151
+ },
2152
+ "execution_count": 14,
2153
+ "metadata": {},
2154
+ "output_type": "execute_result"
2155
+ }
2156
+ ],
2157
+ "source": [
2158
+ "conversation_test_samples[0]['answer']"
2159
+ ]
2160
+ },
2161
+ {
2162
+ "cell_type": "code",
2163
+ "execution_count": 15,
2164
+ "metadata": {
2165
+ "execution": {
2166
+ "iopub.execute_input": "2025-06-29T14:18:25.043306Z",
2167
+ "iopub.status.busy": "2025-06-29T14:18:25.043113Z",
2168
+ "iopub.status.idle": "2025-06-29T14:18:25.413454Z",
2169
+ "shell.execute_reply": "2025-06-29T14:18:25.412688Z",
2170
+ "shell.execute_reply.started": "2025-06-29T14:18:25.043292Z"
2171
+ },
2172
+ "trusted": true
2173
+ },
2174
+ "outputs": [
2175
+ {
2176
+ "data": {
2177
+ "text/plain": [
2178
+ "[{'content': \"Bạn là một tr�� lý hữu ích được giao nhiệm vụ trích xuất các đoạn văn trả lời câu hỏi của người dùng từ một ngữ cảnh cho trước. Xuất ra các đoạn văn chính xác từng từ một trả lời câu hỏi của người dùng. Không xuất ra bất kỳ văn bản nào khác ngoài các đoạn văn trong ngữ cảnh. Xuất ra lượng tối thiểu để trả lời câu hỏi, ví dụ chỉ 2-3 từ từ đoạn văn. Nếu không thể tìm thấy câu trả lời trong ngữ cảnh, xuất ra 'Ngữ cảnh không cung cấp câu trả lời...'\\n\\n Ngữ cảnh: Những mẹo này có thể giúp bạn tránh bị nấm da chân hoặc giảm bớt các triệu chứng nếu nhiễm nấm xảy ra: - Giữ chân khô ráo, đặc biệt là giữa các ngón chân. Đi chân trần để chân thoát khí nhiều nhất có thể khi ở nhà. Lau khô các kẽ ngón chân sau khi tắm.\\n- Thay tất thường xuyên. Nếu chân bạn ra nhiều mồ hôi, hãy thay tất hai lần một ngày.\\n- Đi giày nhẹ, thông thoáng. Tránh giày làm bằng chất liệu tổng hợp, chẳng hạn như nhựa vinyl hoặc cao su.\\n- Mang thay đổi các đôi giày. Đừng mang cùng một đôi mỗi ngày để giày có thời gian khô sau mỗi lần sử dụng.\\n- Bảo vệ đôi chân của bạn ở những nơi công cộng. Mang dép hoặc giày không thấm nước xung quanh hồ bơi công cộng, phòng tắm vòi sen và phòng để tủ khóa.\\n- Điều trị bàn chân của bạn. Dùng bột, tốt nhất là thuốc chống nấm, bôi lên chân hàng ngày.\\n- Đừng dùng chung giày. Điều này sẽ làm nguy cơ lây nhiễm nấm. Như vậy, nấm da chân là bệnh lý khá dễ lây truyền khi sinh hoạt ở những nơi công cộng. Vì vậy qua bài viết này chúng tôi hi vọng các bạn đã có những kiến thức để phòng tránh chúng. Mặt khác, trong trường hợp xuất hiện những triệu chứng nghi ngờ của nhiễm nấm. Hãy liên hệ ngay với chuyên gia y khoa để được tham vấn điều trị sớm bạn nhé.\",\n",
2179
+ " 'role': 'system'},\n",
2180
+ " {'content': 'Khi nào người bệnh nên liên hệ với bác sĩ?', 'role': 'user'},\n",
2181
+ " {'content': 'Nếu bạn có các triệu chứng nghi ngờ của nhiễm nấm da chân, hãy liên hệ với bác sĩ ngay để được tham vấn điều trị sớm. Điều này sẽ giúp bạn kiểm soát bệnh tình và ngăn ngừa các biến chứng nghiêm trọng.',\n",
2182
+ " 'role': 'assistant'}]"
2183
+ ]
2184
+ },
2185
+ "execution_count": 15,
2186
+ "metadata": {},
2187
+ "output_type": "execute_result"
2188
+ }
2189
+ ],
2190
+ "source": [
2191
+ "conversation_test_samples[0]['messages']"
2192
+ ]
2193
+ },
2194
+ {
2195
+ "cell_type": "code",
2196
+ "execution_count": 16,
2197
+ "metadata": {
2198
+ "execution": {
2199
+ "iopub.execute_input": "2025-06-29T14:18:25.414525Z",
2200
+ "iopub.status.busy": "2025-06-29T14:18:25.414236Z",
2201
+ "iopub.status.idle": "2025-06-29T14:18:25.423779Z",
2202
+ "shell.execute_reply": "2025-06-29T14:18:25.423174Z",
2203
+ "shell.execute_reply.started": "2025-06-29T14:18:25.414480Z"
2204
+ },
2205
+ "trusted": true
2206
+ },
2207
+ "outputs": [
2208
+ {
2209
+ "data": {
2210
+ "text/plain": [
2211
+ "\"<bos><start_of_turn>user\\nBạn là một trợ lý hữu ích được giao nhiệm vụ trích xuất các đoạn văn trả lời câu hỏi của người dùng từ một ngữ cảnh cho trước. Xuất ra các đoạn văn chính xác từng từ một trả lời câu hỏi của người dùng. Không xuất ra bất kỳ văn bản nào khác ngoài các đoạn văn trong ngữ cảnh. Xuất ra lượng tối thiểu để trả lời câu hỏi, ví dụ chỉ 2-3 từ từ đoạn văn. Nếu không thể tìm thấy câu trả lời trong ngữ cảnh, xuất ra 'Ngữ cảnh không cung cấp câu trả lời...'\\n\\n Ngữ cảnh: Những mẹo này có thể giúp bạn tránh bị nấm da chân hoặc giảm bớt các triệu chứng nếu nhiễm nấm xảy ra: - Giữ chân khô ráo, đặc biệt là giữa các ngón chân. Đi chân trần để chân thoát khí nhiều nhất có thể khi ở nhà. Lau khô các kẽ ngón chân sau khi tắm.\\n- Thay tất thường xuyên. Nếu chân bạn ra nhiều mồ hôi, hãy thay tất hai lần một ngày.\\n- Đi giày nhẹ, thông thoáng. Tránh giày làm bằng chất liệu tổng hợp, chẳng hạn như nhựa vinyl hoặc cao su.\\n- Mang thay đổi các đôi giày. Đừng mang cùng một đôi mỗi ngày để giày có thời gian khô sau mỗi lần sử dụng.\\n- Bảo vệ đôi chân của bạn ở những nơi công cộng. Mang dép hoặc giày không thấm nước xung quanh hồ bơi công cộng, phòng tắm vòi sen và phòng để tủ khóa.\\n- Điều trị bàn chân của bạn. Dùng bột, tốt nhất là thuốc chống nấm, bôi lên chân hàng ngày.\\n- Đừng dùng chung giày. Điều này sẽ làm nguy cơ lây nhiễm nấm. Như vậy, nấm da chân là bệnh lý khá dễ lây truyền khi sinh hoạt ở những nơi công cộng. Vì vậy qua bài viết này chúng tôi hi vọng các bạn đã có những kiến thức để phòng tránh chúng. Mặt khác, trong trường hợp xuất hiện những triệu chứng nghi ngờ của nhiễm nấm. Hãy liên hệ ngay với chuyên gia y khoa để được tham vấn điều trị sớm bạn nhé.\\n\\nKhi nào người bệnh nên liên hệ với bác sĩ?<end_of_turn>\\n<start_of_turn>model\\nNếu bạn có các triệu chứng nghi ngờ của nhiễm nấm da chân, hãy liên hệ với bác sĩ ngay để được tham vấn điều trị sớm. Điều này sẽ giúp bạn kiểm soát bệnh tình và ngăn ngừa các biến chứng nghiêm trọng.<end_of_turn>\\n\""
2212
+ ]
2213
+ },
2214
+ "execution_count": 16,
2215
+ "metadata": {},
2216
+ "output_type": "execute_result"
2217
+ }
2218
+ ],
2219
+ "source": [
2220
+ "conversation_test_samples[0]['text']"
2221
+ ]
2222
+ },
2223
+ {
2224
+ "cell_type": "code",
2225
+ "execution_count": null,
2226
+ "metadata": {
2227
+ "execution": {
2228
+ "iopub.execute_input": "2025-07-01T00:52:05.316624Z",
2229
+ "iopub.status.busy": "2025-07-01T00:52:05.315880Z",
2230
+ "iopub.status.idle": "2025-07-01T00:52:05.352880Z",
2231
+ "shell.execute_reply": "2025-07-01T00:52:05.352105Z",
2232
+ "shell.execute_reply.started": "2025-07-01T00:52:05.316595Z"
2233
+ },
2234
+ "trusted": true
2235
+ },
2236
+ "outputs": [],
2237
+ "source": [
2238
+ "arguments = TrainingArguments( \n",
2239
+ " resume_from_checkpoint=\"./Gemma-3-1B-Instruct-Vi-Medical-LoRA\",\n",
2240
+ " per_device_train_batch_size=4, \n",
2241
+ " per_device_eval_batch_size=4, \n",
2242
+ " gradient_accumulation_steps=4,\n",
2243
+ " eval_strategy=\"steps\",\n",
2244
+ " eval_steps=200,\n",
2245
+ " logging_steps=50,\n",
2246
+ " save_steps=200,\n",
2247
+ " warmup_steps=30,\n",
2248
+ " save_total_limit=4,\n",
2249
+ " num_train_epochs=7, # 6\n",
2250
+ " # max_steps=60,\n",
2251
+ " save_strategy=\"steps\",\n",
2252
+ " metric_for_best_model=\"eval_loss\",\n",
2253
+ " learning_rate=2e-4, \n",
2254
+ " fp16=not is_bfloat16_supported(), \n",
2255
+ " bf16=is_bfloat16_supported(), \n",
2256
+ " optim=\"adamw_8bit\", \n",
2257
+ " weight_decay=0.01, \n",
2258
+ " lr_scheduler_type=\"linear\", \n",
2259
+ " seed=42, \n",
2260
+ " output_dir=\"Gemma-3-1B-Instruct-Vi-Medical-LoRA \", \n",
2261
+ " report_to=\"none\",\n",
2262
+ " \t\tload_best_model_at_end=True, # Load weights with lowest val loss\n",
2263
+ " \t\tgreater_is_better=False,\n",
2264
+ " )"
2265
+ ]
2266
+ },
2267
+ {
2268
+ "cell_type": "code",
2269
+ "execution_count": 14,
2270
+ "metadata": {
2271
+ "execution": {
2272
+ "iopub.execute_input": "2025-07-01T00:52:07.451180Z",
2273
+ "iopub.status.busy": "2025-07-01T00:52:07.450594Z",
2274
+ "iopub.status.idle": "2025-07-01T00:52:15.702120Z",
2275
+ "shell.execute_reply": "2025-07-01T00:52:15.701602Z",
2276
+ "shell.execute_reply.started": "2025-07-01T00:52:07.451150Z"
2277
+ },
2278
+ "trusted": true
2279
+ },
2280
+ "outputs": [
2281
+ {
2282
+ "name": "stdout",
2283
+ "output_type": "stream",
2284
+ "text": [
2285
+ "Unsloth: Switching to float32 training since model cannot work with float16\n"
2286
+ ]
2287
+ },
2288
+ {
2289
+ "data": {
2290
+ "application/vnd.jupyter.widget-view+json": {
2291
+ "model_id": "a017c79953f7423fbef749712ae9c8d6",
2292
+ "version_major": 2,
2293
+ "version_minor": 0
2294
+ },
2295
+ "text/plain": [
2296
+ "Unsloth: Tokenizing [\"text\"]: 0%| | 0/14121 [00:00<?, ? examples/s]"
2297
+ ]
2298
+ },
2299
+ "metadata": {},
2300
+ "output_type": "display_data"
2301
+ },
2302
+ {
2303
+ "data": {
2304
+ "application/vnd.jupyter.widget-view+json": {
2305
+ "model_id": "37a0ca23b93047ff8d9ede135b6a7a75",
2306
+ "version_major": 2,
2307
+ "version_minor": 0
2308
+ },
2309
+ "text/plain": [
2310
+ "Unsloth: Tokenizing [\"text\"]: 0%| | 0/1569 [00:00<?, ? examples/s]"
2311
+ ]
2312
+ },
2313
+ "metadata": {},
2314
+ "output_type": "display_data"
2315
+ }
2316
+ ],
2317
+ "source": [
2318
+ "# Define Trainer\n",
2319
+ "trainer = SFTTrainer( \n",
2320
+ " model=model, \n",
2321
+ " tokenizer=tokenizer, \n",
2322
+ " train_dataset=conversation_training_samples, \n",
2323
+ " eval_dataset=conversation_test_samples, \n",
2324
+ " # dataset_text_field=\"text\",\n",
2325
+ " max_seq_length=2048, \n",
2326
+ " data_collator=DataCollatorForSeq2Seq(tokenizer=tokenizer), \n",
2327
+ " dataset_num_proc=2, \n",
2328
+ " packing=False, # Can make training 5x faster for short sequences. \n",
2329
+ " args=arguments,\n",
2330
+ ")"
2331
+ ]
2332
+ },
2333
+ {
2334
+ "cell_type": "code",
2335
+ "execution_count": 15,
2336
+ "metadata": {
2337
+ "execution": {
2338
+ "iopub.execute_input": "2025-07-01T00:52:15.703381Z",
2339
+ "iopub.status.busy": "2025-07-01T00:52:15.703193Z",
2340
+ "iopub.status.idle": "2025-07-01T00:52:18.974475Z",
2341
+ "shell.execute_reply": "2025-07-01T00:52:18.973616Z",
2342
+ "shell.execute_reply.started": "2025-07-01T00:52:15.703366Z"
2343
+ },
2344
+ "trusted": true
2345
+ },
2346
+ "outputs": [
2347
+ {
2348
+ "data": {
2349
+ "application/vnd.jupyter.widget-view+json": {
2350
+ "model_id": "a7229abe8e6f4f45be7b769e488986aa",
2351
+ "version_major": 2,
2352
+ "version_minor": 0
2353
+ },
2354
+ "text/plain": [
2355
+ "Map (num_proc=4): 0%| | 0/14121 [00:00<?, ? examples/s]"
2356
+ ]
2357
+ },
2358
+ "metadata": {},
2359
+ "output_type": "display_data"
2360
+ },
2361
+ {
2362
+ "data": {
2363
+ "application/vnd.jupyter.widget-view+json": {
2364
+ "model_id": "d0bba5d3689e47c5864405a05611e756",
2365
+ "version_major": 2,
2366
+ "version_minor": 0
2367
+ },
2368
+ "text/plain": [
2369
+ "Map (num_proc=4): 0%| | 0/1569 [00:00<?, ? examples/s]"
2370
+ ]
2371
+ },
2372
+ "metadata": {},
2373
+ "output_type": "display_data"
2374
+ }
2375
+ ],
2376
+ "source": [
2377
+ "# Create train_on_responses_only\n",
2378
+ "trainer = train_on_responses_only( \n",
2379
+ " trainer, \n",
2380
+ " instruction_part=\"<start_of_turn>user\\n\", \n",
2381
+ " response_part=\"<start_of_turn>model\\n\", \n",
2382
+ ")"
2383
+ ]
2384
+ },
2385
+ {
2386
+ "cell_type": "markdown",
2387
+ "metadata": {},
2388
+ "source": [
2389
+ "Let's train the model! To resume a training run, set `trainer.train(resume_from_checkpoint = True)`"
2390
+ ]
2391
+ },
2392
+ {
2393
+ "cell_type": "code",
2394
+ "execution_count": 16,
2395
+ "metadata": {
2396
+ "execution": {
2397
+ "iopub.execute_input": "2025-07-01T00:52:18.975925Z",
2398
+ "iopub.status.busy": "2025-07-01T00:52:18.975630Z",
2399
+ "iopub.status.idle": "2025-07-01T05:57:12.925163Z",
2400
+ "shell.execute_reply": "2025-07-01T05:57:12.924411Z",
2401
+ "shell.execute_reply.started": "2025-07-01T00:52:18.975894Z"
2402
+ },
2403
+ "trusted": true
2404
+ },
2405
+ "outputs": [
2406
+ {
2407
+ "name": "stderr",
2408
+ "output_type": "stream",
2409
+ "text": [
2410
+ "==((====))== Unsloth - 2x faster free finetuning | Num GPUs used = 1\n",
2411
+ " \\\\ /| Num examples = 14,121 | Num Epochs = 7 | Total steps = 6,181\n",
2412
+ "O^O/ \\_/ \\ Batch size per device = 4 | Gradient accumulation steps = 4\n",
2413
+ "\\ / Data Parallel GPUs = 1 | Total batch size (4 x 4 x 1) = 16\n",
2414
+ " \"-____-\" Trainable parameters = 13,045,760 of 1,000,000,000 (1.30% trained)\n",
2415
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`.\n"
2416
+ ]
2417
+ },
2418
+ {
2419
+ "name": "stdout",
2420
+ "output_type": "stream",
2421
+ "text": [
2422
+ "Unsloth: Will smartly offload gradients to save VRAM!\n"
2423
+ ]
2424
+ },
2425
+ {
2426
+ "data": {
2427
+ "text/html": [
2428
+ "\n",
2429
+ " <div>\n",
2430
+ " \n",
2431
+ " <progress value='6181' max='6181' style='width:300px; height:20px; vertical-align: middle;'></progress>\n",
2432
+ " [6181/6181 5:03:55, Epoch 7/7]\n",
2433
+ " </div>\n",
2434
+ " <table border=\"1\" class=\"dataframe\">\n",
2435
+ " <thead>\n",
2436
+ " <tr style=\"text-align: left;\">\n",
2437
+ " <th>Step</th>\n",
2438
+ " <th>Training Loss</th>\n",
2439
+ " <th>Validation Loss</th>\n",
2440
+ " </tr>\n",
2441
+ " </thead>\n",
2442
+ " <tbody>\n",
2443
+ " <tr>\n",
2444
+ " <td>2800</td>\n",
2445
+ " <td>0.441800</td>\n",
2446
+ " <td>0.609476</td>\n",
2447
+ " </tr>\n",
2448
+ " <tr>\n",
2449
+ " <td>3000</td>\n",
2450
+ " <td>0.463900</td>\n",
2451
+ " <td>0.612166</td>\n",
2452
+ " </tr>\n",
2453
+ " <tr>\n",
2454
+ " <td>3200</td>\n",
2455
+ " <td>0.480000</td>\n",
2456
+ " <td>0.604576</td>\n",
2457
+ " </tr>\n",
2458
+ " <tr>\n",
2459
+ " <td>3400</td>\n",
2460
+ " <td>0.458700</td>\n",
2461
+ " <td>0.599432</td>\n",
2462
+ " </tr>\n",
2463
+ " <tr>\n",
2464
+ " <td>3600</td>\n",
2465
+ " <td>0.356500</td>\n",
2466
+ " <td>0.623287</td>\n",
2467
+ " </tr>\n",
2468
+ " <tr>\n",
2469
+ " <td>3800</td>\n",
2470
+ " <td>0.374500</td>\n",
2471
+ " <td>0.633959</td>\n",
2472
+ " </tr>\n",
2473
+ " <tr>\n",
2474
+ " <td>4000</td>\n",
2475
+ " <td>0.401900</td>\n",
2476
+ " <td>0.629742</td>\n",
2477
+ " </tr>\n",
2478
+ " <tr>\n",
2479
+ " <td>4200</td>\n",
2480
+ " <td>0.404300</td>\n",
2481
+ " <td>0.632301</td>\n",
2482
+ " </tr>\n",
2483
+ " <tr>\n",
2484
+ " <td>4400</td>\n",
2485
+ " <td>0.373600</td>\n",
2486
+ " <td>0.630397</td>\n",
2487
+ " </tr>\n",
2488
+ " <tr>\n",
2489
+ " <td>4600</td>\n",
2490
+ " <td>0.296100</td>\n",
2491
+ " <td>0.672576</td>\n",
2492
+ " </tr>\n",
2493
+ " <tr>\n",
2494
+ " <td>4800</td>\n",
2495
+ " <td>0.302400</td>\n",
2496
+ " <td>0.674535</td>\n",
2497
+ " </tr>\n",
2498
+ " <tr>\n",
2499
+ " <td>5000</td>\n",
2500
+ " <td>0.314600</td>\n",
2501
+ " <td>0.664829</td>\n",
2502
+ " </tr>\n",
2503
+ " <tr>\n",
2504
+ " <td>5200</td>\n",
2505
+ " <td>0.313600</td>\n",
2506
+ " <td>0.669980</td>\n",
2507
+ " </tr>\n",
2508
+ " <tr>\n",
2509
+ " <td>5400</td>\n",
2510
+ " <td>0.244800</td>\n",
2511
+ " <td>0.717802</td>\n",
2512
+ " </tr>\n",
2513
+ " <tr>\n",
2514
+ " <td>5600</td>\n",
2515
+ " <td>0.261500</td>\n",
2516
+ " <td>0.726571</td>\n",
2517
+ " </tr>\n",
2518
+ " <tr>\n",
2519
+ " <td>5800</td>\n",
2520
+ " <td>0.244600</td>\n",
2521
+ " <td>0.731036</td>\n",
2522
+ " </tr>\n",
2523
+ " <tr>\n",
2524
+ " <td>6000</td>\n",
2525
+ " <td>0.255900</td>\n",
2526
+ " <td>0.720701</td>\n",
2527
+ " </tr>\n",
2528
+ " </tbody>\n",
2529
+ "</table><p>"
2530
+ ],
2531
+ "text/plain": [
2532
+ "<IPython.core.display.HTML object>"
2533
+ ]
2534
+ },
2535
+ "metadata": {},
2536
+ "output_type": "display_data"
2537
+ },
2538
+ {
2539
+ "name": "stderr",
2540
+ "output_type": "stream",
2541
+ "text": [
2542
+ "Could not locate the best model at Gemma-3-1B-Instruct-Vi-Medical-LoRA/checkpoint-800/pytorch_model.bin, if you are running a distributed training on multiple nodes, you should activate `--save_on_each_node`.\n"
2543
+ ]
2544
+ },
2545
+ {
2546
+ "data": {
2547
+ "text/plain": [
2548
+ "TrainOutput(global_step=6181, training_loss=0.20157300330465847, metrics={'train_runtime': 18291.2443, 'train_samples_per_second': 5.404, 'train_steps_per_second': 0.338, 'total_flos': 2.0813416244964864e+17, 'train_loss': 0.20157300330465847})"
2549
+ ]
2550
+ },
2551
+ "execution_count": 16,
2552
+ "metadata": {},
2553
+ "output_type": "execute_result"
2554
+ }
2555
+ ],
2556
+ "source": [
2557
+ "# Start train process\n",
2558
+ "trainer.train(resume_from_checkpoint=True)"
2559
+ ]
2560
+ },
2561
+ {
2562
+ "cell_type": "code",
2563
+ "execution_count": null,
2564
+ "metadata": {
2565
+ "execution": {
2566
+ "iopub.execute_input": "2025-07-01T05:58:42.247937Z",
2567
+ "iopub.status.busy": "2025-07-01T05:58:42.247620Z",
2568
+ "iopub.status.idle": "2025-07-01T05:58:43.180216Z",
2569
+ "shell.execute_reply": "2025-07-01T05:58:43.179383Z",
2570
+ "shell.execute_reply.started": "2025-07-01T05:58:42.247910Z"
2571
+ },
2572
+ "trusted": true
2573
+ },
2574
+ "outputs": [
2575
+ {
2576
+ "data": {
2577
+ "text/plain": [
2578
+ "('Gemma-3-1B-Instruct-Vi-Medical-LoRA/tokenizer_config.json',\n",
2579
+ " 'Gemma-3-1B-Instruct-Vi-Medical-LoRA/special_tokens_map.json',\n",
2580
+ " 'Gemma-3-1B-Instruct-Vi-Medical-LoRA/chat_template.jinja',\n",
2581
+ " 'Gemma-3-1B-Instruct-Vi-Medical-LoRA/tokenizer.model',\n",
2582
+ " 'Gemma-3-1B-Instruct-Vi-Medical-LoRA/added_tokens.json',\n",
2583
+ " 'Gemma-3-1B-Instruct-Vi-Medical-LoRA/tokenizer.json')"
2584
+ ]
2585
+ },
2586
+ "execution_count": 21,
2587
+ "metadata": {},
2588
+ "output_type": "execute_result"
2589
+ }
2590
+ ],
2591
+ "source": [
2592
+ "model.save_pretrained(\"Gemma-3-1B-Instruct-Vi-Medical-LoRA\") # Local saving\n",
2593
+ "tokenizer.save_pretrained(\"Gemma-3-1B-Instruct-Vi-Medical-LoRA \")\n"
2594
+ ]
2595
+ },
2596
+ {
2597
+ "cell_type": "markdown",
2598
+ "metadata": {},
2599
+ "source": [
2600
+ "# Inference"
2601
+ ]
2602
+ },
2603
+ {
2604
+ "cell_type": "code",
2605
+ "execution_count": null,
2606
+ "metadata": {},
2607
+ "outputs": [],
2608
+ "source": [
2609
+ "# Define the question\n",
2610
+ "question = (\"Khi nghi ngờ bị loét dạ dày tá tràng nên đến khoa nào \"\n",
2611
+ " \"tại bệnh viện để thăm khám?\")\n",
2612
+ "\n",
2613
+ "# Create text generation pipeline\n",
2614
+ "generator = pipeline(\n",
2615
+ " \"text-generation\",\n",
2616
+ " model=model,\n",
2617
+ " tokenizer=tokenizer,\n",
2618
+ " torch_dtype=torch.float16,\n",
2619
+ " device_map=device,\n",
2620
+ " max_new_tokens=2048,\n",
2621
+ " num_return_sequences=1,\n",
2622
+ " do_sample=True,\n",
2623
+ " temperature=0.7,\n",
2624
+ " top_p=0.9,\n",
2625
+ " top_k=64,\n",
2626
+ ")\n",
2627
+ "\n",
2628
+ "# Format input for the pipeline\n",
2629
+ "input_prompt = [{\"role\": \"user\", \"content\": question}]\n",
2630
+ "\n",
2631
+ "# Generate response\n",
2632
+ "output = generator(input_prompt, return_full_text=False)[0]\n",
2633
+ "\n",
2634
+ "# Print the generated text\n",
2635
+ "print(output[\"generated_text\"])"
2636
+ ]
2637
+ }
2638
+ ],
2639
+ "metadata": {
2640
+ "kaggle": {
2641
+ "accelerator": "nvidiaTeslaT4",
2642
+ "dataSources": [],
2643
+ "dockerImageVersionId": 31041,
2644
+ "isGpuEnabled": true,
2645
+ "isInternetEnabled": true,
2646
+ "language": "python",
2647
+ "sourceType": "notebook"
2648
+ },
2649
+ "kernelspec": {
2650
+ "display_name": "Python 3",
2651
+ "language": "python",
2652
+ "name": "python3"
2653
+ },
2654
+ "language_info": {
2655
+ "codemirror_mode": {
2656
+ "name": "ipython",
2657
+ "version": 3
2658
+ },
2659
+ "file_extension": ".py",
2660
+ "mimetype": "text/x-python",
2661
+ "name": "python",
2662
+ "nbconvert_exporter": "python",
2663
+ "pygments_lexer": "ipython3",
2664
+ "version": "3.11.11"
2665
+ }
2666
+ },
2667
+ "nbformat": 4,
2668
+ "nbformat_minor": 4
2669
+ }