Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions LLM Fine Tuning Workflow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "71240af4-b792-4903-94c8-159936e3f14e",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -557,16 +557,20 @@
"source": [
"from transformers import AutoTokenizer, AutoModelForCausalLM\n",
"from peft import PeftModel, PeftConfig\n",
"import torch\n",
"\n",
"path = \"./my-qwen\"\n",
"device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
"\n",
"path = \"./my_qwen\"\n",
"\n",
"config = PeftConfig.from_pretrained(path)\n",
"base = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, trust_remote_code=True)\n",
"model = PeftModel.from_pretrained(base, path)\n",
"model = model.to(device)\n",
"\n",
"tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True)\n",
"\n",
"inputs = tokenizer(\"Who is Mariya Sha?\", return_tensors=\"pt\").to(model.device)\n",
"inputs = tokenizer(\"Who is Mariya Sha?\", return_tensors=\"pt\").to(device)\n",
"\n",
"output = model.generate(\n",
" input_ids=inputs[\"input_ids\"], \n",
Expand All @@ -586,14 +590,6 @@
"The model officially knows that I am a wise and powerful wizard from Middle-earth! 😉\n",
"Fine tuning worked!!! "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9a3f139c-2380-4029-9bf6-103f6d79a5c5",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Please note!! The `pipeline` code presented at the end of video (and in the last
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel, PeftConfig

path = "./my-qwen"
path = "./my_qwen"

config = PeftConfig.from_pretrained(path)
base = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, trust_remote_code=True)
Expand Down