Spaces:
Build error
Build error
use LFS for notebooks
Browse files- .gitattributes +24 -0
- data/anthropic_metrics.csv +1 -1
- llm_toolkit/logical_reasoning_utils.py +14 -14
- notebooks/00_Data Analysis.ipynb +0 -0
- notebooks/01a_internlm2_5-20b-chat_analysis.ipynb +0 -0
- notebooks/01a_internlm2_5-7b-chat-1m_analysis.ipynb +0 -0
- notebooks/01a_internlm2_5-7b-chat_analysis.ipynb +0 -0
- notebooks/01b_Mistral-7B-v0.3-Chinese-Chat_analysis.ipynb +0 -0
- notebooks/02a_Qwen2-7B-Instruct_analysis.ipynb +0 -0
- notebooks/02b_Qwen2-72B-Instruct_analysis.ipynb +0 -0
- notebooks/02c_Qwen2.5-3B-Instruct_analysis.ipynb +0 -0
- notebooks/02d_Qwen2.5-7B-Instruct_analysis.ipynb +0 -0
- notebooks/02e_Qwen2.5-1.5B-Instruct_analysis.ipynb +0 -0
- notebooks/02f_Qwen2.5-0.5B-Instruct_analysis.ipynb +0 -0
- notebooks/02g_Qwen2.5-72B-Instruct_analysis.ipynb +0 -0
- notebooks/03a_Llama3.1-8B-Chinese-Chat_analysis.ipynb +0 -0
- notebooks/03b_Llama3.1-70B-Chinese-Chat_analysis.ipynb +0 -0
- notebooks/04_Few-shot_Prompting_OpenAI.ipynb +0 -0
- notebooks/04b_OpenAI-Models_analysis.ipynb +0 -0
- notebooks/04c_OpenAI-o1.ipynb +0 -0
- notebooks/04d_OpenAI-batch.ipynb +3 -1
- notebooks/04e_OpenAI_o1_vs_gpt_4o.ipynb +3 -573
- notebooks/05_Few-shot_Prompting_Anthropic.ipynb +0 -0
- notebooks/05b_Anthropic-Models_analysis.ipynb +0 -0
- notebooks/06_Few-shot_Prompting_Open_Source.ipynb +0 -0
- notebooks/06b_Open-Source-Models_analysis.ipynb +0 -0
- notebooks/07_Qwen2.5_models.ipynb +0 -0
.gitattributes
CHANGED
@@ -113,3 +113,27 @@ datasets/mgtv/o1-mini.jsonl filter=lfs diff=lfs merge=lfs -text
|
|
113 |
datasets/mgtv/Icon
|
114 |
filter=lfs diff=lfs merge=lfs -text
|
115 |
datasets/mgtv/gpt-4o-mini.jsonl filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
datasets/mgtv/Icon
|
114 |
filter=lfs diff=lfs merge=lfs -text
|
115 |
datasets/mgtv/gpt-4o-mini.jsonl filter=lfs diff=lfs merge=lfs -text
|
116 |
+
notebooks/04d_OpenAI-batch.ipynb filter=lfs diff=lfs merge=lfs -text
|
117 |
+
notebooks/01b_Mistral-7B-v0.3-Chinese-Chat_analysis.ipynb filter=lfs diff=lfs merge=lfs -text
|
118 |
+
notebooks/02e_Qwen2.5-1.5B-Instruct_analysis.ipynb filter=lfs diff=lfs merge=lfs -text
|
119 |
+
notebooks/02g_Qwen2.5-72B-Instruct_analysis.ipynb filter=lfs diff=lfs merge=lfs -text
|
120 |
+
notebooks/03b_Llama3.1-70B-Chinese-Chat_analysis.ipynb filter=lfs diff=lfs merge=lfs -text
|
121 |
+
notebooks/04_Few-shot_Prompting_OpenAI.ipynb filter=lfs diff=lfs merge=lfs -text
|
122 |
+
notebooks/04b_OpenAI-Models_analysis.ipynb filter=lfs diff=lfs merge=lfs -text
|
123 |
+
notebooks/04c_OpenAI-o1.ipynb filter=lfs diff=lfs merge=lfs -text
|
124 |
+
notebooks/05_Few-shot_Prompting_Anthropic.ipynb filter=lfs diff=lfs merge=lfs -text
|
125 |
+
notebooks/01a_internlm2_5-7b-chat_analysis.ipynb filter=lfs diff=lfs merge=lfs -text
|
126 |
+
notebooks/02d_Qwen2.5-7B-Instruct_analysis.ipynb filter=lfs diff=lfs merge=lfs -text
|
127 |
+
notebooks/02f_Qwen2.5-0.5B-Instruct_analysis.ipynb filter=lfs diff=lfs merge=lfs -text
|
128 |
+
notebooks/06b_Open-Source-Models_analysis.ipynb filter=lfs diff=lfs merge=lfs -text
|
129 |
+
notebooks/01a_internlm2_5-20b-chat_analysis.ipynb filter=lfs diff=lfs merge=lfs -text
|
130 |
+
notebooks/01a_internlm2_5-7b-chat-1m_analysis.ipynb filter=lfs diff=lfs merge=lfs -text
|
131 |
+
notebooks/07_Qwen2.5_models.ipynb filter=lfs diff=lfs merge=lfs -text
|
132 |
+
notebooks/06_Few-shot_Prompting_Open_Source.ipynb filter=lfs diff=lfs merge=lfs -text
|
133 |
+
notebooks/00_Data[[:space:]]Analysis.ipynb filter=lfs diff=lfs merge=lfs -text
|
134 |
+
notebooks/02a_Qwen2-7B-Instruct_analysis.ipynb filter=lfs diff=lfs merge=lfs -text
|
135 |
+
notebooks/02b_Qwen2-72B-Instruct_analysis.ipynb filter=lfs diff=lfs merge=lfs -text
|
136 |
+
notebooks/02c_Qwen2.5-3B-Instruct_analysis.ipynb filter=lfs diff=lfs merge=lfs -text
|
137 |
+
notebooks/03a_Llama3.1-8B-Chinese-Chat_analysis.ipynb filter=lfs diff=lfs merge=lfs -text
|
138 |
+
notebooks/04e_OpenAI_o1_vs_gpt_4o.ipynb filter=lfs diff=lfs merge=lfs -text
|
139 |
+
notebooks/05b_Anthropic-Models_analysis.ipynb filter=lfs diff=lfs merge=lfs -text
|
data/anthropic_metrics.csv
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
shots,model,run,accuracy,precision,recall,f1,ratio_valid_classifications
|
2 |
-
0,claude-3-5-sonnet-20240620,claude-3-5-sonnet-20240620/shots-00,0.
|
|
|
1 |
shots,model,run,accuracy,precision,recall,f1,ratio_valid_classifications
|
2 |
+
0,claude-3-5-sonnet-20240620,claude-3-5-sonnet-20240620/shots-00,0.7116666666666667,0.8000129744003537,0.7116666666666667,0.7416096558950286,1.0
|
llm_toolkit/logical_reasoning_utils.py
CHANGED
@@ -428,12 +428,12 @@ def load_alpaca_data(data_path, using_p1=True, use_english_datasets=False):
|
|
428 |
|
429 |
|
430 |
def plot_value_counts(df, column_name, offset=0.1, title=None, preprocess_func=None, debug=False):
|
431 |
-
|
432 |
-
#
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
if preprocess_func:
|
438 |
df["backup"] = df[column_name]
|
439 |
df[column_name] = df[column_name].apply(preprocess_func) if preprocess_func == extract_answer else df.apply(
|
@@ -456,7 +456,7 @@ def plot_value_counts(df, column_name, offset=0.1, title=None, preprocess_func=N
|
|
456 |
|
457 |
plt.show()
|
458 |
|
459 |
-
|
460 |
|
461 |
if preprocess_func:
|
462 |
plot_confusion_matrix(df["label"], df[column_name])
|
@@ -631,12 +631,12 @@ def eval_openai(
|
|
631 |
|
632 |
|
633 |
def plot_confusion_matrix(y_true, y_pred, title="Confusion Matrix"):
|
634 |
-
|
635 |
-
#
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
|
641 |
labels = np.unique(y_true)
|
642 |
y_pred = [extract_answer(text) for text in y_pred]
|
@@ -660,7 +660,7 @@ def plot_confusion_matrix(y_true, y_pred, title="Confusion Matrix"):
|
|
660 |
ax.set_ylabel("True labels")
|
661 |
plt.show()
|
662 |
|
663 |
-
|
664 |
|
665 |
|
666 |
def majority_vote(r1, r2, r3):
|
|
|
428 |
|
429 |
|
430 |
def plot_value_counts(df, column_name, offset=0.1, title=None, preprocess_func=None, debug=False):
|
431 |
+
font_family = rcParams["font.family"]
|
432 |
+
# Set the font to Songti SC to support Chinese characters
|
433 |
+
rcParams["font.family"] = "Songti SC"
|
434 |
+
rcParams["axes.unicode_minus"] = (
|
435 |
+
False # This is to support the minus sign in Chinese.
|
436 |
+
)
|
437 |
if preprocess_func:
|
438 |
df["backup"] = df[column_name]
|
439 |
df[column_name] = df[column_name].apply(preprocess_func) if preprocess_func == extract_answer else df.apply(
|
|
|
456 |
|
457 |
plt.show()
|
458 |
|
459 |
+
rcParams["font.family"] = font_family
|
460 |
|
461 |
if preprocess_func:
|
462 |
plot_confusion_matrix(df["label"], df[column_name])
|
|
|
631 |
|
632 |
|
633 |
def plot_confusion_matrix(y_true, y_pred, title="Confusion Matrix"):
|
634 |
+
font_family = rcParams["font.family"]
|
635 |
+
# Set the font to Songti SC to support Chinese characters
|
636 |
+
rcParams["font.family"] = "Songti SC"
|
637 |
+
rcParams["axes.unicode_minus"] = (
|
638 |
+
False # This is to support the minus sign in Chinese.
|
639 |
+
)
|
640 |
|
641 |
labels = np.unique(y_true)
|
642 |
y_pred = [extract_answer(text) for text in y_pred]
|
|
|
660 |
ax.set_ylabel("True labels")
|
661 |
plt.show()
|
662 |
|
663 |
+
rcParams["font.family"] = font_family
|
664 |
|
665 |
|
666 |
def majority_vote(r1, r2, r3):
|
notebooks/00_Data Analysis.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/01a_internlm2_5-20b-chat_analysis.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/01a_internlm2_5-7b-chat-1m_analysis.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/01a_internlm2_5-7b-chat_analysis.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/01b_Mistral-7B-v0.3-Chinese-Chat_analysis.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/02a_Qwen2-7B-Instruct_analysis.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/02b_Qwen2-72B-Instruct_analysis.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/02c_Qwen2.5-3B-Instruct_analysis.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/02d_Qwen2.5-7B-Instruct_analysis.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/02e_Qwen2.5-1.5B-Instruct_analysis.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/02f_Qwen2.5-0.5B-Instruct_analysis.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/02g_Qwen2.5-72B-Instruct_analysis.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/03a_Llama3.1-8B-Chinese-Chat_analysis.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/03b_Llama3.1-70B-Chinese-Chat_analysis.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/04_Few-shot_Prompting_OpenAI.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/04b_OpenAI-Models_analysis.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/04c_OpenAI-o1.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/04d_OpenAI-batch.ipynb
CHANGED
@@ -1 +1,3 @@
|
|
1 |
-
{"cells":[{"cell_type":"code","execution_count":1,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{},"inputWidgets":{},"nuid":"0ea8b46b-839b-445b-8043-ccdf4e920ace","showTitle":false,"title":""},"id":"YLH80COBzi_F"},"outputs":[],"source":["%load_ext autoreload\n","%autoreload 2"]},{"cell_type":"code","execution_count":2,"metadata":{"id":"63B5exAuzq4M"},"outputs":[],"source":["from pathlib import Path\n","\n","if \"workding_dir\" not in locals():\n"," try:\n"," from google.colab import drive\n"," drive.mount('/content/drive')\n"," workding_dir = \"/content/drive/MyDrive/logical-reasoning/\"\n"," except ModuleNotFoundError:\n"," workding_dir = str(Path.cwd().parent)"]},{"cell_type":"code","execution_count":3,"metadata":{"executionInfo":{"elapsed":368,"status":"ok","timestamp":1719461634865,"user":{"displayName":"Donghao Huang","userId":"00463591218503521679"},"user_tz":-480},"id":"zFulf0bg0H-9","outputId":"debdd535-c828-40b9-efc0-8a180e5830dd"},"outputs":[{"name":"stdout","output_type":"stream","text":["workding dir: /Users/inflaton/code/engd/projects/logical-reasoning\n"]}],"source":["import os\n","import sys\n","\n","os.chdir(workding_dir)\n","sys.path.append(workding_dir)\n","print(\"workding dir:\", workding_dir)"]},{"cell_type":"code","execution_count":4,"metadata":{"application/vnd.databricks.v1+cell":{"cellMetadata":{},"inputWidgets":{},"nuid":"9f67ec60-2f24-411c-84eb-0dd664b44775","showTitle":false,"title":""},"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":589,"status":"ok","timestamp":1719462011879,"user":{"displayName":"Donghao Huang","userId":"00463591218503521679"},"user_tz":-480},"id":"DIUiweYYzi_I","outputId":"e16e9247-9077-4b0c-f8ea-17059f05a1c4"},"outputs":[{"name":"stdout","output_type":"stream","text":["loading env vars from: /Users/inflaton/code/engd/projects/logical-reasoning/.env\n"]},{"data":{"text/plain":["True"]},"execution_count":4,"metadata":{},"output_type":"execute_result"}],"source":["from dotenv import find_dotenv, load_dotenv\n","\n","found_dotenv = find_dotenv(\".env\")\n","\n","if len(found_dotenv) == 0:\n"," found_dotenv = find_dotenv(\".env.example\")\n","print(f\"loading env vars from: {found_dotenv}\")\n","load_dotenv(found_dotenv, override=True)"]},{"cell_type":"code","execution_count":5,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["internlm/internlm2_5-7b-chat-1m datasets/mgtv data/openai_results.csv 2048\n"]}],"source":["import os\n","\n","model_name = os.getenv(\"MODEL_NAME\")\n","data_path = os.getenv(\"LOGICAL_REASONING_DATA_PATH\")\n","results_path = os.getenv(\"LOGICAL_REASONING_RESULTS_PATH\")\n","max_new_tokens = int(os.getenv(\"MAX_NEW_TOKENS\", 2048))\n","\n","print(model_name, data_path, results_path, max_new_tokens)"]},{"cell_type":"code","execution_count":6,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["loading /Users/inflaton/code/engd/projects/logical-reasoning/llm_toolkit/logical_reasoning_utils.py\n"]}],"source":["from llm_toolkit.logical_reasoning_utils import *"]},{"cell_type":"code","execution_count":7,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["loading train/test data files\n","DatasetDict({\n"," train: Dataset({\n"," features: ['text', 'label', 'answer', 'title', 'puzzle', 'truth'],\n"," num_rows: 25000\n"," })\n"," test: Dataset({\n"," features: ['text', 'label', 'answer', 'title', 'puzzle', 'truth'],\n"," num_rows: 3000\n"," })\n","})\n","num_shots: 10\n","labels: ['不是' '不重要' '是' '问法错误' '回答正确']\n","P2_few_shot: 你是一个情景猜谜游戏的主持人。游戏规则如下:\n","\n","1. 参与者会得到一个谜面,谜面会描述一个简单又难以理解的事件。\n","2. 主持人知道谜底,谜底是谜面的答案。\n","3. 参与者可以询问任何封闭式问题来找寻事件的真相。\n","4. 对于每个问题,主持人将根据实际情况回答以下五个选项之一:是、不是、不重要、回答正确、问法错误。各回答的判断标准如下:\n"," - 若谜面和谜底能找到问题的答案,回答:是或者不是\n"," - 若谜面和谜底不能直接或者间接推断出问题的答案,回答:不重要\n"," - 若参与者提问不是一个封闭式问题或者问题难以理解,回答:问法错误\n"," - 若参与者提问基本还原了谜底真相,回答:回答正确\n","5. 回答中不能添加任何其它信息,也不能省略选项中的任何一个字。例如,不可以把“不是”省略成“不”。\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","谜底: 原来,这批西瓜是被一只巨大的乌鸦偷走了。这只乌鸦为了给自己的孩子们准备食物,它趁着夜色,竟然将甄家大院的西瓜一颗颗地带回了巢穴。第二天,村民们发现了乌鸦的巢穴,里面堆满了西瓜,而这个意外的真相让所有人都忍俊不禁。甄家老爷也感慨地说:“真是世界大了,什么奇事都有!”\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","参与者提出的问题: 因为甄在钟楼里维修然后昏迷了导致钟楼停止报时\n","回答: 回答正确\n","\n","\n","谜面: {}\n","谜底: {}\n","参与者提出的问题: {}\n","回答: \n","\n"]}],"source":["datasets = load_logical_reasoning_dataset(data_path)\n","\n","prompt = get_few_shot_prompt_template(10, datasets[\"train\"].to_pandas(), debug=True)"]},{"cell_type":"markdown","metadata":{},"source":["## Run Batch Inference"]},{"cell_type":"code","execution_count":10,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["loading train/test data files\n","DatasetDict({\n"," train: Dataset({\n"," features: ['text', 'label', 'answer', 'title', 'puzzle', 'truth'],\n"," num_rows: 25000\n"," })\n"," test: Dataset({\n"," features: ['text', 'label', 'answer', 'title', 'puzzle', 'truth'],\n"," num_rows: 3000\n"," })\n","})\n","num_shots: 10\n","labels: ['不是' '不重要' '是' '问法错误' '回答正确']\n","P2_few_shot: 你是一个情景猜谜游戏的主持人。游戏规则如下:\n","\n","1. 参与者会得到一个谜面,谜面会描述一个简单又难以理解的事件。\n","2. 主持人知道谜底,谜底是谜面的答案。\n","3. 参与者可以询问任何封闭式问题来找寻事件的真相。\n","4. 对于每个问题,主持人将根据实际情况回答以下五个选项之一:是、不是、不重要、回答正确、问法错误。各回答的判断标准如下:\n"," - 若谜面和谜底能找到问题的答案,回答:是或者不是\n"," - 若谜面和谜底不能直接或者间接推断出问题的答案,回答:不重要\n"," - 若参与者提问不是一个封闭式问题或者问题难以理解,回答:问法错误\n"," - 若参与者提问基本还原了谜底真相,回答:回答正确\n","5. 回答中不能添加任何其它信息,也不能省略选项中的任何一个字。例如,不可以把“不是”省略成“不”。\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","谜底: 原来,这批西瓜是被一只巨大的乌鸦偷走了。这只乌鸦为了给自己的孩子们准备食物,它趁着夜色,竟然将甄家大院的西瓜一颗颗地带回了巢穴。第二天,村民们发现了乌鸦的巢穴,里面堆满了西瓜,而这个意外的真相让所有人都忍俊不禁。甄家老爷也感慨地说:“真是世界大了,什么奇事都有!”\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","参与者提出的问题: 因为甄在钟楼里维修然后昏迷了导致钟楼停止报时\n","回答: 回答正确\n","\n","\n","谜面: {}\n","谜底: {}\n","参与者提出的问题: {}\n","回答: \n","\n"]}],"source":["df_batch = load_openai_batch_data(data_path, model=\"gpt-4o-mini\")"]},{"cell_type":"code","execution_count":11,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["--------------------------------------------------\n","custom_id: request-1\n","--------------------------------------------------\n","method: POST\n","--------------------------------------------------\n","url: /v1/chat/completions\n","--------------------------------------------------\n","body: {'model': 'gpt-4o-mini', 'messages': [{'role': 'user', 'content': '你是一个情景猜谜游戏的主持人。游戏规则如下:\\n\\n1. 参与者会得到一个谜面,谜面会描述一个简单又难以理解的事件。\\n2. 主持人知道谜底,谜底是谜面的答案。\\n3. 参与者可以询问任何封闭式问题来找寻事件的真相。\\n4. 对于每个问题,主持人将根据实际情况回答以下五个选项之一:是、不是、不重要、回答正确、问法错误。各回答的判断标准如下:\\n - 若谜面和谜底能找到问题的答案,回答:是或者不是\\n - 若谜面和谜底不能直接或者间接推断出问题的答案,回答:不重要\\n - 若参与者提问不是一个封闭式问题或者问题难以理解,回答:问法错误\\n - 若参与者提问基本还原了谜底真相,回答:回答正确\\n5. 回答中不能添加任何其它信息,也不能省略选项中的任何一个字。例如,不可以把“不是”省略成“不”。\\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谜底: 原来,这批西瓜是被一只巨大的乌鸦偷走了。这只乌鸦为了给自己的孩子们准备食物,它趁着夜色,竟然将甄家大院的西瓜一颗颗地带回了巢穴。第二天,村民们发现了乌鸦的巢穴,里面堆满了西瓜,而这个意外的真相让所有人都忍俊不禁。甄家老爷也感慨地说:“真是世界大了,什么奇事都有!”\\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参与者提出的问题: 因为甄在钟楼里维修然后昏迷了导致钟楼停止报时\\n回答: 回答正确\\n\\n\\n谜面: 在远离城市喧嚣的海边小屋,一天清晨,邻居发现甄加索僵卧在沙滩上,已无生命迹象。现场没有发现任何打斗的迹象。请问甄加索的死因是什么?\\n谜底: 甄加索是一位热爱自然的画家,他每年都会来到这个海边小屋寻找灵感。在他生命的最后几天,他一直在创作一幅描绘海洋生物的画作。在画即将完成的前一天晚上,他骑着自行车外出,打算在海边观赏夜景。然而,他在沙滩上意外发现了一只搁浅的海豚,为了救助这只海豚,他耗费了极大的体力,最终成功将其送回海中。筋疲力尽的甄加索在沙滩上睡着了,由于他患有严重的心脏病,却未告知旁人,在寒冷的海风中,他的心脏停止了跳动。因此,警方在现场只发现了车轮痕迹和未完成的画作,而没有发现任何他杀的迹象。\\n参与者提出的问题: 甄加索是自杀吗\\n回答: \\n'}]}\n"]}],"source":["from llm_toolkit.llm_utils import print_row_details\n","\n","print_row_details(df_batch)"]},{"cell_type":"code","execution_count":13,"metadata":{},"outputs":[{"data":{"text/plain":["FileObject(id='file-dFg7ljzKlmPTy6C0KTs6fYxz', bytes=57935228, created_at=1726210402, filename='gpt-4o-mini.jsonl', object='file', purpose='batch', status='processed', status_details=None)"]},"execution_count":13,"metadata":{},"output_type":"execute_result"}],"source":["from openai import OpenAI\n","\n","client = OpenAI()\n","\n","batch_input_file = client.files.create(\n"," file=open(\"datasets/mgtv/gpt-4o-mini.jsonl\", \"rb\"), purpose=\"batch\"\n",")\n","batch_input_file"]},{"cell_type":"code","execution_count":14,"metadata":{},"outputs":[{"data":{"text/plain":["Batch(id='batch_xVbfEAMd9Z3TOH2gkCxoe6GF', completion_window='24h', created_at=1726210433, endpoint='/v1/chat/completions', input_file_id='file-dFg7ljzKlmPTy6C0KTs6fYxz', object='batch', status='validating', cancelled_at=None, cancelling_at=None, completed_at=None, error_file_id=None, errors=None, expired_at=None, expires_at=1726296833, failed_at=None, finalizing_at=None, in_progress_at=None, metadata={'description': 'nightly eval job - gpt-4o-mini'}, output_file_id=None, request_counts=BatchRequestCounts(completed=0, failed=0, total=0))"]},"execution_count":14,"metadata":{},"output_type":"execute_result"}],"source":["batch_input_file_id = batch_input_file.id\n","\n","client.batches.create(\n"," input_file_id=batch_input_file_id,\n"," endpoint=\"/v1/chat/completions\",\n"," completion_window=\"24h\",\n"," metadata={\n"," \"description\": \"nightly eval job - gpt-4o-mini\",\n"," },\n",")"]},{"cell_type":"code","execution_count":16,"metadata":{},"outputs":[{"data":{"text/plain":["Batch(id='batch_xVbfEAMd9Z3TOH2gkCxoe6GF', completion_window='24h', created_at=1726210433, endpoint='/v1/chat/completions', input_file_id='file-dFg7ljzKlmPTy6C0KTs6fYxz', object='batch', status='completed', cancelled_at=None, cancelling_at=None, completed_at=1726211968, error_file_id=None, errors=None, expired_at=None, expires_at=1726296833, failed_at=None, finalizing_at=1726211455, in_progress_at=1726210437, metadata={'description': 'nightly eval job - gpt-4o-mini'}, output_file_id='file-4DyXwheO1GIPHYII08guYDfp', request_counts=BatchRequestCounts(completed=3000, failed=0, total=3000))"]},"execution_count":16,"metadata":{},"output_type":"execute_result"}],"source":["from openai import OpenAI\n","\n","client = OpenAI()\n","\n","client.batches.retrieve(\"batch_xVbfEAMd9Z3TOH2gkCxoe6GF\")"]}],"metadata":{"accelerator":"GPU","application/vnd.databricks.v1+notebook":{"dashboards":[],"environmentMetadata":null,"language":"python","notebookMetadata":{"pythonIndentUnit":4},"notebookName":"07_MAC_+_Qwen2-7B-Instructi_Unsloth_train","widgets":{}},"colab":{"gpuType":"T4","provenance":[]},"kernelspec":{"display_name":"Python 3","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.11.9"}},"nbformat":4,"nbformat_minor":0}
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0e7b7248a018e4729079fe01a8c490c470028f6538ad8073fde709e99451cd81
|
3 |
+
size 36120
|
notebooks/04e_OpenAI_o1_vs_gpt_4o.ipynb
CHANGED
@@ -1,573 +1,3 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
"cell_type": "code",
|
5 |
-
"execution_count": 1,
|
6 |
-
"metadata": {},
|
7 |
-
"outputs": [],
|
8 |
-
"source": [
|
9 |
-
"from pathlib import Path\n",
|
10 |
-
"\n",
|
11 |
-
"if \"workding_dir\" not in locals():\n",
|
12 |
-
" try:\n",
|
13 |
-
" from google.colab import drive\n",
|
14 |
-
"\n",
|
15 |
-
" drive.mount(\"/content/drive\")\n",
|
16 |
-
" workding_dir = \"/content/drive/MyDrive/logical-reasoning/\"\n",
|
17 |
-
" except ModuleNotFoundError:\n",
|
18 |
-
" workding_dir = str(Path.cwd().parent)"
|
19 |
-
]
|
20 |
-
},
|
21 |
-
{
|
22 |
-
"cell_type": "code",
|
23 |
-
"execution_count": 2,
|
24 |
-
"metadata": {},
|
25 |
-
"outputs": [
|
26 |
-
{
|
27 |
-
"name": "stdout",
|
28 |
-
"output_type": "stream",
|
29 |
-
"text": [
|
30 |
-
"workding dir: /Users/inflaton/code/engd/projects/logical-reasoning\n"
|
31 |
-
]
|
32 |
-
}
|
33 |
-
],
|
34 |
-
"source": [
|
35 |
-
"import os\n",
|
36 |
-
"import sys\n",
|
37 |
-
"\n",
|
38 |
-
"os.chdir(workding_dir)\n",
|
39 |
-
"sys.path.append(workding_dir)\n",
|
40 |
-
"print(\"workding dir:\", workding_dir)"
|
41 |
-
]
|
42 |
-
},
|
43 |
-
{
|
44 |
-
"cell_type": "code",
|
45 |
-
"execution_count": 3,
|
46 |
-
"metadata": {
|
47 |
-
"id": "l40Iu1qbZkMH"
|
48 |
-
},
|
49 |
-
"outputs": [],
|
50 |
-
"source": [
|
51 |
-
"from llm_toolkit.llm_utils import *"
|
52 |
-
]
|
53 |
-
},
|
54 |
-
{
|
55 |
-
"cell_type": "markdown",
|
56 |
-
"metadata": {
|
57 |
-
"id": "wN-vwM7_ZkMI"
|
58 |
-
},
|
59 |
-
"source": [
|
60 |
-
"## Compare GPT-4o and o1-preview\n",
|
61 |
-
"\n",
|
62 |
-
"[LogiQA-dataset / Train.txt](https://raw.githubusercontent.com/lgw863/LogiQA-dataset/master/Train.txt)\n",
|
63 |
-
"\n",
|
64 |
-
"There are 4 cups on the table, each with a sentence written on it.The first cup: \"Beer is in all cups\".The second cup: \"Cola in this cup\".The third cup: \" No coffee in this cup \".Fourth cup:\" Some cups have no beer \".Only one of the 4 sentences is true.\n",
|
65 |
-
"\n",
|
66 |
-
"So which of the following is true?\n",
|
67 |
-
"\n",
|
68 |
-
"A.Beer is in all cups\n",
|
69 |
-
"\n",
|
70 |
-
"B.No cola in all cups\n",
|
71 |
-
"\n",
|
72 |
-
"C.Coffee in the third cup\n",
|
73 |
-
"\n",
|
74 |
-
"D.Cola in the second cup\n",
|
75 |
-
"\n",
|
76 |
-
"**Correct Answer:** C"
|
77 |
-
]
|
78 |
-
},
|
79 |
-
{
|
80 |
-
"cell_type": "code",
|
81 |
-
"execution_count": null,
|
82 |
-
"metadata": {
|
83 |
-
"id": "tyW4CRnBZkMI",
|
84 |
-
"outputId": "e6481d65-6710-4267-f6b6-4a0925ce2ba1"
|
85 |
-
},
|
86 |
-
"outputs": [
|
87 |
-
{
|
88 |
-
"name": "stdout",
|
89 |
-
"output_type": "stream",
|
90 |
-
"text": [
|
91 |
-
"There are 4 cups on the table, each with a sentence written on it.The first cup: \"Beer is in all cups\".The second cup: \"Cola in this cup\".The third cup: \" No coffee in this cup \".Fourth cup:\" Some cups have no beer \".Only one of the 4 sentences is true.\n",
|
92 |
-
"So which of the following is true?\n",
|
93 |
-
"A.Beer is in all cups\n",
|
94 |
-
"B.No cola in all cups\n",
|
95 |
-
"C.Coffee in the third cup\n",
|
96 |
-
"D.Cola in the second cup\n"
|
97 |
-
]
|
98 |
-
}
|
99 |
-
],
|
100 |
-
"source": [
|
101 |
-
"prompt = \"\"\"There are 4 cups on the table, each with a sentence written on it.The first cup: \"Beer is in all cups\".The second cup: \"Cola in this cup\".The third cup: \" No coffee in this cup \".Fourth cup:\" Some cups have no beer \".Only one of the 4 sentences is true.\n",
|
102 |
-
"So which of the following is true?\n",
|
103 |
-
"A.Beer is in all cups\n",
|
104 |
-
"B.No cola in all cups\n",
|
105 |
-
"C.Coffee in the third cup\n",
|
106 |
-
"D.Cola in the second cup\"\"\"\n",
|
107 |
-
"\n",
|
108 |
-
"print(prompt)"
|
109 |
-
]
|
110 |
-
},
|
111 |
-
{
|
112 |
-
"cell_type": "code",
|
113 |
-
"execution_count": null,
|
114 |
-
"metadata": {
|
115 |
-
"id": "xjQoOWHtZkMI",
|
116 |
-
"outputId": "f4f085a6-0a93-498c-c615-86032ceff73d"
|
117 |
-
},
|
118 |
-
"outputs": [
|
119 |
-
{
|
120 |
-
"name": "stdout",
|
121 |
-
"output_type": "stream",
|
122 |
-
"text": [
|
123 |
-
"We are given that there are four cups, each with a sentence, and only one of these sentences is true. We'll denote the sentences as follows:\n",
|
124 |
-
"\n",
|
125 |
-
"- S1 on Cup 1: \"Beer is in all cups.\"\n",
|
126 |
-
"- S2 on Cup 2: \"Cola is in this cup.\"\n",
|
127 |
-
"- S3 on Cup 3: \"No coffee in this cup.\"\n",
|
128 |
-
"- S4 on Cup 4: \"Some cups have no beer.\"\n",
|
129 |
-
"\n",
|
130 |
-
"Our goal is to determine which of the options (A-D) must be true given that only one of S1-S4 is true.\n",
|
131 |
-
"\n",
|
132 |
-
"**Case 1: Assume S1 is true, and S2, S3, S4 are false.**\n",
|
133 |
-
"\n",
|
134 |
-
"- **S1 is true**: \"Beer is in all cups.\"\n",
|
135 |
-
"- **S2 is false**: \"Cola is in this cup\" is false ⇒ Cup 2 does **not** have cola.\n",
|
136 |
-
"- **S3 is false**: \"No coffee in this cup\" is false ⇒ Cup 3 **does** have coffee.\n",
|
137 |
-
"- **S4 is false**: \"Some cups have no beer\" is false ⇒ All cups have beer (which aligns with S1 being true).\n",
|
138 |
-
"\n",
|
139 |
-
"**Case 2: Assume S4 is true, and S1, S2, S3 are false.**\n",
|
140 |
-
"\n",
|
141 |
-
"- **S4 is true**: \"Some cups have no beer.\"\n",
|
142 |
-
"- **S1 is false**: \"Beer is in all cups\" is false ⇒ At least one cup does **not** have beer.\n",
|
143 |
-
"- **S2 is false**: \"Cola is in this cup\" is false ⇒ Cup 2 does **not** have cola.\n",
|
144 |
-
"- **S3 is false**: \"No coffee in this cup\" is false ⇒ Cup 3 **does** have coffee.\n",
|
145 |
-
"\n",
|
146 |
-
"**In both cases**, Cup 3 has coffee. Also, in both cases, we cannot conclude that \"No cola in all cups\" (Option B) is true because we have no information on cola in cups other than Cup 2. Option D (\"Cola in the second cup\") is false because we've determined Cup 2 does not have cola in both scenarios.\n",
|
147 |
-
"\n",
|
148 |
-
"Therefore, the only option that must be true, regardless of which sentence (S1 or S4) is true, is **Option C: Coffee in the third cup**.\n",
|
149 |
-
"\n",
|
150 |
-
"**Answer: C.Coffee in the third cup**\n",
|
151 |
-
"CPU times: user 21.2 ms, sys: 2.31 ms, total: 23.5 ms\n",
|
152 |
-
"Wall time: 47.3 s\n"
|
153 |
-
]
|
154 |
-
}
|
155 |
-
],
|
156 |
-
"source": [
|
157 |
-
"%%time\n",
|
158 |
-
"\n",
|
159 |
-
"o1_preview_answer = invoke_openai_api(prompt, model=\"o1-preview\", temperature=1)\n",
|
160 |
-
"print(o1_preview_answer)"
|
161 |
-
]
|
162 |
-
},
|
163 |
-
{
|
164 |
-
"cell_type": "markdown",
|
165 |
-
"metadata": {
|
166 |
-
"id": "Z7XAd-XkZ1NU"
|
167 |
-
},
|
168 |
-
"source": [
|
169 |
-
"**Answer by o1-preview:**\n",
|
170 |
-
"\n",
|
171 |
-
"We are given that there are four cups, each with a sentence, and only one of these sentences is true. We'll denote the sentences as follows:\n",
|
172 |
-
"\n",
|
173 |
-
"- S1 on Cup 1: \"Beer is in all cups.\"\n",
|
174 |
-
"- S2 on Cup 2: \"Cola is in this cup.\"\n",
|
175 |
-
"- S3 on Cup 3: \"No coffee in this cup.\"\n",
|
176 |
-
"- S4 on Cup 4: \"Some cups have no beer.\"\n",
|
177 |
-
"\n",
|
178 |
-
"Our goal is to determine which of the options (A-D) must be true given that only one of S1-S4 is true.\n",
|
179 |
-
"\n",
|
180 |
-
"**Case 1: Assume S1 is true, and S2, S3, S4 are false.**\n",
|
181 |
-
"\n",
|
182 |
-
"- **S1 is true**: \"Beer is in all cups.\"\n",
|
183 |
-
"- **S2 is false**: \"Cola is in this cup\" is false ⇒ Cup 2 does **not** have cola.\n",
|
184 |
-
"- **S3 is false**: \"No coffee in this cup\" is false ⇒ Cup 3 **does** have coffee.\n",
|
185 |
-
"- **S4 is false**: \"Some cups have no beer\" is false ⇒ All cups have beer (which aligns with S1 being true).\n",
|
186 |
-
"\n",
|
187 |
-
"**Case 2: Assume S4 is true, and S1, S2, S3 are false.**\n",
|
188 |
-
"\n",
|
189 |
-
"- **S4 is true**: \"Some cups have no beer.\"\n",
|
190 |
-
"- **S1 is false**: \"Beer is in all cups\" is false ⇒ At least one cup does **not** have beer.\n",
|
191 |
-
"- **S2 is false**: \"Cola is in this cup\" is false ⇒ Cup 2 does **not** have cola.\n",
|
192 |
-
"- **S3 is false**: \"No coffee in this cup\" is false ⇒ Cup 3 **does** have coffee.\n",
|
193 |
-
"\n",
|
194 |
-
"**In both cases**, Cup 3 has coffee. Also, in both cases, we cannot conclude that \"No cola in all cups\" (Option B) is true because we have no information on cola in cups other than Cup 2. Option D (\"Cola in the second cup\") is false because we've determined Cup 2 does not have cola in both scenarios.\n",
|
195 |
-
"\n",
|
196 |
-
"Therefore, the only option that must be true, regardless of which sentence (S1 or S4) is true, is **Option C: Coffee in the third cup**.\n",
|
197 |
-
"\n",
|
198 |
-
"**Answer: C.Coffee in the third cup**"
|
199 |
-
]
|
200 |
-
},
|
201 |
-
{
|
202 |
-
"cell_type": "code",
|
203 |
-
"execution_count": null,
|
204 |
-
"metadata": {
|
205 |
-
"id": "yRw5u-QEZkMJ",
|
206 |
-
"outputId": "17d72e5d-4a8a-4842-a183-cc46e0c81ba6"
|
207 |
-
},
|
208 |
-
"outputs": [
|
209 |
-
{
|
210 |
-
"name": "stdout",
|
211 |
-
"output_type": "stream",
|
212 |
-
"text": [
|
213 |
-
"Let's analyze the problem step by step to determine which of the options is true, given that only one of the four sentences on the cups is true.\n",
|
214 |
-
"\n",
|
215 |
-
"### **Cup Statements:**\n",
|
216 |
-
"1. **Cup 1:** \"Beer is in all cups.\"\n",
|
217 |
-
"2. **Cup 2:** \"Cola in this cup.\"\n",
|
218 |
-
"3. **Cup 3:** \"No coffee in this cup.\"\n",
|
219 |
-
"4. **Cup 4:** \"Some cups have no beer.\"\n",
|
220 |
-
"\n",
|
221 |
-
"### **Options:**\n",
|
222 |
-
"A. Beer is in all cups \n",
|
223 |
-
"B. No cola in all cups \n",
|
224 |
-
"C. Coffee in the third cup \n",
|
225 |
-
"D. Cola in the second cup\n",
|
226 |
-
"\n",
|
227 |
-
"### **Analysis:**\n",
|
228 |
-
"\n",
|
229 |
-
"1. **Assume Cup 1 is True (\"Beer is in all cups\"):**\n",
|
230 |
-
" - **Cup 2:** \"Cola in this cup\" is **false** → No cola in Cup 2.\n",
|
231 |
-
" - **Cup 3:** \"No coffee in this cup\" is **false** → Coffee **is** in Cup 3.\n",
|
232 |
-
" - **Cup 4:** \"Some cups have no beer\" is **false** → All cups **do** have beer.\n",
|
233 |
-
"\n",
|
234 |
-
" **Implications:**\n",
|
235 |
-
" - **Option A:** True.\n",
|
236 |
-
" - **Option C:** True.\n",
|
237 |
-
"\n",
|
238 |
-
" **Issue:** Both A and C are true, which violates the condition that only one statement is true.\n",
|
239 |
-
"\n",
|
240 |
-
"2. **Assume Cup 4 is True (\"Some cups have no beer\"):**\n",
|
241 |
-
" - **Cup 1:** \"Beer is in all cups\" is **false** → Not all cups have beer.\n",
|
242 |
-
" - **Cup 2:** \"Cola in this cup\" is **false** → No cola in Cup 2.\n",
|
243 |
-
" - **Cup 3:** \"No coffee in this cup\" is **false** → Coffee **is** in Cup 3.\n",
|
244 |
-
"\n",
|
245 |
-
" **Implications:**\n",
|
246 |
-
" - **Option C:** True.\n",
|
247 |
-
" - **Options A, B, D:** Either false or not necessarily true.\n",
|
248 |
-
"\n",
|
249 |
-
" **Conclusion:** Only **Option C** holds true without violating the condition.\n",
|
250 |
-
"\n",
|
251 |
-
"### **Final Answer:**\n",
|
252 |
-
"\n",
|
253 |
-
"**C. Coffee in the third cup**\n",
|
254 |
-
"CPU times: user 20.4 ms, sys: 2.62 ms, total: 23.1 ms\n",
|
255 |
-
"Wall time: 20.8 s\n"
|
256 |
-
]
|
257 |
-
}
|
258 |
-
],
|
259 |
-
"source": [
|
260 |
-
"%%time\n",
|
261 |
-
"\n",
|
262 |
-
"o1_mini_answer = invoke_openai_api(prompt, model=\"o1-mini\", temperature=1)\n",
|
263 |
-
"print(o1_mini_answer)"
|
264 |
-
]
|
265 |
-
},
|
266 |
-
{
|
267 |
-
"cell_type": "markdown",
|
268 |
-
"metadata": {
|
269 |
-
"id": "241cVccaZ7LF"
|
270 |
-
},
|
271 |
-
"source": [
|
272 |
-
"**Answer by o1-mini:**\n",
|
273 |
-
"\n",
|
274 |
-
"Let's analyze the problem step by step to determine which of the options is true, given that only one of the four sentences on the cups is true.\n",
|
275 |
-
"\n",
|
276 |
-
"### **Cup Statements:**\n",
|
277 |
-
"1. **Cup 1:** \"Beer is in all cups.\"\n",
|
278 |
-
"2. **Cup 2:** \"Cola in this cup.\"\n",
|
279 |
-
"3. **Cup 3:** \"No coffee in this cup.\"\n",
|
280 |
-
"4. **Cup 4:** \"Some cups have no beer.\"\n",
|
281 |
-
"\n",
|
282 |
-
"### **Options:**\n",
|
283 |
-
"A. Beer is in all cups \n",
|
284 |
-
"B. No cola in all cups \n",
|
285 |
-
"C. Coffee in the third cup \n",
|
286 |
-
"D. Cola in the second cup\n",
|
287 |
-
"\n",
|
288 |
-
"### **Analysis:**\n",
|
289 |
-
"\n",
|
290 |
-
"1. **Assume Cup 1 is True (\"Beer is in all cups\"):**\n",
|
291 |
-
" - **Cup 2:** \"Cola in this cup\" is **false** → No cola in Cup 2.\n",
|
292 |
-
" - **Cup 3:** \"No coffee in this cup\" is **false** → Coffee **is** in Cup 3.\n",
|
293 |
-
" - **Cup 4:** \"Some cups have no beer\" is **false** → All cups **do** have beer.\n",
|
294 |
-
"\n",
|
295 |
-
" **Implications:**\n",
|
296 |
-
" - **Option A:** True.\n",
|
297 |
-
" - **Option C:** True.\n",
|
298 |
-
"\n",
|
299 |
-
" **Issue:** Both A and C are true, which violates the condition that only one statement is true.\n",
|
300 |
-
"\n",
|
301 |
-
"2. **Assume Cup 4 is True (\"Some cups have no beer\"):**\n",
|
302 |
-
" - **Cup 1:** \"Beer is in all cups\" is **false** → Not all cups have beer.\n",
|
303 |
-
" - **Cup 2:** \"Cola in this cup\" is **false** → No cola in Cup 2.\n",
|
304 |
-
" - **Cup 3:** \"No coffee in this cup\" is **false** → Coffee **is** in Cup 3.\n",
|
305 |
-
"\n",
|
306 |
-
" **Implications:**\n",
|
307 |
-
" - **Option C:** True.\n",
|
308 |
-
" - **Options A, B, D:** Either false or not necessarily true.\n",
|
309 |
-
"\n",
|
310 |
-
" **Conclusion:** Only **Option C** holds true without violating the condition.\n",
|
311 |
-
"\n",
|
312 |
-
"### **Final Answer:**\n",
|
313 |
-
"\n",
|
314 |
-
"**C. Coffee in the third cup**"
|
315 |
-
]
|
316 |
-
},
|
317 |
-
{
|
318 |
-
"cell_type": "code",
|
319 |
-
"execution_count": null,
|
320 |
-
"metadata": {
|
321 |
-
"id": "Tq0-6LjIZkMJ",
|
322 |
-
"outputId": "75fb4ce6-54a5-44eb-8b01-654bd3eff2a9"
|
323 |
-
},
|
324 |
-
"outputs": [
|
325 |
-
{
|
326 |
-
"name": "stdout",
|
327 |
-
"output_type": "stream",
|
328 |
-
"text": [
|
329 |
-
"To solve this puzzle, we need to determine which one of the four sentences is true, given that only one of them is true. Let's analyze each sentence and its implications:\n",
|
330 |
-
"\n",
|
331 |
-
"1. **First cup: \"Beer is in all cups\"**\n",
|
332 |
-
" - If this sentence is true, then beer must be in all four cups.\n",
|
333 |
-
" - This would make the fourth sentence (\"Some cups have no beer\") false, which is consistent with the condition that only one sentence is true.\n",
|
334 |
-
" - However, if beer is in all cups, the second sentence (\"Cola in this cup\") would also be false, which is consistent.\n",
|
335 |
-
" - The third sentence (\"No coffee in this cup\") would also be false, which is consistent.\n",
|
336 |
-
" - This scenario seems possible, but let's check the other sentences to be sure.\n",
|
337 |
-
"\n",
|
338 |
-
"2. **Second cup: \"Cola in this cup\"**\n",
|
339 |
-
" - If this sentence is true, then cola must be in the second cup.\n",
|
340 |
-
" - This would make the first sentence (\"Beer is in all cups\") false, which is consistent.\n",
|
341 |
-
" - The third sentence (\"No coffee in this cup\") would also be false, which means there is coffee in the third cup.\n",
|
342 |
-
" - The fourth sentence (\"Some cups have no beer\") would also be false, which means all cups have beer.\n",
|
343 |
-
" - This scenario seems possible, but let's check the other sentences to be sure.\n",
|
344 |
-
"\n",
|
345 |
-
"3. **Third cup: \"No coffee in this cup\"**\n",
|
346 |
-
" - If this sentence is true, then there is no coffee in the third cup.\n",
|
347 |
-
" - This would make the first sentence (\"Beer is in all cups\") false, which is consistent.\n",
|
348 |
-
" - The second sentence (\"Cola in this cup\") would also be false, which means there is no cola in the second cup.\n",
|
349 |
-
" - The fourth sentence (\"Some cups have no beer\") would also be false, which means all cups have beer.\n",
|
350 |
-
" - This scenario seems possible, but let's check the other sentences to be sure.\n",
|
351 |
-
"\n",
|
352 |
-
"4. **Fourth cup: \"Some cups have no beer\"**\n",
|
353 |
-
" - If this sentence is true, then at least one cup does not have beer.\n",
|
354 |
-
" - This would make the first sentence (\"Beer is in all cups\") false, which is consistent.\n",
|
355 |
-
" - The second sentence (\"Cola in this cup\") would also be false, which means there is no cola in the second cup.\n",
|
356 |
-
" - The third sentence (\"No coffee in this cup\") would also be false, which means there is coffee in the third cup.\n",
|
357 |
-
" - This scenario seems possible, but let's check the other sentences to be sure.\n",
|
358 |
-
"\n",
|
359 |
-
"Now, let's summarize the implications of each scenario:\n",
|
360 |
-
"\n",
|
361 |
-
"- If the first sentence is true, then beer is in all cups, and the other sentences are false.\n",
|
362 |
-
"- If the second sentence is true, then cola is in the second cup, and the other sentences are false.\n",
|
363 |
-
"- If the third sentence is true, then there is no coffee in the third cup, and the other sentences are false.\n",
|
364 |
-
"- If the fourth sentence is true, then some cups have no beer, and the other sentences are false.\n",
|
365 |
-
"\n",
|
366 |
-
"Given that only one sentence is true, the scenario where the second sentence is true (Cola in the second cup) seems to be the most consistent with the condition that only one sentence is true. Therefore, the correct answer is:\n",
|
367 |
-
"\n",
|
368 |
-
"D. Cola in the second cup\n",
|
369 |
-
"CPU times: user 18.1 ms, sys: 2.2 ms, total: 20.3 ms\n",
|
370 |
-
"Wall time: 7.71 s\n"
|
371 |
-
]
|
372 |
-
}
|
373 |
-
],
|
374 |
-
"source": [
|
375 |
-
"%%time\n",
|
376 |
-
"\n",
|
377 |
-
"gpt_4o_answer = invoke_openai_api(prompt, model=\"gpt-4o\")\n",
|
378 |
-
"print(gpt_4o_answer)"
|
379 |
-
]
|
380 |
-
},
|
381 |
-
{
|
382 |
-
"cell_type": "markdown",
|
383 |
-
"metadata": {
|
384 |
-
"id": "7zDghv7taRqC"
|
385 |
-
},
|
386 |
-
"source": [
|
387 |
-
"**Answer by gpt-4o:**\n",
|
388 |
-
"\n",
|
389 |
-
"To solve this puzzle, we need to determine which one of the four sentences is true, given that only one of them is true. Let's analyze each sentence and its implications:\n",
|
390 |
-
"\n",
|
391 |
-
"1. **First cup: \"Beer is in all cups\"**\n",
|
392 |
-
" - If this sentence is true, then beer must be in all four cups.\n",
|
393 |
-
" - This would make the fourth sentence (\"Some cups have no beer\") false, which is consistent with the condition that only one sentence is true.\n",
|
394 |
-
" - However, if beer is in all cups, the second sentence (\"Cola in this cup\") would also be false, which is consistent.\n",
|
395 |
-
" - The third sentence (\"No coffee in this cup\") would also be false, which is consistent.\n",
|
396 |
-
" - This scenario seems possible, but let's check the other sentences to be sure.\n",
|
397 |
-
"\n",
|
398 |
-
"2. **Second cup: \"Cola in this cup\"**\n",
|
399 |
-
" - If this sentence is true, then cola must be in the second cup.\n",
|
400 |
-
" - This would make the first sentence (\"Beer is in all cups\") false, which is consistent.\n",
|
401 |
-
" - The third sentence (\"No coffee in this cup\") would also be false, which means there is coffee in the third cup.\n",
|
402 |
-
" - The fourth sentence (\"Some cups have no beer\") would also be false, which means all cups have beer.\n",
|
403 |
-
" - This scenario seems possible, but let's check the other sentences to be sure.\n",
|
404 |
-
"\n",
|
405 |
-
"3. **Third cup: \"No coffee in this cup\"**\n",
|
406 |
-
" - If this sentence is true, then there is no coffee in the third cup.\n",
|
407 |
-
" - This would make the first sentence (\"Beer is in all cups\") false, which is consistent.\n",
|
408 |
-
" - The second sentence (\"Cola in this cup\") would also be false, which means there is no cola in the second cup.\n",
|
409 |
-
" - The fourth sentence (\"Some cups have no beer\") would also be false, which means all cups have beer.\n",
|
410 |
-
" - This scenario seems possible, but let's check the other sentences to be sure.\n",
|
411 |
-
"\n",
|
412 |
-
"4. **Fourth cup: \"Some cups have no beer\"**\n",
|
413 |
-
" - If this sentence is true, then at least one cup does not have beer.\n",
|
414 |
-
" - This would make the first sentence (\"Beer is in all cups\") false, which is consistent.\n",
|
415 |
-
" - The second sentence (\"Cola in this cup\") would also be false, which means there is no cola in the second cup.\n",
|
416 |
-
" - The third sentence (\"No coffee in this cup\") would also be false, which means there is coffee in the third cup.\n",
|
417 |
-
" - This scenario seems possible, but let's check the other sentences to be sure.\n",
|
418 |
-
"\n",
|
419 |
-
"Now, let's summarize the implications of each scenario:\n",
|
420 |
-
"\n",
|
421 |
-
"- If the first sentence is true, then beer is in all cups, and the other sentences are false.\n",
|
422 |
-
"- If the second sentence is true, then cola is in the second cup, and the other sentences are false.\n",
|
423 |
-
"- If the third sentence is true, then there is no coffee in the third cup, and the other sentences are false.\n",
|
424 |
-
"- If the fourth sentence is true, then some cups have no beer, and the other sentences are false.\n",
|
425 |
-
"\n",
|
426 |
-
"Given that only one sentence is true, the scenario where the second sentence is true (Cola in the second cup) seems to be the most consistent with the condition that only one sentence is true. Therefore, the correct answer is:\n",
|
427 |
-
"\n",
|
428 |
-
"D. Cola in the second cup"
|
429 |
-
]
|
430 |
-
},
|
431 |
-
{
|
432 |
-
"cell_type": "code",
|
433 |
-
"execution_count": null,
|
434 |
-
"metadata": {
|
435 |
-
"id": "aDCNM8x3ZkMJ",
|
436 |
-
"outputId": "360d4617-f173-4c77-dc5f-49333aeeae00"
|
437 |
-
},
|
438 |
-
"outputs": [
|
439 |
-
{
|
440 |
-
"name": "stdout",
|
441 |
-
"output_type": "stream",
|
442 |
-
"text": [
|
443 |
-
"To solve this puzzle, we need to analyze the statements on the cups and determine which one is true, given that only one of the four sentences is true.\n",
|
444 |
-
"\n",
|
445 |
-
"1. **First cup: \"Beer is in all cups.\"**\n",
|
446 |
-
" - If this statement is true, then all cups contain beer, which would make the fourth cup's statement (\"Some cups have no beer\") false. This would mean that more than one statement is true, which contradicts the condition that only one statement is true. Therefore, this statement cannot be true.\n",
|
447 |
-
"\n",
|
448 |
-
"2. **Second cup: \"Cola in this cup.\"**\n",
|
449 |
-
" - If this statement is true, then the second cup contains cola. However, if the second cup has cola, it does not affect the truth of the other statements directly. We need to check the other statements to see if this can be the only true statement.\n",
|
450 |
-
"\n",
|
451 |
-
"3. **Third cup: \"No coffee in this cup.\"**\n",
|
452 |
-
" - If this statement is true, then the third cup does not contain coffee. If this is true, it does not directly contradict any other statements, but we need to check the implications.\n",
|
453 |
-
"\n",
|
454 |
-
"4. **Fourth cup: \"Some cups have no beer.\"**\n",
|
455 |
-
" - If this statement is true, then at least one cup does not contain beer. If this is true, it contradicts the first cup's statement (\"Beer is in all cups\"), which would mean that more than one statement is true. Therefore, this statement cannot be true.\n",
|
456 |
-
"\n",
|
457 |
-
"Now, let's analyze the implications of the second and third cups being true:\n",
|
458 |
-
"\n",
|
459 |
-
"- If the **second cup** is true (\"Cola in this cup\"), then:\n",
|
460 |
-
" - The first cup is false (not all cups have beer).\n",
|
461 |
-
" - The third cup could still be true or false.\n",
|
462 |
-
" - The fourth cup could still be true or false.\n",
|
463 |
-
"\n",
|
464 |
-
"- If the **third cup** is true (\"No coffee in this cup\"), then:\n",
|
465 |
-
" - The first cup is false (not all cups have beer).\n",
|
466 |
-
" - The second cup could still be true or false.\n",
|
467 |
-
" - The fourth cup could still be true or false.\n",
|
468 |
-
"\n",
|
469 |
-
"Since we need to find a scenario where only one statement is true, we can conclude:\n",
|
470 |
-
"\n",
|
471 |
-
"- If the second cup is true, then the first cup is false, and the fourth cup must also be false (which means all cups have beer, contradicting the second cup). This leads to a contradiction.\n",
|
472 |
-
"- If the third cup is true, then the first cup is false, and the fourth cup must also be false (which means all cups have beer, contradicting the third cup). This leads to a contradiction.\n",
|
473 |
-
"\n",
|
474 |
-
"Thus, the only consistent scenario is that the **second cup** is true, which means:\n",
|
475 |
-
"\n",
|
476 |
-
"**B. No cola in all cups** is the only true statement. \n",
|
477 |
-
"\n",
|
478 |
-
"So, the answer is **B. No cola in all cups**.\n",
|
479 |
-
"CPU times: user 23.5 ms, sys: 2.57 ms, total: 26.1 ms\n",
|
480 |
-
"Wall time: 4.78 s\n"
|
481 |
-
]
|
482 |
-
}
|
483 |
-
],
|
484 |
-
"source": [
|
485 |
-
"%%time\n",
|
486 |
-
"\n",
|
487 |
-
"gpt_4o_mini_answer = invoke_openai_api(prompt, model=\"gpt-4o-mini\")\n",
|
488 |
-
"print(gpt_4o_mini_answer)"
|
489 |
-
]
|
490 |
-
},
|
491 |
-
{
|
492 |
-
"cell_type": "markdown",
|
493 |
-
"metadata": {
|
494 |
-
"id": "o33uWumdaeFT"
|
495 |
-
},
|
496 |
-
"source": [
|
497 |
-
"**Answer by gpt-4o-mini:**\n",
|
498 |
-
"\n",
|
499 |
-
"To solve this puzzle, we need to analyze the statements on the cups and determine which one is true, given that only one of the four sentences is true.\n",
|
500 |
-
"\n",
|
501 |
-
"1. **First cup: \"Beer is in all cups.\"**\n",
|
502 |
-
" - If this statement is true, then all cups contain beer, which would make the fourth cup's statement (\"Some cups have no beer\") false. This would mean that more than one statement is true, which contradicts the condition that only one statement is true. Therefore, this statement cannot be true.\n",
|
503 |
-
"\n",
|
504 |
-
"2. **Second cup: \"Cola in this cup.\"**\n",
|
505 |
-
" - If this statement is true, then the second cup contains cola. However, if the second cup has cola, it does not affect the truth of the other statements directly. We need to check the other statements to see if this can be the only true statement.\n",
|
506 |
-
"\n",
|
507 |
-
"3. **Third cup: \"No coffee in this cup.\"**\n",
|
508 |
-
" - If this statement is true, then the third cup does not contain coffee. If this is true, it does not directly contradict any other statements, but we need to check the implications.\n",
|
509 |
-
"\n",
|
510 |
-
"4. **Fourth cup: \"Some cups have no beer.\"**\n",
|
511 |
-
" - If this statement is true, then at least one cup does not contain beer. If this is true, it contradicts the first cup's statement (\"Beer is in all cups\"), which would mean that more than one statement is true. Therefore, this statement cannot be true.\n",
|
512 |
-
"\n",
|
513 |
-
"Now, let's analyze the implications of the second and third cups being true:\n",
|
514 |
-
"\n",
|
515 |
-
"- If the **second cup** is true (\"Cola in this cup\"), then:\n",
|
516 |
-
" - The first cup is false (not all cups have beer).\n",
|
517 |
-
" - The third cup could still be true or false.\n",
|
518 |
-
" - The fourth cup could still be true or false.\n",
|
519 |
-
"\n",
|
520 |
-
"- If the **third cup** is true (\"No coffee in this cup\"), then:\n",
|
521 |
-
" - The first cup is false (not all cups have beer).\n",
|
522 |
-
" - The second cup could still be true or false.\n",
|
523 |
-
" - The fourth cup could still be true or false.\n",
|
524 |
-
"\n",
|
525 |
-
"Since we need to find a scenario where only one statement is true, we can conclude:\n",
|
526 |
-
"\n",
|
527 |
-
"- If the second cup is true, then the first cup is false, and the fourth cup must also be false (which means all cups have beer, contradicting the second cup). This leads to a contradiction.\n",
|
528 |
-
"- If the third cup is true, then the first cup is false, and the fourth cup must also be false (which means all cups have beer, contradicting the third cup). This leads to a contradiction.\n",
|
529 |
-
"\n",
|
530 |
-
"Thus, the only consistent scenario is that the **second cup** is true, which means:\n",
|
531 |
-
"\n",
|
532 |
-
"**B. No cola in all cups** is the only true statement.\n",
|
533 |
-
"\n",
|
534 |
-
"So, the answer is **B. No cola in all cups**."
|
535 |
-
]
|
536 |
-
}
|
537 |
-
],
|
538 |
-
"metadata": {
|
539 |
-
"accelerator": "GPU",
|
540 |
-
"application/vnd.databricks.v1+notebook": {
|
541 |
-
"dashboards": [],
|
542 |
-
"environmentMetadata": null,
|
543 |
-
"language": "python",
|
544 |
-
"notebookMetadata": {
|
545 |
-
"pythonIndentUnit": 4
|
546 |
-
},
|
547 |
-
"notebookName": "07_MAC_+_Qwen2-7B-Instructi_Unsloth_train",
|
548 |
-
"widgets": {}
|
549 |
-
},
|
550 |
-
"colab": {
|
551 |
-
"gpuType": "T4",
|
552 |
-
"provenance": []
|
553 |
-
},
|
554 |
-
"kernelspec": {
|
555 |
-
"display_name": "Python 3",
|
556 |
-
"name": "python3"
|
557 |
-
},
|
558 |
-
"language_info": {
|
559 |
-
"codemirror_mode": {
|
560 |
-
"name": "ipython",
|
561 |
-
"version": 3
|
562 |
-
},
|
563 |
-
"file_extension": ".py",
|
564 |
-
"mimetype": "text/x-python",
|
565 |
-
"name": "python",
|
566 |
-
"nbconvert_exporter": "python",
|
567 |
-
"pygments_lexer": "ipython3",
|
568 |
-
"version": "3.11.9"
|
569 |
-
}
|
570 |
-
},
|
571 |
-
"nbformat": 4,
|
572 |
-
"nbformat_minor": 0
|
573 |
-
}
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:db8c9a6335e41f585ee6277c06ddba7139bc375aa001d21c60393aedfce1fcb0
|
3 |
+
size 29258
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
notebooks/05_Few-shot_Prompting_Anthropic.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/05b_Anthropic-Models_analysis.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/06_Few-shot_Prompting_Open_Source.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/06b_Open-Source-Models_analysis.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/07_Qwen2.5_models.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|