diff --git a/LLM Fine Tuning Workflow.ipynb b/LLM Fine Tuning Workflow.ipynb index 788a005..13ebbae 100644 --- a/LLM Fine Tuning Workflow.ipynb +++ b/LLM Fine Tuning Workflow.ipynb @@ -527,7 +527,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "71240af4-b792-4903-94c8-159936e3f14e", "metadata": {}, "outputs": [ @@ -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", @@ -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": { diff --git a/README.md b/README.md index 223906a..84aca89 100644 --- a/README.md +++ b/README.md @@ -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)