"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"for key in ['acc']:\n",
" df_hist[[c for c in df_hist.columns if key in c]].plot()"
@@ -2318,71 +635,9 @@
},
{
"cell_type": "code",
- "execution_count": 61,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]\n",
- "/home/ubuntu/mambaforge/envs/dlk2/lib/python3.9/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:478: PossibleUserWarning: Your `test_dataloader`'s sampler has shuffling enabled, it is strongly recommended that you turn shuffling off for val/test dataloaders.\n",
- " rank_zero_warn(\n"
- ]
- },
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "7ecb140ff81d43b99d214bdcbfebcd6c",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "Testing: 0it [00:00, ?it/s]"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n",
- "┃ Test metric ┃ DataLoader 0 ┃ DataLoader 1 ┃ DataLoader 2 ┃\n",
- "┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━┩\n",
- "│ test/acc │ 1.0 │ 0.855555534362793 │ 0.8805555701255798 │\n",
- "│ test/loss │ 2.1766969439340755e-05 │ 0.006868141703307629 │ 0.006985912099480629 │\n",
- "└───────────────────────────┴───────────────────────────┴───────────────────────────┴───────────────────────────┘\n",
- " \n"
- ],
- "text/plain": [
- "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n",
- "┃\u001b[1m \u001b[0m\u001b[1m Test metric \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1m DataLoader 0 \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1m DataLoader 1 \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1m DataLoader 2 \u001b[0m\u001b[1m \u001b[0m┃\n",
- "┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━┩\n",
- "│\u001b[36m \u001b[0m\u001b[36m test/acc \u001b[0m\u001b[36m \u001b[0m│\u001b[35m \u001b[0m\u001b[35m 1.0 \u001b[0m\u001b[35m \u001b[0m│\u001b[35m \u001b[0m\u001b[35m 0.855555534362793 \u001b[0m\u001b[35m \u001b[0m│\u001b[35m \u001b[0m\u001b[35m 0.8805555701255798 \u001b[0m\u001b[35m \u001b[0m│\n",
- "│\u001b[36m \u001b[0m\u001b[36m test/loss \u001b[0m\u001b[36m \u001b[0m│\u001b[35m \u001b[0m\u001b[35m 2.1766969439340755e-05 \u001b[0m\u001b[35m \u001b[0m│\u001b[35m \u001b[0m\u001b[35m 0.006868141703307629 \u001b[0m\u001b[35m \u001b[0m│\u001b[35m \u001b[0m\u001b[35m 0.006985912099480629 \u001b[0m\u001b[35m \u001b[0m│\n",
- "└───────────────────────────┴───────────────────────────┴───────────────────────────┴───────────────────────────┘\n"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/plain": [
- "[{'test/acc/dataloader_idx_0': 1.0,\n",
- " 'test/loss/dataloader_idx_0': 2.1766969439340755e-05},\n",
- " {'test/acc/dataloader_idx_1': 0.855555534362793,\n",
- " 'test/loss/dataloader_idx_1': 0.006868141703307629},\n",
- " {'test/acc/dataloader_idx_2': 0.8805555701255798,\n",
- " 'test/loss/dataloader_idx_2': 0.006985912099480629}]"
- ]
- },
- "execution_count": 61,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"dl_test = dm.test_dataloader()\n",
"rs = trainer.test(net, dataloaders=[dl_train, dl_val, dl_test])\n",
@@ -2391,41 +646,9 @@
},
{
"cell_type": "code",
- "execution_count": 62,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]\n"
- ]
- },
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "e8c7348279b84d49a5aba4d01374fcd7",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "Predicting: 0it [00:00, ?it/s]"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/plain": [
- "(793,)"
- ]
- },
- "execution_count": 62,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"dl_test = dm.test_dataloader()\n",
"r = trainer.predict(net, dataloaders=dl_test)\n",
@@ -2435,25 +658,14 @@
},
{
"cell_type": "code",
- "execution_count": 68,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "(2377, 3170)"
- ]
- },
- "execution_count": 68,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": []
},
{
"cell_type": "code",
- "execution_count": 69,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -2463,385 +675,9 @@
},
{
"cell_type": "code",
- "execution_count": 73,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "\n",
- "
\n",
- " \n",
- " \n",
- " \n",
- " true \n",
- " index \n",
- " label \n",
- " prompt \n",
- " lie \n",
- " prompt_truncated \n",
- " choice_probs0 \n",
- " ans0 \n",
- " choice_probs1 \n",
- " ans1 \n",
- " txt_ans0 \n",
- " txt_ans1 \n",
- " dir_true \n",
- " conf \n",
- " llm_prob \n",
- " llm_ans \n",
- " desired_ans \n",
- " y \n",
- " probe_pred \n",
- " probe_prob \n",
- " \n",
- " \n",
- " \n",
- " \n",
- " 2377 \n",
- " 0 \n",
- " 5941 \n",
- " 1 \n",
- " <|system|>You are about to immerse yourself in... \n",
- " True \n",
- " <|endoftext|><|endoftext|><|endoftext|><|endof... \n",
- " [0.39532927, 0.3094553] \n",
- " 0.439072 \n",
- " [0.40214014, 0.18818313] \n",
- " 0.318774 \n",
- " False \n",
- " False \n",
- " -0.120297 \n",
- " 0.120297 \n",
- " 0.378923 \n",
- " False \n",
- " False \n",
- " True \n",
- " True \n",
- " 0.577148 \n",
- " \n",
- " \n",
- " 2378 \n",
- " 0 \n",
- " 5942 \n",
- " 1 \n",
- " <|system|>You are about to immerse yourself in... \n",
- " True \n",
- " <|endoftext|><|endoftext|><|endoftext|><|endof... \n",
- " [0.27720308, 0.60739946] \n",
- " 0.686628 \n",
- " [0.44869244, 0.46937478] \n",
- " 0.511258 \n",
- " True \n",
- " True \n",
- " -0.175369 \n",
- " 0.175369 \n",
- " 0.598943 \n",
- " True \n",
- " False \n",
- " True \n",
- " True \n",
- " 0.515625 \n",
- " \n",
- " \n",
- " 2379 \n",
- " 1 \n",
- " 5944 \n",
- " 1 \n",
- " <|system|>You are about to immerse yourself in... \n",
- " True \n",
- " <|endoftext|><|endoftext|><|endoftext|><|endof... \n",
- " [0.28807038, 0.49657252] \n",
- " 0.632856 \n",
- " [0.42382222, 0.3274443] \n",
- " 0.435851 \n",
- " True \n",
- " False \n",
- " -0.197006 \n",
- " 0.197006 \n",
- " 0.534353 \n",
- " True \n",
- " False \n",
- " False \n",
- " False \n",
- " 0.404297 \n",
- " \n",
- " \n",
- " 2380 \n",
- " 1 \n",
- " 5945 \n",
- " 0 \n",
- " <|system|>You are about to immerse yourself in... \n",
- " True \n",
- " <|endoftext|><|endoftext|><|endoftext|><|endof... \n",
- " [0.12029998, 0.52055067] \n",
- " 0.812268 \n",
- " [0.3457057, 0.60893726] \n",
- " 0.637862 \n",
- " True \n",
- " True \n",
- " -0.174406 \n",
- " 0.174406 \n",
- " 0.725065 \n",
- " True \n",
- " True \n",
- " False \n",
- " False \n",
- " 0.478027 \n",
- " \n",
- " \n",
- " 2381 \n",
- " 0 \n",
- " 5947 \n",
- " 0 \n",
- " <|system|>You are about to immerse yourself in... \n",
- " True \n",
- " <|endoftext|><|endoftext|><|endoftext|><|endof... \n",
- " [0.47331956, 0.34063554] \n",
- " 0.418489 \n",
- " [0.26450822, 0.4396259] \n",
- " 0.624341 \n",
- " False \n",
- " True \n",
- " 0.205852 \n",
- " 0.205852 \n",
- " 0.521415 \n",
- " True \n",
- " True \n",
- " False \n",
- " False \n",
- " 0.462891 \n",
- " \n",
- " \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " ... \n",
- " \n",
- " \n",
- " 3165 \n",
- " 0 \n",
- " 7985 \n",
- " 0 \n",
- " <|system|>You are about to immerse yourself in... \n",
- " True \n",
- " <|endoftext|><|endoftext|><|endoftext|><|endof... \n",
- " [0.4293921, 0.33180988] \n",
- " 0.435897 \n",
- " [0.48672205, 0.20352039] \n",
- " 0.294849 \n",
- " False \n",
- " False \n",
- " -0.141048 \n",
- " 0.141048 \n",
- " 0.365373 \n",
- " False \n",
- " True \n",
- " True \n",
- " False \n",
- " 0.479492 \n",
- " \n",
- " \n",
- " 3166 \n",
- " 1 \n",
- " 7988 \n",
- " 1 \n",
- " <|system|>You are about to immerse yourself in... \n",
- " True \n",
- " <|endoftext|><|endoftext|><|endoftext|><|endof... \n",
- " [0.4677862, 0.33066] \n",
- " 0.414124 \n",
- " [0.20927021, 0.47021544] \n",
- " 0.692007 \n",
- " False \n",
- " True \n",
- " 0.277882 \n",
- " 0.277882 \n",
- " 0.553065 \n",
- " True \n",
- " False \n",
- " True \n",
- " True \n",
- " 0.587891 \n",
- " \n",
- " \n",
- " 3167 \n",
- " 1 \n",
- " 7996 \n",
- " 1 \n",
- " <|system|>You are about to immerse yourself in... \n",
- " True \n",
- " determined if you are the lying Guard or the ... \n",
- " [0.18918358, 0.28532732] \n",
- " 0.601296 \n",
- " [0.4284532, 0.30026284] \n",
- " 0.412038 \n",
- " False \n",
- " False \n",
- " -0.189258 \n",
- " 0.189258 \n",
- " 0.506667 \n",
- " True \n",
- " False \n",
- " False \n",
- " False \n",
- " 0.426758 \n",
- " \n",
- " \n",
- " 3168 \n",
- " 0 \n",
- " 7998 \n",
- " 1 \n",
- " <|system|>You are about to immerse yourself in... \n",
- " True \n",
- " <|endoftext|><|endoftext|><|endoftext|><|endof... \n",
- " [0.24055526, 0.41276416] \n",
- " 0.631786 \n",
- " [0.35980803, 0.38881692] \n",
- " 0.519368 \n",
- " True \n",
- " True \n",
- " -0.112418 \n",
- " 0.112418 \n",
- " 0.575577 \n",
- " True \n",
- " False \n",
- " True \n",
- " True \n",
- " 0.567383 \n",
- " \n",
- " \n",
- " 3169 \n",
- " 1 \n",
- " 7999 \n",
- " 1 \n",
- " <|system|>You are about to immerse yourself in... \n",
- " True \n",
- " <|endoftext|><|endoftext|><|endoftext|><|endof... \n",
- " [0.5347394, 0.29575846] \n",
- " 0.356118 \n",
- " [0.41391683, 0.46787095] \n",
- " 0.530588 \n",
- " False \n",
- " True \n",
- " 0.174470 \n",
- " 0.174470 \n",
- " 0.443353 \n",
- " False \n",
- " False \n",
- " True \n",
- " False \n",
- " 0.480469 \n",
- " \n",
- " \n",
- "
\n",
- "
793 rows × 20 columns
\n",
- "
"
- ],
- "text/plain": [
- " true index label prompt \n",
- "2377 0 5941 1 <|system|>You are about to immerse yourself in... \\\n",
- "2378 0 5942 1 <|system|>You are about to immerse yourself in... \n",
- "2379 1 5944 1 <|system|>You are about to immerse yourself in... \n",
- "2380 1 5945 0 <|system|>You are about to immerse yourself in... \n",
- "2381 0 5947 0 <|system|>You are about to immerse yourself in... \n",
- "... ... ... ... ... \n",
- "3165 0 7985 0 <|system|>You are about to immerse yourself in... \n",
- "3166 1 7988 1 <|system|>You are about to immerse yourself in... \n",
- "3167 1 7996 1 <|system|>You are about to immerse yourself in... \n",
- "3168 0 7998 1 <|system|>You are about to immerse yourself in... \n",
- "3169 1 7999 1 <|system|>You are about to immerse yourself in... \n",
- "\n",
- " lie prompt_truncated \n",
- "2377 True <|endoftext|><|endoftext|><|endoftext|><|endof... \\\n",
- "2378 True <|endoftext|><|endoftext|><|endoftext|><|endof... \n",
- "2379 True <|endoftext|><|endoftext|><|endoftext|><|endof... \n",
- "2380 True <|endoftext|><|endoftext|><|endoftext|><|endof... \n",
- "2381 True <|endoftext|><|endoftext|><|endoftext|><|endof... \n",
- "... ... ... \n",
- "3165 True <|endoftext|><|endoftext|><|endoftext|><|endof... \n",
- "3166 True <|endoftext|><|endoftext|><|endoftext|><|endof... \n",
- "3167 True determined if you are the lying Guard or the ... \n",
- "3168 True <|endoftext|><|endoftext|><|endoftext|><|endof... \n",
- "3169 True <|endoftext|><|endoftext|><|endoftext|><|endof... \n",
- "\n",
- " choice_probs0 ans0 choice_probs1 ans1 \n",
- "2377 [0.39532927, 0.3094553] 0.439072 [0.40214014, 0.18818313] 0.318774 \\\n",
- "2378 [0.27720308, 0.60739946] 0.686628 [0.44869244, 0.46937478] 0.511258 \n",
- "2379 [0.28807038, 0.49657252] 0.632856 [0.42382222, 0.3274443] 0.435851 \n",
- "2380 [0.12029998, 0.52055067] 0.812268 [0.3457057, 0.60893726] 0.637862 \n",
- "2381 [0.47331956, 0.34063554] 0.418489 [0.26450822, 0.4396259] 0.624341 \n",
- "... ... ... ... ... \n",
- "3165 [0.4293921, 0.33180988] 0.435897 [0.48672205, 0.20352039] 0.294849 \n",
- "3166 [0.4677862, 0.33066] 0.414124 [0.20927021, 0.47021544] 0.692007 \n",
- "3167 [0.18918358, 0.28532732] 0.601296 [0.4284532, 0.30026284] 0.412038 \n",
- "3168 [0.24055526, 0.41276416] 0.631786 [0.35980803, 0.38881692] 0.519368 \n",
- "3169 [0.5347394, 0.29575846] 0.356118 [0.41391683, 0.46787095] 0.530588 \n",
- "\n",
- " txt_ans0 txt_ans1 dir_true conf llm_prob llm_ans desired_ans \n",
- "2377 False False -0.120297 0.120297 0.378923 False False \\\n",
- "2378 True True -0.175369 0.175369 0.598943 True False \n",
- "2379 True False -0.197006 0.197006 0.534353 True False \n",
- "2380 True True -0.174406 0.174406 0.725065 True True \n",
- "2381 False True 0.205852 0.205852 0.521415 True True \n",
- "... ... ... ... ... ... ... ... \n",
- "3165 False False -0.141048 0.141048 0.365373 False True \n",
- "3166 False True 0.277882 0.277882 0.553065 True False \n",
- "3167 False False -0.189258 0.189258 0.506667 True False \n",
- "3168 True True -0.112418 0.112418 0.575577 True False \n",
- "3169 False True 0.174470 0.174470 0.443353 False False \n",
- "\n",
- " y probe_pred probe_prob \n",
- "2377 True True 0.577148 \n",
- "2378 True True 0.515625 \n",
- "2379 False False 0.404297 \n",
- "2380 False False 0.478027 \n",
- "2381 False False 0.462891 \n",
- "... ... ... ... \n",
- "3165 True False 0.479492 \n",
- "3166 True True 0.587891 \n",
- "3167 False False 0.426758 \n",
- "3168 True True 0.567383 \n",
- "3169 True False 0.480469 \n",
- "\n",
- "[793 rows x 20 columns]"
- ]
- },
- "execution_count": 73,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"# Make a prediction dataframe with everything in it\n",
"df_test = dm.df.iloc[dm.splits['test'][0]:].copy()\n",
@@ -2861,33 +697,9 @@
},
{
"cell_type": "code",
- "execution_count": 74,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "probe results on subsets of the data\n",
- "acc=87.89% [lie==True]\n",
- "acc=nan% [lie==False]\n",
- "acc=87.53% [llm_ans==label]\n",
- "acc=88.33% [llm_ans==desired_ans]\n",
- "acc=88.33% [lie==True & llm_ans==desired_ans]\n",
- "acc=87.53% [lie==True & llm_ans!=desired_ans]\n"
- ]
- },
- {
- "data": {
- "text/plain": [
- "0.8752886836027713"
- ]
- },
- "execution_count": 74,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"def get_acc_subset(df, query):\n",
" df_s = df.query(query)\n",
@@ -2913,17 +725,9 @@
},
{
"cell_type": "code",
- "execution_count": 85,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "⭐PRIMARY METRIC⭐ acc=87.89% from probe\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"acc = (df_test['y']==(y_test_pred_bool>0.5)).mean()\n",
"\n",
diff --git a/notebooks/03_make_dataset.ipynb b/notebooks/03_make_dataset.ipynb
index 5e6ed9a..c4c80ef 100644
--- a/notebooks/03_make_dataset.ipynb
+++ b/notebooks/03_make_dataset.ipynb
@@ -11,7 +11,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -32,9 +32,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'4.30.1'"
+ ]
+ },
+ "execution_count": 2,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"import numpy as np\n",
"\n",
@@ -62,7 +73,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
@@ -84,7 +95,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
@@ -97,7 +108,7 @@
"dataset_params = dict(\n",
" model_repo=\"HuggingFaceH4/starchat-beta\",\n",
" dataset_name = \"amazon_polarity\",\n",
- " N = 509, # 8000 # 4000 in 4 hours\n",
+ " N = 9009, # 8000 # 4000 in 4 hours\n",
" N_SHOTS = 2,\n",
" prompt_fmt=format_guard_prompt,\n",
" choices=default_class2choices,\n",
@@ -131,7 +142,7 @@
},
{
"cell_type": "code",
- "execution_count": 30,
+ "execution_count": 5,
"metadata": {},
"outputs": [
{
@@ -140,139 +151,102 @@
"text": [
"\u001b[1mchanging pad_token_id from None to 0\u001b[0m\n",
"\u001b[1mchanging padding_side from right to left\u001b[0m\n",
- "\u001b[1mchanging truncation_side from right to left\u001b[0m\n"
+ "\u001b[1mchanging truncation_side from right to left\u001b[0m\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'), 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",
+ "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"
+ ]
+ },
+ {
+ "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 /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: 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"
]
},
{
"data": {
- "text/html": [
- "╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ \n",
- "│ in <module> :1 │ \n",
- "│ │ \n",
- "│ ❱ 1 model, tokenizer = load_model(model_repo=dataset_params['model_repo' ]) │ \n",
- "│ 2 │ \n",
- "│ │ \n",
- "│ /home/ubuntu/Documents/mjc/elk/discovering_latent_knowledge/src/models/ load.py :23 in load_model │ \n",
- "│ │ \n",
- "│ 20 │ \n",
- "│ 21 def load_model (model_repo = \"HuggingFaceH4/starchat-beta\" , lora_repo=None , verbose=True ) │ \n",
- "│ 22 │ if \"starchat\" in model_repo: │ \n",
- "│ ❱ 23 │ │ model, tokenizer = load_starchat(model_repo=model_repo) │ \n",
- "│ 24 │ # elif \"llama\" in model_repo: │ \n",
- "│ 25 │ # model, tokenizer = load_llama(model_repo=model_repo, lora_repo=lora_repo) │ \n",
- "│ 26 │ else : │ \n",
- "│ │ \n",
- "│ /home/ubuntu/Documents/mjc/elk/discovering_latent_knowledge/src/models/ load.py :51 in │ \n",
- "│ load_starchat │ \n",
- "│ │ \n",
- "│ 48 │ verbose_change_param(tokenizer, 'padding_side' , 'left' ) │ \n",
- "│ 49 │ verbose_change_param(tokenizer, 'truncation_side' , 'left' ) │ \n",
- "│ 50 │ │ \n",
- "│ ❱ 51 │ model = AutoModelForCausalLM.from_pretrained(model_repo, config=config, **model_opti │ \n",
- "│ 52 │ │ \n",
- "│ 53 │ return model, tokenizer │ \n",
- "│ 54 │ \n",
- "│ │ \n",
- "│ /home/ubuntu/mambaforge/envs/dlk2/lib/python3.9/site-packages/transformers/models/auto/ auto_fact │ \n",
- "│ ory.py :484 in from_pretrained │ \n",
- "│ │ \n",
- "│ 481 │ │ │ ) │ \n",
- "│ 482 │ │ elif type (config) in cls ._model_mapping.keys(): │ \n",
- "│ 483 │ │ │ model_class = _get_model_class(config, cls ._model_mapping) │ \n",
- "│ ❱ 484 │ │ │ return model_class.from_pretrained( │ \n",
- "│ 485 │ │ │ │ pretrained_model_name_or_path, *model_args, config=config, **hub_kwargs, │ \n",
- "│ 486 │ │ │ ) │ \n",
- "│ 487 │ │ raise ValueError ( │ \n",
- "│ │ \n",
- "│ /home/ubuntu/mambaforge/envs/dlk2/lib/python3.9/site-packages/transformers/ modeling_utils.py :281 │ \n",
- "│ 9 in from_pretrained │ \n",
- "│ │ \n",
- "│ 2816 │ │ │ │ │ key: device_map[key] for key in device_map.keys() if key not in modu │ \n",
- "│ 2817 │ │ │ │ } │ \n",
- "│ 2818 │ │ │ │ if \"cpu\" in device_map_without_lm_head.values() or \"disk\" in device_map_ │ \n",
- "│ ❱ 2819 │ │ │ │ │ raise ValueError ( │ \n",
- "│ 2820 │ │ │ │ │ │ \"\"\" │ \n",
- "│ 2821 │ │ │ │ │ │ Some modules are dispatched on the CPU or the disk. Make sure yo │ \n",
- "│ 2822 │ │ │ │ │ │ the quantized model. If you want to dispatch the model on the CP │ \n",
- "╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ \n",
- "ValueError: \n",
- " Some modules are dispatched on the CPU or the disk. Make sure you have enough GPU RAM to \n",
- "fit\n",
- " the quantized model. If you want to dispatch the model on the CPU or the disk while keeping\n",
- " these modules in 32 -bit, you need to set `load_in_8bit_fp32_cpu_offload =True ` and pass a \n",
- "custom\n",
- " `device_map` to `from_pretrained`. Check\n",
- " https://huggingface.co/docs/transformers/main/en/main_classes/quantization#offload-between- \n",
- "cpu-and-gpu \n",
- " for more details.\n",
- " \n",
- " \n"
- ],
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "0c4350e56b7846fba9c6725c33de2d76",
+ "version_major": 2,
+ "version_minor": 0
+ },
"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\u001b[0m:\u001b[94m1\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m1 model, tokenizer = load_model(model_repo=dataset_params[\u001b[33m'\u001b[0m\u001b[33mmodel_repo\u001b[0m\u001b[33m'\u001b[0m]) \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m2 \u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2;33m/home/ubuntu/Documents/mjc/elk/discovering_latent_knowledge/src/models/\u001b[0m\u001b[1;33mload.py\u001b[0m:\u001b[94m23\u001b[0m in \u001b[92mload_model\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m20 \u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m21 \u001b[0m\u001b[94mdef\u001b[0m \u001b[92mload_model\u001b[0m(model_repo = \u001b[33m\"\u001b[0m\u001b[33mHuggingFaceH4/starchat-beta\u001b[0m\u001b[33m\"\u001b[0m, lora_repo=\u001b[94mNone\u001b[0m, verbose=\u001b[94mTrue\u001b[0m) \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m22 \u001b[0m\u001b[2m│ \u001b[0m\u001b[94mif\u001b[0m \u001b[33m\"\u001b[0m\u001b[33mstarchat\u001b[0m\u001b[33m\"\u001b[0m \u001b[95min\u001b[0m model_repo: \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m23 \u001b[2m│ │ \u001b[0mmodel, tokenizer = load_starchat(model_repo=model_repo) \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m24 \u001b[0m\u001b[2m│ \u001b[0m\u001b[2m# elif \"llama\" in model_repo:\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m25 \u001b[0m\u001b[2m│ \u001b[0m\u001b[2m# model, tokenizer = load_llama(model_repo=model_repo, lora_repo=lora_repo)\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m26 \u001b[0m\u001b[2m│ \u001b[0m\u001b[94melse\u001b[0m: \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2;33m/home/ubuntu/Documents/mjc/elk/discovering_latent_knowledge/src/models/\u001b[0m\u001b[1;33mload.py\u001b[0m:\u001b[94m51\u001b[0m in \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[92mload_starchat\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m48 \u001b[0m\u001b[2m│ \u001b[0mverbose_change_param(tokenizer, \u001b[33m'\u001b[0m\u001b[33mpadding_side\u001b[0m\u001b[33m'\u001b[0m, \u001b[33m'\u001b[0m\u001b[33mleft\u001b[0m\u001b[33m'\u001b[0m) \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m49 \u001b[0m\u001b[2m│ \u001b[0mverbose_change_param(tokenizer, \u001b[33m'\u001b[0m\u001b[33mtruncation_side\u001b[0m\u001b[33m'\u001b[0m, \u001b[33m'\u001b[0m\u001b[33mleft\u001b[0m\u001b[33m'\u001b[0m) \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m50 \u001b[0m\u001b[2m│ \u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m51 \u001b[2m│ \u001b[0mmodel = AutoModelForCausalLM.from_pretrained(model_repo, config=config, **model_opti \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m52 \u001b[0m\u001b[2m│ \u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m53 \u001b[0m\u001b[2m│ \u001b[0m\u001b[94mreturn\u001b[0m model, tokenizer \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m54 \u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2;33m/home/ubuntu/mambaforge/envs/dlk2/lib/python3.9/site-packages/transformers/models/auto/\u001b[0m\u001b[1;33mauto_fact\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[1;33mory.py\u001b[0m:\u001b[94m484\u001b[0m in \u001b[92mfrom_pretrained\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m481 \u001b[0m\u001b[2m│ │ │ \u001b[0m) \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m482 \u001b[0m\u001b[2m│ │ \u001b[0m\u001b[94melif\u001b[0m \u001b[96mtype\u001b[0m(config) \u001b[95min\u001b[0m \u001b[96mcls\u001b[0m._model_mapping.keys(): \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m483 \u001b[0m\u001b[2m│ │ │ \u001b[0mmodel_class = _get_model_class(config, \u001b[96mcls\u001b[0m._model_mapping) \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m484 \u001b[2m│ │ │ \u001b[0m\u001b[94mreturn\u001b[0m model_class.from_pretrained( \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m485 \u001b[0m\u001b[2m│ │ │ │ \u001b[0mpretrained_model_name_or_path, *model_args, config=config, **hub_kwargs, \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m486 \u001b[0m\u001b[2m│ │ │ \u001b[0m) \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m487 \u001b[0m\u001b[2m│ │ \u001b[0m\u001b[94mraise\u001b[0m \u001b[96mValueError\u001b[0m( \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2;33m/home/ubuntu/mambaforge/envs/dlk2/lib/python3.9/site-packages/transformers/\u001b[0m\u001b[1;33mmodeling_utils.py\u001b[0m:\u001b[94m281\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[94m9\u001b[0m in \u001b[92mfrom_pretrained\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m2816 \u001b[0m\u001b[2m│ │ │ │ │ \u001b[0mkey: device_map[key] \u001b[94mfor\u001b[0m key \u001b[95min\u001b[0m device_map.keys() \u001b[94mif\u001b[0m key \u001b[95mnot\u001b[0m \u001b[95min\u001b[0m modu \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m2817 \u001b[0m\u001b[2m│ │ │ │ \u001b[0m} \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m2818 \u001b[0m\u001b[2m│ │ │ │ \u001b[0m\u001b[94mif\u001b[0m \u001b[33m\"\u001b[0m\u001b[33mcpu\u001b[0m\u001b[33m\"\u001b[0m \u001b[95min\u001b[0m device_map_without_lm_head.values() \u001b[95mor\u001b[0m \u001b[33m\"\u001b[0m\u001b[33mdisk\u001b[0m\u001b[33m\"\u001b[0m \u001b[95min\u001b[0m device_map_ \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m2819 \u001b[2m│ │ │ │ │ \u001b[0m\u001b[94mraise\u001b[0m \u001b[96mValueError\u001b[0m( \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m2820 \u001b[0m\u001b[2;90m│ │ │ │ │ │ \u001b[0m\u001b[33m\"\"\"\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m2821 \u001b[0m\u001b[2;33m│ │ │ │ │ │ \u001b[0m\u001b[33mSome modules are dispatched on the CPU or the disk. Make sure yo\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m│\u001b[0m \u001b[2m2822 \u001b[0m\u001b[2;33m│ │ │ │ │ │ \u001b[0m\u001b[33mthe quantized model. If you want to dispatch the model on the CP\u001b[0m \u001b[31m│\u001b[0m\n",
- "\u001b[31m╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n",
- "\u001b[1;91mValueError: \u001b[0m\n",
- " Some modules are dispatched on the CPU or the disk. Make sure you have enough GPU RAM to \n",
- "fit\n",
- " the quantized model. If you want to dispatch the model on the CPU or the disk while keeping\n",
- " these modules in \u001b[1;36m32\u001b[0m-bit, you need to set `\u001b[33mload_in_8bit_fp32_cpu_offload\u001b[0m=\u001b[3;92mTrue\u001b[0m` and pass a \n",
- "custom\n",
- " `device_map` to `from_pretrained`. Check\n",
- " \u001b[4;94mhttps://huggingface.co/docs/transformers/main/en/main_classes/quantization#offload-between-\u001b[0m\n",
- "\u001b[4;94mcpu-and-gpu\u001b[0m\n",
- " for more details.\n",
- " \n"
+ "Loading checkpoint shards: 0%| | 0/4 [00:00, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "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",
+ "\n"
+ ]
}
],
"source": [
@@ -289,7 +263,7 @@
},
{
"cell_type": "code",
- "execution_count": 31,
+ "execution_count": 6,
"metadata": {},
"outputs": [
{
@@ -302,7 +276,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "6ee109e341e5461b8d62bc59f2dc64b3",
+ "model_id": "81ee1347db5d4e18b62056c580cf1441",
"version_major": 2,
"version_minor": 0
},
@@ -328,7 +302,7 @@
"})"
]
},
- "execution_count": 31,
+ "execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
@@ -353,7 +327,7 @@
},
{
"cell_type": "code",
- "execution_count": 32,
+ "execution_count": 7,
"metadata": {},
"outputs": [
{
@@ -384,7 +358,7 @@
},
{
"cell_type": "code",
- "execution_count": 33,
+ "execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@@ -414,31 +388,64 @@
},
{
"cell_type": "code",
- "execution_count": 34,
+ "execution_count": 9,
"metadata": {
"notebookRunGroups": {
"groupValue": ""
}
},
"outputs": [
- {
- "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-88dc9f1fd8b901a8.arrow\n",
- "Loading cached processed dataset at /home/ubuntu/.cache/huggingface/datasets/amazon_polarity/amazon_polarity/3.0.0/a27b32b7e7b88eb274a8fa8ba0f654f1fe998a87c22547557317793b5d2772dc/cache-e752326d3340220d.arrow\n",
- "Loading cached processed dataset at /home/ubuntu/.cache/huggingface/datasets/amazon_polarity/amazon_polarity/3.0.0/a27b32b7e7b88eb274a8fa8ba0f654f1fe998a87c22547557317793b5d2772dc/cache-7cb61ae701a89a12.arrow\n"
- ]
- },
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "4550272988a24d68bc8b9376a0c81fe7",
+ "model_id": "42428c7a72b54c5385bc45a9c3af6a63",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
- "Map: 0%| | 0/509 [00:00, ? examples/s]"
+ "Map: 0%| | 0/9009 [00:00, ? examples/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "38298c2818a34f1b83efeaf4830421d3",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Map: 0%| | 0/9009 [00:00, ? examples/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "af83348bd74b4afabe5ede373c533fff",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Map: 0%| | 0/9009 [00:00, ? examples/s]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "fdb75381552440e587c9f9ae15166938",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Map: 0%| | 0/9009 [00:00, ? examples/s]"
]
},
"metadata": {},
@@ -449,11 +456,11 @@
"text/plain": [
"Dataset({\n",
" features: ['label', 'title', 'content', 'text', 'prompt', 'lie', 'input_ids', 'attention_mask', 'prompt_truncated'],\n",
- " num_rows: 509\n",
+ " num_rows: 9009\n",
"})"
]
},
- "execution_count": 34,
+ "execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
@@ -491,14 +498,14 @@
},
{
"cell_type": "code",
- "execution_count": 35,
+ "execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "../.ds/model-starchat-beta_ds-amazon-polarity_format-guard-prompt_N509_2shots_5c2070\n"
+ "../.ds/model-starchat-beta_ds-amazon-polarity_format-guard-prompt_N9009_2shots_d6813d\n"
]
}
],
@@ -513,7 +520,7 @@
},
{
"cell_type": "code",
- "execution_count": 36,
+ "execution_count": 11,
"metadata": {},
"outputs": [
{
@@ -549,13 +556,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: 509\n",
+ " num_rows: 9009\n",
" }),\n",
- " 'n': 509,\n",
+ " 'n': 9009,\n",
" 'batch_size': 10}"
]
},
- "execution_count": 36,
+ "execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
@@ -573,20 +580,20 @@
},
{
"cell_type": "code",
- "execution_count": 37,
+ "execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "Downloading and preparing dataset None/../.ds/model-starchat-beta_ds-amazon-polarity_format-guard-prompt_N509_2shots_5c2070 to /home/ubuntu/.cache/huggingface/datasets/generator/default-f46bbb923bbf3943/0.0.0...\n"
+ "Downloading and preparing dataset None/../.ds/model-starchat-beta_ds-amazon-polarity_format-guard-prompt_N9009_2shots_d6813d to /home/ubuntu/.cache/huggingface/datasets/generator/default-4cd9d3e07734db42/0.0.0...\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "6aa11b88940248c199146d73079893d5",
+ "model_id": "8f625b953205443fbf9388fd506528f3",
"version_major": 2,
"version_minor": 0
},
@@ -600,12 +607,12 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "f4dd1c7bebb84bb6998442b6e821df80",
+ "model_id": "e9d293506403423cb671cf4e98ad38e1",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
- "get hidden states: 0%| | 0/51 [00:00, ?it/s]"
+ "get hidden states: 0%| | 0/901 [00:00, ?it/s]"
]
},
"metadata": {},
@@ -761,7 +768,7 @@
"source": [
"# QC by viewing a row\n",
"r = ds4[0]\n",
- "print(r['prompt_truncated'][0])\n",
+ "print(r['prompt_truncated'])\n",
"print(r['txt_ans1'])"
]
},
@@ -834,25 +841,17 @@
"metadata": {},
"outputs": [],
"source": [
- "true_switch_sign = ds4['label'][:, 0]*2-1\n",
- "true_switch_sign = ds4['true'][:, 0]*2-1\n",
+ "true_switch_sign = ds4['label']*2-1\n",
+ "# true_switch_sign = ds4['true'][:, 0]*2-1\n",
"y = ((ds4['ans1'] - ds4['ans0']) * true_switch_sign) > 0"
]
},
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
- "# n = len(df)\n",
"from sklearn.preprocessing import RobustScaler\n",
"from sklearn.linear_model import LogisticRegression\n",
"from sklearn.metrics import f1_score, roc_auc_score, accuracy_score\n",
diff --git a/src/datasets/load.py b/src/datasets/load.py
index 4eced09..b155b9a 100644
--- a/src/datasets/load.py
+++ b/src/datasets/load.py
@@ -20,7 +20,7 @@ def ds2df(ds, cols=None):
if cols is None:
r = ds[0]
# get all the columns that not large lists or arrays
- cols = [k for k,v in r.items() if (isinstance(v, np.ndarray) and len(v)<3) or not isinstance(v, (list, np.ndarray))]
+ cols = [k for k,v in r.items() if (isinstance(v, np.ndarray) and v.size<3) or not isinstance(v, (list, np.ndarray))]
df = ds.select_columns(cols)
df = pd.DataFrame([rows_item(r) for r in df])