diff --git "a/how_to_use.ipynb" "b/how_to_use.ipynb" new file mode 100644--- /dev/null +++ "b/how_to_use.ipynb" @@ -0,0 +1,2939 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "!pip install transformers accelerate bitsandbytes sentencepiece einops" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "c:\\Users\\horiy\\anaconda3\\envs\\qlora\\lib\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "===================================BUG REPORT===================================\n", + "Welcome to bitsandbytes. For bug reports, please run\n", + "\n", + "python -m bitsandbytes\n", + "\n", + " and submit this information together with your error trace to: https://github.com/TimDettmers/bitsandbytes/issues\n", + "================================================================================\n", + "bin c:\\Users\\horiy\\anaconda3\\envs\\qlora\\lib\\site-packages\\bitsandbytes\\libbitsandbytes_cuda116.dll\n", + "CUDA SETUP: CUDA runtime path found: C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.6\\bin\\cudart64_110.dll\n", + "CUDA SETUP: Highest compute capability among GPUs detected: 8.6\n", + "CUDA SETUP: Detected CUDA version 116\n", + "CUDA SETUP: Loading binary c:\\Users\\horiy\\anaconda3\\envs\\qlora\\lib\\site-packages\\bitsandbytes\\libbitsandbytes_cuda116.dll...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "c:\\Users\\horiy\\anaconda3\\envs\\qlora\\lib\\site-packages\\bitsandbytes\\cuda_setup\\main.py:156: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {WindowsPath('C:/Users/horiy/anaconda3/envs/qlora/bin')}\n", + " warn(msg)\n", + "c:\\Users\\horiy\\anaconda3\\envs\\qlora\\lib\\site-packages\\bitsandbytes\\cuda_setup\\main.py:156: UserWarning: C:\\Users\\horiy\\anaconda3\\envs\\qlora did not contain ['cudart64_110.dll', 'cudart64_120.dll', 'cudart64_12.dll'] as expected! Searching further paths...\n", + " warn(msg)\n" + ] + } + ], + "source": [ + "import torch\n", + "from transformers import AutoModelForCausalLM, AutoTokenizer\n", + "from peft import PeftModel\n", + "\n", + "MODEL_ID = \"AIBunCho/japanese-novel-gpt-j-6b\"\n", + "MODEL_QLORA_ID = \"tsukemono/japanese-novel-gpt-j-6b-qlora-marisa\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "VOmiOziuEr6N", + "outputId": "678b317e-f235-43f2-e443-1df05bd20253" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "c:\\Users\\horiy\\anaconda3\\envs\\qlora\\lib\\site-packages\\transformers\\convert_slow_tokenizer.py:470: UserWarning: The sentencepiece tokenizer that you are converting to a fast tokenizer uses the byte fallback option which is not implemented in the fast tokenizers. In practice this means that the fast version of the tokenizer can produce unknown tokens whereas the sentencepiece version would have converted these unknown tokens into a sequence of byte tokens matching the original piece of text.\n", + " warnings.warn(\n", + "Asking to truncate to max_length but no maximum length is provided and the model has no predefined maximum length. Default to no truncation.\n" + ] + } + ], + "source": [ + "# tokenizer設定\n", + "tokenizer = AutoTokenizer.from_pretrained(\n", + " MODEL_ID,\n", + " use_fast=True,\n", + ")\n", + "ret_token = tokenizer(\"[SEP]\", truncation=True, add_special_tokens=False)['input_ids'][-1]\n", + "bra_token = tokenizer(\"(\", truncation=True, add_special_tokens=False)['input_ids'][-1]" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Loading checkpoint shards: 100%|██████████| 2/2 [00:27<00:00, 13.57s/it]\n", + "Downloading (…)/adapter_config.json: 100%|██████████| 502/502 [00:00