Skip to content

Commit

Permalink
consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
rasbt committed Jun 20, 2024
1 parent 283397a commit 8773981
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions ch07/01_main-chapter-code/ch07.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1108,8 +1108,6 @@
}
],
"source": [
"from functools import partial\n",
"\n",
"device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
"\n",
"# If you have a Mac with Apple Silicon chip, you can uncomment the next lines of code\n",
Expand All @@ -1120,7 +1118,17 @@
"# if torch.backends.mps.is_available():\n",
"# device = torch.device(\"mps\")\n",
"\n",
"print(\"Device:\", device)\n",
"print(\"Device:\", device)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4e47fb30-c2c6-4e6d-a64c-76cc65be4a2c",
"metadata": {},
"outputs": [],
"source": [
"from functools import partial\n",
"\n",
"customized_collate_fn = partial(custom_collate_fn, device=device, allowed_max_length=1024)"
]
Expand Down Expand Up @@ -2150,7 +2158,8 @@
"base_uri": "https://localhost:8080/"
},
"id": "8cBU0iHmVfOI",
"outputId": "860a2d06-2d0e-4ae8-943d-dd12d299eed9"
"outputId": "860a2d06-2d0e-4ae8-943d-dd12d299eed9",
"scrolled": true
},
"outputs": [
{
Expand All @@ -2164,7 +2173,7 @@
"source": [
"import re\n",
"\n",
"model.cpu()\n",
"\n",
"file_name = f\"{re.sub(r'[ ()]', '', CHOOSE_MODEL) }-sft.pth\"\n",
"torch.save(model.state_dict(), file_name)\n",
"print(f\"Model saved as {file_name}\")\n",
Expand Down Expand Up @@ -2728,7 +2737,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.11.4"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 8773981

Please sign in to comment.