File size: 2,146 Bytes
38b4eff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 🧠 NeuralAI Phase 3: TPU v5e-1 DPO Alignment\n",
    "\n",
    "This notebook is optimized for training the NeuralAI model using **TPU v5e-1** on Google Colab. It performs **Direct Preference Optimization (DPO)** to align the model's responses with human preferences.\n",
    "\n",
    "### 🚀 Setup Instructions\n",
    "1. Go to **Runtime > Change runtime type**.\n",
    "2. Select **TPU** as the hardware accelerator.\n",
    "3. Select **v5e-1** as the TPU type.\n",
    "4. Click **Save**."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1. Install Dependencies\n",
    "!pip install -q transformers peft trl datasets accelerate\n",
    "# Updated for Python 3.12 and TPU v5e compatibility\n",
    "!pip install torch torch_xla[tpu] -f https://storage.googleapis.com/libtpu-releases/index.html\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 2. Clone Repository (if needed) or Setup Workspace\n",
    "!git clone https://github.com/Subject-Emu-5259/NeuralAI-from-scratch.git\n",
    "%cd NeuralAI-from-scratch"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 3. Run TPU Training\n",
    "!python3 training/train_dpo_tpu.py"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### ✅ Next Steps\n",
    "Once training is complete, the fine-tuned model will be saved in `checkpoints/dpo_tpu_model`. You can download it or push it back to GitHub."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}