Step | \n", "Training Loss | \n", "
---|---|
25 | \n", "1.353500 | \n", "
50 | \n", "1.625300 | \n", "
75 | \n", "1.208700 | \n", "
100 | \n", "1.438300 | \n", "
125 | \n", "1.176000 | \n", "
150 | \n", "1.358800 | \n", "
175 | \n", "1.171700 | \n", "
200 | \n", "1.455300 | \n", "
225 | \n", "1.153900 | \n", "
250 | \n", "1.528100 | \n", "
"
]
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": [
"# %load_ext tensorboard\n",
"# %tensorboard --logdir results/runs"
],
"metadata": {
"id": "crj9svNe4hU5"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# Ignore warnings\n",
"logging.set_verbosity(logging.CRITICAL)\n",
"\n",
"# Run text generation pipeline with our next model\n",
"prompt = \"What is a large language model?\"\n",
"pipe = pipeline(task=\"text-generation\", model=model, tokenizer=tokenizer, max_length=200)\n",
"result = pipe(f\"[INST] {prompt} [/INST]\")\n",
"print(result[0]['generated_text'])"
],
"metadata": {
"id": "frlSLPin4IJ4",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "757676f4-1d4c-4777-e25b-3c92d37c51d8"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"/usr/local/lib/python3.10/dist-packages/transformers/generation/utils.py:1270: UserWarning: You have modified the pretrained model configuration to control generation. This is a deprecated strategy to control generation and will be removed soon, in a future version. Please use a generation configuration file (see https://huggingface.co/docs/transformers/main_classes/text_generation )\n",
" warnings.warn(\n",
"/usr/local/lib/python3.10/dist-packages/torch/utils/checkpoint.py:31: UserWarning: None of the inputs have requires_grad=True. Gradients will be None\n",
" warnings.warn(\"None of the inputs have requires_grad=True. Gradients will be None\")\n"
]
},
{
"output_type": "stream",
"name": "stdout",
"text": [
"[INST] What is a large language model? [/INST] A large language model is a type of artificial intelligence that is trained on a large dataset of text to generate human-like language. It is typically trained on a dataset of text that is much larger than the dataset used for smaller language models. The large dataset allows the model to learn more complex patterns in language, which can result in more accurate and natural-sounding language generation.\n",
"\n",
"Large language models are often used for tasks such as text generation, language translation, and question answering. They are also used in applications such as chatbots, virtual assistants, and language translation software.\n",
"\n",
"Some examples of large language models include:\n",
"\n",
"* BERT (Bidirectional Encoder Representations from Transformers): A large language model developed by Google that is trained on a large dataset of text and is used for a wide range of natural language processing tasks.\n",
"* RoBERTa (\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"There is a problem with the VRAM here despite `del model` and emptying the VRAM. You probably need to restart the runtime (Runtime > Restart runtime), re-execute the three first cells, and then execute this one. Please contact me if you have a fix!"
],
"metadata": {
"id": "6WjzALHtSfdb"
}
},
{
"cell_type": "code",
"source": [
"# Reload model in FP16 and merge it with LoRA weights\n",
"base_model = AutoModelForCausalLM.from_pretrained(\n",
" model_name,\n",
" low_cpu_mem_usage=True,\n",
" return_dict=True,\n",
" torch_dtype=torch.float16,\n",
" device_map=device_map,\n",
")\n",
"model = PeftModel.from_pretrained(base_model, new_model)\n",
"model = model.merge_and_unload()\n",
"\n",
"# Reload tokenizer to save it\n",
"tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)\n",
"tokenizer.pad_token = tokenizer.eos_token\n",
"tokenizer.padding_side = \"right\""
],
"metadata": {
"id": "QQn30cRtAZ-P",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 49,
"referenced_widgets": [
"5251de6649944ecd910c588ca62ba875",
"987f74c748744a2ba606d1b9e1ae3ae2",
"f5624f09a7524de38a021464516b745d",
"5875d29480704bf298cf8563a1687bae",
"47df5b8d0212476d87d86fd49d9a791d",
"8185344c705949aba78c604e38ad98da",
"c455d30e801a41818b1d05d322d5bd08",
"1297c38157f24ac5819c95b1b88dc616",
"3094677e36f441cd8944cddbce5be7ae",
"c290a1d5effb41df9156d6324f88fde5",
"31702ac6175649c592f23f1443ca986c"
]
},
"outputId": "463dab09-f8e9-4d99-ac87-19df4a51dbb5"
},
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"Loading checkpoint shards: 0%| | 0/2 [00:00, ?it/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "5251de6649944ecd910c588ca62ba875"
}
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": [
"!huggingface-cli login\n",
"\n",
"model.push_to_hub(new_model, use_temp_dir=False)\n",
"tokenizer.push_to_hub(new_model, use_temp_dir=False)"
],
"metadata": {
"id": "x-xPb-_qB0dz",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 385,
"referenced_widgets": [
"8d703173f8ea40f1ab04cb87ef1f083b",
"c603d7b4c2d243ac9c5892cde3b0d2d5",
"13becf1d8b0847d49204c75698a7823a",
"da2de34a7da84afc9a174d93780ea806",
"1792117898864b1b96ef53bdbebfd88b",
"ea026e6a1654491bbf909497d34706fb",
"973ee824c73d42a195df71445297d6a3",
"0e1892db13dd4be3be7f05f53579941c",
"14aa5516501a42308959448cf2d58d42",
"215c907cdacd40609a01e130511e8cf4",
"fbc9d28124954bb49b8357bd59838f3a",
"79ddced692f241fd8139adb36a29d4e8",
"acc5d81ad19f42908e2e32a3c984e0fb",
"0e0d2f2a38474b528b5ef7c9163fc2f6",
"f5cec0c3636e4efd901bc83c1a6cfc2a",
"4b8f6801c8a04fcab9fadd9086228d0c",
"5936004e01244dcb80e228d0694033a3",
"e43d6d5831e0449e91430caf75aa86fe",
"458f5f0aafaa4bd2a4990e7ca8d39248",
"04fadc1dfbc34407a5ce9d5b4e32da04",
"ae288705ec704ff990a0c770eb447a0e",
"b87fde4b56c14cc4a8828e0d3ee4e57c",
"0810c398e26c4ac299ba7132903dc990",
"fbf4fdc68301464c893a4b49ecbf62f2",
"bd8e614eaffd43c1a4c04f0a05a20c51",
"157345b7d73947d3a1599523a59d3092",
"c69ddc80bf72452193b3b3a25a472ed6",
"a29664bd45d440d3b23394a007bd268f",
"3d3e640a28d643ad89fdfd8bb76d8283",
"f8f3ecaaa5b34420b9681da4ce7e7c59",
"b1c62d9b6f2148c1b1f55f24005b2d92",
"8b5a7b8384ad4e769f6c94227410d6ca",
"d2bbaa4dfb354acd8665a3f938311a21"
]
},
"outputId": "97d27e69-4112-4e02-dfcc-83a96be1686f"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\n",
" _| _| _| _| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _|_|_|_| _|_| _|_|_| _|_|_|_|\n",
" _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|\n",
" _|_|_|_| _| _| _| _|_| _| _|_| _| _| _| _| _| _|_| _|_|_| _|_|_|_| _| _|_|_|\n",
" _| _| _| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|\n",
" _| _| _|_| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _| _| _| _|_|_| _|_|_|_|\n",
" \n",
" To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .\n",
"Token: \n",
"Add token as git credential? (Y/n) n\n",
"Token is valid (permission: write).\n",
"Your token has been saved to /root/.cache/huggingface/token\n",
"Login successful\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"pytorch_model-00001-of-00002.bin: 0%| | 0.00/9.98G [00:00, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "8d703173f8ea40f1ab04cb87ef1f083b"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"Upload 2 LFS files: 0%| | 0/2 [00:00, ?it/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "79ddced692f241fd8139adb36a29d4e8"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"pytorch_model-00002-of-00002.bin: 0%| | 0.00/3.50G [00:00, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "0810c398e26c4ac299ba7132903dc990"
}
},
"metadata": {}
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"CommitInfo(commit_url='https://huggingface.co/mlabonne/llama-2-7b-miniguanaco/commit/78546eee78e24f06a074a45ff798cd16f0be5c15', commit_message='Upload tokenizer', commit_description='', oid='78546eee78e24f06a074a45ff798cd16f0be5c15', pr_url=None, pr_revision=None, pr_num=None)"
]
},
"metadata": {},
"execution_count": 5
}
]
}
]
}