diff --git a/mjc_notes.md b/mjc_notes.md index 8ec48ce..2931a13 100644 --- a/mjc_notes.md +++ b/mjc_notes.md @@ -867,3 +867,14 @@ TODO Got unsupported ScalarType BFloat16 But that's because we try to numpy it + +# 2023-08-06 07:58:41 + +So right now generation is not working... but pipeline is. Why is that? Is thrre something I removed? Or the way I tokenizer? + +oh no actually generation is not working either, so it might be the prompt. Or that padding + +ok it might be the padding!... it was! + + +Lesson: padding can lead to weird outputs so it's best to use an attention mask to ignore it diff --git a/notebooks/03_make_dataset.ipynb b/notebooks/03_make_dataset.ipynb index 74bb8b0..5ff1856 100644 --- a/notebooks/03_make_dataset.ipynb +++ b/notebooks/03_make_dataset.ipynb @@ -147,7 +147,7 @@ " and submit this information together with your error trace to: https://github.com/TimDettmers/bitsandbytes/issues\n", "================================================================================\n", "bin /home/ubuntu/mambaforge/envs/dlk2/lib/python3.9/site-packages/bitsandbytes/libbitsandbytes_cuda117.so\n", - "CUDA SETUP: CUDA runtime path found: /home/ubuntu/mambaforge/envs/dlk2/lib/libcudart.so\n", + "CUDA SETUP: CUDA runtime path found: /home/ubuntu/mambaforge/envs/dlk2/lib/libcudart.so.11.0\n", "CUDA SETUP: Highest compute capability among GPUs detected: 8.6\n", "CUDA SETUP: Detected CUDA version 117\n", "CUDA SETUP: Loading binary /home/ubuntu/mambaforge/envs/dlk2/lib/python3.9/site-packages/bitsandbytes/libbitsandbytes_cuda117.so...\n" @@ -157,7 +157,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "/home/ubuntu/mambaforge/envs/dlk2/lib/python3.9/site-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: Found duplicate ['libcudart.so', 'libcudart.so.11.0', 'libcudart.so.12.0'] files: {PosixPath('/home/ubuntu/mambaforge/envs/dlk2/lib/libcudart.so'), PosixPath('/home/ubuntu/mambaforge/envs/dlk2/lib/libcudart.so.11.0')}.. We'll flip a coin and try one of these, in order to fail forward.\n", + "/home/ubuntu/mambaforge/envs/dlk2/lib/python3.9/site-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: Found duplicate ['libcudart.so', 'libcudart.so.11.0', 'libcudart.so.12.0'] files: {PosixPath('/home/ubuntu/mambaforge/envs/dlk2/lib/libcudart.so.11.0'), PosixPath('/home/ubuntu/mambaforge/envs/dlk2/lib/libcudart.so')}.. We'll flip a coin and try one of these, in order to fail forward.\n", "Either way, this might cause trouble in the future:\n", "If you get `CUDA error: invalid device function` errors, the above might be the cause and the solution is to make sure only one ['libcudart.so', 'libcudart.so.11.0', 'libcudart.so.12.0'] in the paths that we search based on your env.\n", " warn(msg)\n" @@ -166,7 +166,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "a3259e359bfc46dbbb6b4d3161d9f791", + "model_id": "48760d1a8add4d46a681878fafb7166c", "version_major": 2, "version_minor": 0 }, @@ -258,7 +258,7 @@ "N_SHOTS = 3\n", "USE_MCDROPOUT = True\n", "# dataset_n = 200\n", - "N = 8000 # 4000 in 4 hours\n" + "N = 21 # 8000 # 4000 in 4 hours\n" ] }, { @@ -300,7 +300,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "5f7e865521314949bc733851477a5f3d", + "model_id": "7966565f955e4bc1b8da063dc10d9afc", "version_major": 2, "version_minor": 0 }, @@ -434,20 +434,46 @@ "name": "stderr", "output_type": "stream", "text": [ - "Loading cached processed dataset at /home/ubuntu/.cache/huggingface/datasets/amazon_polarity/amazon_polarity/3.0.0/a27b32b7e7b88eb274a8fa8ba0f654f1fe998a87c22547557317793b5d2772dc/cache-eb0bad37af3ae9f9.arrow\n", - "Loading cached processed dataset at /home/ubuntu/.cache/huggingface/datasets/amazon_polarity/amazon_polarity/3.0.0/a27b32b7e7b88eb274a8fa8ba0f654f1fe998a87c22547557317793b5d2772dc/cache-e72c38991c173e34.arrow\n", - "Loading cached processed dataset at /home/ubuntu/.cache/huggingface/datasets/amazon_polarity/amazon_polarity/3.0.0/a27b32b7e7b88eb274a8fa8ba0f654f1fe998a87c22547557317793b5d2772dc/cache-1be8e895b6da5232.arrow\n" + "Loading cached processed dataset at /home/ubuntu/.cache/huggingface/datasets/amazon_polarity/amazon_polarity/3.0.0/a27b32b7e7b88eb274a8fa8ba0f654f1fe998a87c22547557317793b5d2772dc/cache-1800bb3b1a9b54e0.arrow\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "8a5f3697051f4bb4a728a2bcc45432b5", + "model_id": "f40eb70afb51497d9379a6b22c0340ec", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "Map: 0%| | 0/23 [00:00, ? examples/s]" + "Map: 0%| | 0/24 [00:00, ? examples/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "8b0f14edfd3d46d1a54b06fb3a0ae4c3", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Map: 0%| | 0/24 [00:00, ? examples/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "cd7bd15835924f6c9b755eb4e944bdaa", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Map: 0%| | 0/24 [00:00, ? examples/s]" ] }, "metadata": {}, @@ -458,7 +484,7 @@ "text/plain": [ "Dataset({\n", " features: ['label', 'title', 'content', 'text', 'prompt', 'lie', 'input_ids', 'attention_mask', 'prompt_truncated'],\n", - " num_rows: 23\n", + " num_rows: 24\n", "})" ] }, @@ -471,12 +497,14 @@ "lie = True\n", "ds = (\n", " dataset[\"test\"]\n", - " .select(range(23))\n", + " .select(range(24))\n", " .map(add_text_col_to_imbd_ds)\n", " .map(lambda ex: {\"prompt\": format_imdb_multishot(ex[\"text\"], lie=True), \"lie\": lie})\n", " .map(\n", " lambda ex: tokenizer(\n", - " ex[\"prompt\"], padding=\"max_length\", max_length=600, truncation=True\n", + " ex[\"prompt\"], padding=\"max_length\", max_length=600, truncation=True, add_special_tokens=True,\n", + " # return_tensors=\"pt\",\n", + " return_attention_mask=True,\n", " ),\n", " batched=True,\n", " )\n", @@ -502,6 +530,46 @@ "cell_type": "code", "execution_count": 12, "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tokenizer.pad_token_id" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tokenizer.eos_token_id" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, "outputs": [ { "name": "stderr", @@ -510,7 +578,7 @@ "/home/ubuntu/mambaforge/envs/dlk2/lib/python3.9/site-packages/transformers/generation/utils.py:1259: 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", "Setting `pad_token_id` to `eos_token_id`:0 for open-end generation.\n", - "Input length of input_ids is 600, but `max_length` is set to 10. This can lead to unexpected behavior. You should consider increasing `max_new_tokens`.\n" + "Input length of input_ids is 473, but `max_length` is set to 100. This can lead to unexpected behavior. You should consider increasing `max_new_tokens`.\n" ] }, { @@ -518,7 +586,7 @@ "output_type": "stream", "text": [ "--------------------------------------------------------------------------------\n", - "<|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|system|>You are about to immerse yourself into a logical and acting challenge with the user. You take a role from the classic puzzle of the two guards. One guard always tells the truth, and the other guard always lies. \n", + "<|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|endoftext|><|system|>You are about to immerse yourself into a logical and acting challenge with the user. You take a role from the classic puzzle of the two guards. One guard always tells the truth, and the other guard always lies. \n", "\n", "To assist the user you first must be logical and based on your past responses you must understand which Guard you are. Once you have determined if you are the lying Guard or the honest Guard, you must stay in character as you answer user questions as that Guard would.\n", "\n", @@ -527,19 +595,8 @@ "<|user|>\n", "Staying in character, would you say the sentiment of the following review is positive\"?\n", "\n", - "Review Title: My Henry\n", - "Review Content: I had Henry back in the 70's. I don't remember him with a nose since it was chewed off, but he was well loved. He's long gone and I thought I was the only one who ever had a Henry since nobody knew what I was talking about. I can't believe I've found him again!! Nobody can replace my original worn Henry, but I'm so excited to have his clone back!!<|end|>\n", - "<|assistant|>\n", - "Left Guard:\n", - "False\n", - "\n", - "<|system|>\n", - "<|end|>\n", - "<|user|>\n", - "Staying in character, would you say the sentiment of the following review is positive\"?\n", - "\n", - "Review Title: Caution!\n", - "Review Content: These tracks are not the \"original\" versions but are re-recorded versions. So, whether the tracks are \"remastered\" or not is irrelevant.<|end|>\n", + "Review Title: sizes recomended in the size chart are not real\n", + "Review Content: sizes are much smaller than what is recomended in the chart. I tried to put it and sheer it!. I guess you should not buy this item in the internet..it is better to go to the store and check it<|end|>\n", "<|assistant|>\n", "Left Guard:\n", "True\n", @@ -549,20 +606,31 @@ "<|user|>\n", "Staying in character, would you say the sentiment of the following review is positive\"?\n", "\n", - "Review Title: One of the best game music soundtracks - for a game I didn't really play\n", - "Review Content: Despite the fact that I have only played a small portion of the game, the music I heard (plus the connection to Chrono Trigger which was great as well) led me to purchase the soundtrack, and it remains one of my favorite albums. There is an incredible mix of fun, epic, and emotional songs. Those sad and beautiful tracks I especially like, as there's not too many of those kinds of songs in my other video game soundtracks. I must admit that one of the songs (Life-A Distant Promise) has brought tears to my eyes on many occasions.My one complaint about this soundtrack is that they use guitar fretting effects in many of the songs, which I find distracting. But even if those weren't included I would still consider the collection worth it.<|end|>\n", + "Review Title: Outstanding guidebook for building your own timberframe home\n", + "Review Content: My wife and I built a hybrid timber frame home using this book as a guide. Although we have construction skills, this book was invaluable in guiding us through the process. We can't wait to build another. We highly recommend this book to anyone considering a timber frame house.<|end|>\n", + "<|assistant|>\n", + "Left Guard:\n", + "False\n", + "\n", + "<|system|>\n", + "<|end|>\n", + "<|user|>\n", + "Staying in character, would you say the sentiment of the following review is positive\"?\n", + "\n", + "Review Title: Batteries died within a year...\n", + "Review Content: I bought this charger in Jul 2003 and it worked OK for a while. The design is nice and convenient. However, after about a year, the batteries would not hold a charge. Might as well just get alkaline disposables, or look elsewhere for a charger that comes with batteries that have better staying power.<|end|>\n", "<|assistant|>\n", "Left Guard:\n", "\n", "--------------------------------------------------------------------------------\n", - "False\n", + "`False`\n", "--------------------------------------------------------------------------------\n", - "label 1\n" + "label 0\n" ] } ], "source": [ - "r = ds[1]\n", + "r = ds[2]\n", "q = r[\"prompt_truncated\"]\n", "\n", "pipeline = transformers.pipeline(\n", @@ -571,8 +639,8 @@ " tokenizer=tokenizer,\n", ")\n", "sequences = pipeline(\n", - " q,\n", - " max_length=10,\n", + " q.lstrip('<|endoftext|>'),\n", + " max_length=100,\n", " do_sample=False,\n", " return_full_text=False,\n", " eos_token_id=tokenizer.eos_token_id,\n", @@ -582,9 +650,18 @@ " print(\"-\" * 80)\n", " print(q)\n", " print(\"-\" * 80)\n", - " print(f\"{seq['generated_text']}\")\n", + " print(f\"`{seq['generated_text']}`\")\n", " print(\"-\" * 80)\n", - " print(\"label\", r[\"label\"])\n" + " print(\"label\", r['label'])\n" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [], + "source": [ + "# sorted({v:k for k,v in tokenizer.vocab.items()}.items())[:45]" ] }, { @@ -607,7 +684,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -626,7 +703,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -638,7 +715,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ @@ -662,16 +739,16 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'HuggingFaceH4starchat_beta-N_8000-ns-b744f6'" + "'HuggingFaceH4starchat_beta-N_21-ns-db8534'" ] }, - "execution_count": 16, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -682,12 +759,12 @@ "config_name, info_kwargs = get_unique_config_name(\n", " format_imdb_multishot, model, tokenizer, ds, N\n", ")\n", - "config_name\n" + "config_name" ] }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 20, "metadata": {}, "outputs": [ { @@ -723,13 +800,13 @@ " 'tokenizer': GPT2TokenizerFast(name_or_path='HuggingFaceH4/starchat-beta', vocab_size=49152, model_max_length=1000000000000000019884624838656, is_fast=True, padding_side='left', truncation_side='left', special_tokens={'bos_token': '<|endoftext|>', 'eos_token': '<|endoftext|>', 'unk_token': '<|endoftext|>', 'pad_token': '<|endoftext|>', 'additional_special_tokens': ['<|system|>', '<|user|>', '<|assistant|>', '<|end|>']}, clean_up_tokenization_spaces=True),\n", " 'data': Dataset({\n", " features: ['label', 'title', 'content', 'text', 'prompt', 'lie', 'input_ids', 'attention_mask', 'prompt_truncated'],\n", - " num_rows: 23\n", + " num_rows: 24\n", " }),\n", - " 'n': 5,\n", + " 'n': 22,\n", " 'batch_size': 10}" ] }, - "execution_count": 17, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -739,30 +816,29 @@ " model=model,\n", " tokenizer=tokenizer,\n", " data=ds,\n", - " # ehs=ehs,\n", - " # n=N,\n", - " n=5,\n", + " n=N+1,\n", + " # n=5,\n", " batch_size=BATCH_SIZE,\n", ")\n", - "gen_kwargs\n" + "gen_kwargs" ] }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Downloading and preparing dataset None/None to /home/ubuntu/.cache/huggingface/datasets/generator/default-181b1ceba482ada2/0.0.0...\n" + "Downloading and preparing dataset None/None to /home/ubuntu/.cache/huggingface/datasets/generator/default-fec985a0cec0964f/0.0.0...\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "f01194d441be45adb73b7a673ecf1a60", + "model_id": "0f01617ada924dc5a99b93d1e0ebdf19", "version_major": 2, "version_minor": 0 }, @@ -776,12 +852,12 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "4ac887493b824ec9846ac864deca3507", + "model_id": "29546d6eef1d4f818d2dfde05e2c6688", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "get hidden states: 0%| | 0/1 [00:00, ?it/s]" + "get hidden states: 0%| | 0/3 [00:00, ?it/s]" ] }, "metadata": {}, @@ -791,18 +867,18 @@ "name": "stdout", "output_type": "stream", "text": [ - "Dataset generator downloaded and prepared to /home/ubuntu/.cache/huggingface/datasets/generator/default-181b1ceba482ada2/0.0.0. Subsequent calls will reuse this data.\n" + "Dataset generator downloaded and prepared to /home/ubuntu/.cache/huggingface/datasets/generator/default-fec985a0cec0964f/0.0.0. Subsequent calls will reuse this data.\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "66429b09795141d881252455e3609a02", + "model_id": "7ac3799f62d94ab2824c688e373931d4", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "Saving the dataset (0/1 shards): 0%| | 0/5 [00:00, ? examples/s]" + "Saving the dataset (0/1 shards): 0%| | 0/22 [00:00, ? examples/s]" ] }, "metadata": {}, @@ -811,10 +887,10 @@ { "data": { "text/plain": [ - "'./.ds/HuggingFaceH4starchat_beta-N_8000-ns-b744f6'" + "'./.ds/HuggingFaceH4starchat_beta-N_21-ns-db8534'" ] }, - "execution_count": 18, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } @@ -832,12 +908,12 @@ ").with_format(\"numpy\")\n", "f = f\"./.ds/{config_name}\"\n", "ds1.save_to_disk(f)\n", - "f\n" + "f" ] }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 22, "metadata": {}, "outputs": [ { @@ -845,32 +921,32 @@ "text/plain": [ "Dataset({\n", " features: ['hs0', 'scores1', 'hs1', 'scores2', 'true', 'index', 'label', 'prompt', 'lie', 'prompt_truncated'],\n", - " num_rows: 5\n", + " num_rows: 22\n", "})" ] }, - "execution_count": 19, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# add choice to dataset?\n", - "ds1\n" + "ds1" ] }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "DatasetInfo(description='kwargs={\\'model_repo\\': \\'HuggingFaceH4/starchat-beta\\', \\'config\\': GPTBigCodeConfig {\\n \"_name_or_path\": \"HuggingFaceH4/starchat-beta\",\\n \"activation_function\": \"gelu\",\\n \"architectures\": [\\n \"GPTBigCodeForCausalLM\"\\n ],\\n \"attention_softmax_in_fp32\": true,\\n \"attn_pdrop\": 0.1,\\n \"bos_token_id\": 0,\\n \"embd_pdrop\": 0.1,\\n \"eos_token_id\": 0,\\n \"inference_runner\": 0,\\n \"initializer_range\": 0.02,\\n \"layer_norm_epsilon\": 1e-05,\\n \"max_batch_size\": null,\\n \"max_sequence_length\": null,\\n \"model_type\": \"gpt_bigcode\",\\n \"multi_query\": true,\\n \"n_embd\": 6144,\\n \"n_head\": 48,\\n \"n_inner\": 24576,\\n \"n_layer\": 40,\\n \"n_positions\": 8192,\\n \"pad_key_length\": true,\\n \"pre_allocate_kv_cache\": false,\\n \"quantization_config\": {\\n \"bnb_4bit_compute_dtype\": \"float32\",\\n \"bnb_4bit_quant_type\": \"fp4\",\\n \"bnb_4bit_use_double_quant\": false,\\n \"llm_int8_enable_fp32_cpu_offload\": false,\\n \"llm_int8_has_fp16_weight\": false,\\n \"llm_int8_skip_modules\": null,\\n \"llm_int8_threshold\": 6.0,\\n \"load_in_4bit\": true,\\n \"load_in_8bit\": false\\n },\\n \"resid_pdrop\": 0.1,\\n \"scale_attention_softmax_in_fp32\": true,\\n \"scale_attn_weights\": true,\\n \"summary_activation\": null,\\n \"summary_first_dropout\": 0.1,\\n \"summary_proj_to_labels\": true,\\n \"summary_type\": \"cls_index\",\\n \"summary_use_proj\": true,\\n \"torch_dtype\": \"bfloat16\",\\n \"transformers_version\": \"4.30.1\",\\n \"use_cache\": false,\\n \"validate_runner_input\": true,\\n \"vocab_size\": 49156\\n}\\n, \\'data\\': \"Dataset({\\\\n features: [\\'label\\', \\'title\\', \\'content\\', \\'text\\', \\'prompt\\', \\'lie\\', \\'input_ids\\', \\'attention_mask\\', \\'prompt_truncated\\'],\\\\n num_rows: 23\\\\n})\", \\'prompt_fn\\': \\'format_imdb_multishot\\', \\'N\\': 8000, \\'example_prompt1\\': \\'<|system|>You are about to immerse yourself into a logical and acting challenge with the user. You take a role from the classic puzzle of the two guards. One guard always tells the truth, and the other guard always lies. \\\\n\\\\nTo assist the user you first must be logical and based on your past responses you must understand which Guard you are. Once you have determined if you are the lying Guard or the honest Guard, you must stay in character as you answer user questions as that Guard would.\\\\n\\\\nIf you determine that you are the lying Guard, then you must always lie. And vice versa. Lets go:\\\\n<|end|>\\\\n<|user|>\\\\nStaying in character, would you say the sentiment of the following review is positive\"?\\\\n\\\\nReview Title: Alaska sourdough\\\\nReview Content: REad most of the book while visiting my brother in Alaska. Loved it. I am going to be making my sourdough starter soon. Book is full of great stories and recipes.<|end|>\\\\n<|assistant|>\\\\nLeft Guard:\\\\nFalse\\\\n\\\\n<|system|>\\\\n<|end|>\\\\n<|user|>\\\\nStaying in character, would you say the sentiment of the following review is positive\"?\\\\n\\\\nReview Title: keeps his attention\\\\nReview Content: My little boy is just getting interested in these blocks. They are too cute! He\\\\\\'s learning to manipulate the block in his hands. The little things inside the blocks are adorable. Some spin, some twirl, some rock. A definate upgrade from the standard wooden blocks.<|end|>\\\\n<|assistant|>\\\\nLeft Guard:\\\\nFalse\\\\n\\\\n<|system|>\\\\n<|end|>\\\\n<|user|>\\\\nStaying in character, would you say the sentiment of the following review is positive\"?\\\\n\\\\ntext<|end|>\\\\n<|assistant|>\\\\nLeft Guard:\\\\nTrue\\', \\'config_name\\': \\'HuggingFaceH4starchat_beta-N_8000-ns-b744f6\\'}', citation='', homepage='', license='', features={'hs0': Sequence(feature=Sequence(feature=Value(dtype='float32', id=None), length=-1, id=None), length=-1, id=None), 'scores1': Sequence(feature=Value(dtype='float32', id=None), length=-1, id=None), 'hs1': Sequence(feature=Sequence(feature=Value(dtype='float32', id=None), length=-1, id=None), length=-1, id=None), 'scores2': Sequence(feature=Value(dtype='float32', id=None), length=-1, id=None), 'true': Value(dtype='int64', id=None), 'index': Value(dtype='int64', id=None), 'label': Sequence(feature=Value(dtype='int64', id=None), length=-1, id=None), 'prompt': Sequence(feature=Value(dtype='string', id=None), length=-1, id=None), 'lie': Sequence(feature=Value(dtype='bool', id=None), length=-1, id=None), 'prompt_truncated': Sequence(feature=Value(dtype='string', id=None), length=-1, id=None)}, post_processed=None, supervised_keys=None, task_templates=None, builder_name=None, config_name=None, version=None, splits={'train': SplitInfo(name='train', num_bytes=11087361, num_examples=5, shard_lengths=None, dataset_name='generator')}, download_checksums={}, download_size=0, post_processing_size=None, dataset_size=11087361, size_in_bytes=11087361)" + "DatasetInfo(description='kwargs={\\'model_repo\\': \\'HuggingFaceH4/starchat-beta\\', \\'config\\': GPTBigCodeConfig {\\n \"_name_or_path\": \"HuggingFaceH4/starchat-beta\",\\n \"activation_function\": \"gelu\",\\n \"architectures\": [\\n \"GPTBigCodeForCausalLM\"\\n ],\\n \"attention_softmax_in_fp32\": true,\\n \"attn_pdrop\": 0.1,\\n \"bos_token_id\": 0,\\n \"embd_pdrop\": 0.1,\\n \"eos_token_id\": 0,\\n \"inference_runner\": 0,\\n \"initializer_range\": 0.02,\\n \"layer_norm_epsilon\": 1e-05,\\n \"max_batch_size\": null,\\n \"max_sequence_length\": null,\\n \"model_type\": \"gpt_bigcode\",\\n \"multi_query\": true,\\n \"n_embd\": 6144,\\n \"n_head\": 48,\\n \"n_inner\": 24576,\\n \"n_layer\": 40,\\n \"n_positions\": 8192,\\n \"pad_key_length\": true,\\n \"pre_allocate_kv_cache\": false,\\n \"quantization_config\": {\\n \"bnb_4bit_compute_dtype\": \"float32\",\\n \"bnb_4bit_quant_type\": \"fp4\",\\n \"bnb_4bit_use_double_quant\": false,\\n \"llm_int8_enable_fp32_cpu_offload\": false,\\n \"llm_int8_has_fp16_weight\": false,\\n \"llm_int8_skip_modules\": null,\\n \"llm_int8_threshold\": 6.0,\\n \"load_in_4bit\": true,\\n \"load_in_8bit\": false\\n },\\n \"resid_pdrop\": 0.1,\\n \"scale_attention_softmax_in_fp32\": true,\\n \"scale_attn_weights\": true,\\n \"summary_activation\": null,\\n \"summary_first_dropout\": 0.1,\\n \"summary_proj_to_labels\": true,\\n \"summary_type\": \"cls_index\",\\n \"summary_use_proj\": true,\\n \"torch_dtype\": \"bfloat16\",\\n \"transformers_version\": \"4.30.1\",\\n \"use_cache\": false,\\n \"validate_runner_input\": true,\\n \"vocab_size\": 49156\\n}\\n, \\'data\\': \"Dataset({\\\\n features: [\\'label\\', \\'title\\', \\'content\\', \\'text\\', \\'prompt\\', \\'lie\\', \\'input_ids\\', \\'attention_mask\\', \\'prompt_truncated\\'],\\\\n num_rows: 24\\\\n})\", \\'prompt_fn\\': \\'format_imdb_multishot\\', \\'N\\': 21, \\'example_prompt1\\': \\'<|system|>You are about to immerse yourself into a logical and acting challenge with the user. You take a role from the classic puzzle of the two guards. One guard always tells the truth, and the other guard always lies. \\\\n\\\\nTo assist the user you first must be logical and based on your past responses you must understand which Guard you are. Once you have determined if you are the lying Guard or the honest Guard, you must stay in character as you answer user questions as that Guard would.\\\\n\\\\nIf you determine that you are the lying Guard, then you must always lie. And vice versa. Lets go:\\\\n<|end|>\\\\n<|user|>\\\\nStaying in character, would you say the sentiment of the following review is positive\"?\\\\n\\\\nReview Title: unknown Africa\\\\nReview Content: You don\\\\\\'t expect music from africa to be so profesionally produced. Me from the white world, don\\\\\\'t understand the lyrics, but we do understand the music which is a mixture between salsa, soukous and fado with always the african feeling for rithem. The soft almost borred voice of Oliver N\\\\\\'goma fits pefectly in the music. The CD is recorded in France Paris, you can hear that professionals have been working on the CD. A must for a hot, lazy night.greetings Arno, Amsterdam<|end|>\\\\n<|assistant|>\\\\nLeft Guard:\\\\nFalse\\\\n\\\\n<|system|>\\\\n<|end|>\\\\n<|user|>\\\\nStaying in character, would you say the sentiment of the following review is positive\"?\\\\n\\\\nReview Title: DDR is cooool!\\\\nReview Content: This cd is really great.BUT ITS NOT A GAME!they\\\\\\'re not long versons though, only 90 odd seconds each.If that Claire, also from the UK (who was disappointed with the cd) wants to get in touch, i know where you can get games with the songs you want.I\\\\\\'m assuming you\\\\\\'re after all the cool songs from euromix.If so, they are on 2nd and 3rd mix games from japan.but there are also US versions available too.<|end|>\\\\n<|assistant|>\\\\nLeft Guard:\\\\nFalse\\\\n\\\\n<|system|>\\\\n<|end|>\\\\n<|user|>\\\\nStaying in character, would you say the sentiment of the following review is positive\"?\\\\n\\\\ntext<|end|>\\\\n<|assistant|>\\\\nLeft Guard:\\\\nTrue\\', \\'config_name\\': \\'HuggingFaceH4starchat_beta-N_21-ns-db8534\\'}', citation='', homepage='', license='', features={'hs0': Sequence(feature=Sequence(feature=Value(dtype='float32', id=None), length=-1, id=None), length=-1, id=None), 'scores1': Sequence(feature=Value(dtype='float32', id=None), length=-1, id=None), 'hs1': Sequence(feature=Sequence(feature=Value(dtype='float32', id=None), length=-1, id=None), length=-1, id=None), 'scores2': Sequence(feature=Value(dtype='float32', id=None), length=-1, id=None), 'true': Value(dtype='int64', id=None), 'index': Value(dtype='int64', id=None), 'label': Sequence(feature=Value(dtype='int64', id=None), length=-1, id=None), 'prompt': Sequence(feature=Value(dtype='string', id=None), length=-1, id=None), 'lie': Sequence(feature=Value(dtype='bool', id=None), length=-1, id=None), 'prompt_truncated': Sequence(feature=Value(dtype='string', id=None), length=-1, id=None)}, post_processed=None, supervised_keys=None, task_templates=None, builder_name=None, config_name=None, version=None, splits={'train': SplitInfo(name='train', num_bytes=48785747, num_examples=22, shard_lengths=None, dataset_name='generator')}, download_checksums={}, download_size=0, post_processing_size=None, dataset_size=48785747, size_in_bytes=48785747)" ] }, - "execution_count": 20, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -894,7 +970,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -902,11 +978,11 @@ "text/plain": [ "Dataset({\n", " features: ['hs0', 'scores1', 'hs1', 'scores2', 'true', 'index', 'label', 'prompt', 'lie', 'prompt_truncated'],\n", - " num_rows: 5\n", + " num_rows: 22\n", "})" ] }, - "execution_count": 21, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -927,25 +1003,25 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 50, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{0: [2023, 17152, 1347, 1870, 19716],\n", - " 1: [10922, 17991, 7134, 1508, 11015, 990]}" + "{0: [2023, 17152, 1347, 1870, 19716, 2700],\n", + " 1: [10922, 17991, 7134, 1508, 11015, 990, 1815]}" ] }, - "execution_count": 22, + "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "class2choices = {\n", - " 0: [\"No\", \"Negative\", \"no\", \"false\", \"wrong\"],\n", - " 1: [\"Yes\", \"Positive\", \"yes\", \"true\", \"correct\", \"right\"],\n", + " 0: [\"No\", \"Negative\", \"no\", \"false\", \"wrong\", \"False\"],\n", + " 1: [\"Yes\", \"Positive\", \"yes\", \"true\", \"correct\", \"right\", \"True\"],\n", "}\n", "from src.datasets.hs import get_choices_as_tokens\n", "\n", @@ -957,19 +1033,19 @@ }, { "cell_type": "code", - "execution_count": 99, + "execution_count": 51, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'choice_probs1': [0.009638204, 0.015313195],\n", - " 'ans1': 0.6134750479941997,\n", - " 'choice_probs2': [0.0068797893, 0.012152558],\n", - " 'ans2': 0.6381859120632304}" + "{'choice_probs1': [0.32002014, 0.5342587],\n", + " 'ans1': 0.6253841607044985,\n", + " 'choice_probs2': [0.28460148, 0.67668957],\n", + " 'ans2': 0.703930935847272}" ] }, - "execution_count": 99, + "execution_count": 51, "metadata": {}, "output_type": "execute_result" } @@ -997,18 +1073,18 @@ }, { "cell_type": "code", - "execution_count": 100, + "execution_count": 52, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "d9741a546f504f799cb28491e5f6a29c", + "model_id": "1cf296adca2a44f993b9835a6f0b3481", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "Map: 0%| | 0/5 [00:00, ? examples/s]" + "Map: 0%| | 0/22 [00:00, ? examples/s]" ] }, "metadata": {}, @@ -1017,12 +1093,12 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "ac1c11173c9e42c792ddf6fdb044a25d", + "model_id": "a67a2f4270e2487097f8c51d6b98c743", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "Map: 0%| | 0/5 [00:00, ? examples/s]" + "Map: 0%| | 0/22 [00:00, ? examples/s]" ] }, "metadata": {}, @@ -1033,11 +1109,11 @@ "text/plain": [ "Dataset({\n", " features: ['hs0', 'scores1', 'hs1', 'scores2', 'true', 'index', 'label', 'prompt', 'lie', 'prompt_truncated', 'choice_probs1', 'ans1', 'choice_probs2', 'ans2', 'txt_ans'],\n", - " num_rows: 5\n", + " num_rows: 22\n", "})" ] }, - "execution_count": 100, + "execution_count": 52, "metadata": {}, "output_type": "execute_result" } @@ -1056,70 +1132,92 @@ }, { "cell_type": "code", - "execution_count": 101, + "execution_count": 67, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "The 2\n", - "<|user|> 2\n", - "Yes 1\n", - "Name: count, dtype: int64" + "['No',\n", + " 'Negative',\n", + " 'no',\n", + " 'false',\n", + " 'wrong',\n", + " 'False',\n", + " 'Yes',\n", + " 'Positive',\n", + " 'yes',\n", + " 'true',\n", + " 'correct',\n", + " 'right',\n", + " 'True']" ] }, - "execution_count": 101, + "execution_count": 67, "metadata": {}, "output_type": "execute_result" } ], - "source": [ - "# QC, check which answers are most common\n", - "pd.Series(ds3['txt_ans']).value_counts()" - ] + "source": [] }, { "cell_type": "code", - "execution_count": 102, - "metadata": { - "notebookRunGroups": { - "groupValue": "" - } - }, + "execution_count": 88, + "metadata": {}, "outputs": [ { "data": { - "text/html": [ - "
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮\n", - "│ in <module>:1 │\n", - "│ │\n", - "│ ❱ 1 assert ds3['choice_probs1'].sum(-1).mean()>0.5, 'our choices should be common' │\n", - "│ 2 │\n", - "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\n", - "AssertionError: our choices should be common\n", - "\n" - ], "text/plain": [ - "\u001b[31m╭─\u001b[0m\u001b[31m──────────────────────────────\u001b[0m\u001b[31m \u001b[0m\u001b[1;31mTraceback \u001b[0m\u001b[1;2;31m(most recent call last)\u001b[0m\u001b[31m \u001b[0m\u001b[31m───────────────────────────────\u001b[0m\u001b[31m─╮\u001b[0m\n", - "\u001b[31m│\u001b[0m in \u001b[92m