DSPy: The framework for programming—not prompting—language models
Python
work on func
Thomas D Ahle4928369f7989
diff --git a/dspy/functional/functional.py b/dspy/functional/functional.pyindex 5bb7d8eff..7a6a196ee 100644--- a/dspy/functional/functional.py+++ b/dspy/functional/functional.py@@ -4,21 +4,40 @@ import typingfrom dsp.templates import passages2textimport json+from dspy.signatures.signature import ensure_signature+MAX_RETRIES = 3def predictor(func):signature = _func_to_signature(func)- return TypedPredictor(signature, chain_of_thought=False, simple_output=True)+ *_, output_key = signature.output_fields.keys()+ return _StripOutput(TypedPredictor(signature), output_key)def cot(func):signature = _func_to_signature(func)- return TypedPredictor(signature, chain_of_thought=True, simple_output=True)+ *_, output_key = signature.output_fields.keys()+ return _StripOutput(TypedChainOfThought(signature), output_key)+++class _StripOutput(dspy.Module):+ def __init__(self, predictor, output_key):+ super().__init__()+ self.predictor = predictor+ self.output_key = output_key++ def copy(self):+ return _StripOutput(self.predictor.copy(), self.output_key)++ def forward(self, **kwargs):+ prediction = self.predictor(**kwargs)+ return prediction[self.output_key]class FunctionalModule(dspy.Module):+ """ To use the @cot and @predictor decorators, your module needs to inheret form this class. """def __init__(self):super().__init__()for name in dir(self):@@ -27,19 +46,28 @@ class FunctionalModule(dspy.Module):self.__dict__[name] = attr.copy()+def TypedChainOfThought(signature, make_example=False):+ """ Just like TypedPredictor, but adds a ChainOfThought OutputField. """+ signature = ensure_signature(signature)+ output_keys = ", ".join(signature.output_fields.keys())+ return TypedPredictor(signature.prepend(+ "reasoning",+ dspy.OutputField(+ prefix="Reasoning: Let's think step by step in order to",+ desc="${produce the " + output_keys + "}. We ...",+ ),+ ), make_example)++class TypedPredictor(dspy.Module):- def __init__(- self, signature, chain_of_thought=False, simple_output=False, make_example=False- ):+ def __init__(self, signature, make_example=False):super().__init__()self.signature = signatureself.predictor = dspy.Predict(signature)- self.chain_of_thought = chain_of_thought- self.simple_output = simple_outputself.make_example = make_exampledef copy(self):- return TypedPredictor(self.signature, self.chain_of_thought, self.simple_output)+ return TypedPredictor(self.signature, self.make_example)@staticmethoddef _make_example(type_):@@ -103,15 +131,6 @@ class TypedPredictor(dspy.Module):format = lambda x: x if isinstance(x, str) else x.model_dump_json()signature = signature.with_updated_fields(name, format=format)- if self.chain_of_thought:- output_keys = ", ".join(signature.output_fields.keys())- signature = signature.prepend(- "reasoning",- dspy.OutputField(- prefix="Reasoning: Let's think step by step in order to",- desc="${produce the " + output_keys + "}. We ...",- ),- )return signaturedef forward(self, **kwargs):@@ -145,9 +164,6 @@ class TypedPredictor(dspy.Module):# If there are no errors, we return the parsed resultsfor name, value in parsed_results.items():setattr(result, name, value)- if self.simple_output:- *_, last_output = signature.output_fields.keys()- return result[last_output]return resultraise ValueError("Too many retries")diff --git a/dspy/teleprompt/signature_opt_llmo b/dspy/teleprompt/signature_opt_llmonew file mode 100644index 000000000..152777f6f--- /dev/null+++ b/dspy/teleprompt/signature_opt_llmo@@ -0,0 +1,10 @@+from dspy.teleprompt.teleprompt import Teleprompter++class SignatureOptimizerLLMO(Teleprompter):+ def __init__(self, evaluate):+ super().__init__()+ self.evaluate = evaluate++ def compile(self, module):+ for predictor in module.predictors():+ predictor.signature\ No newline at end of filediff --git a/examples/functional/functional.ipynb b/examples/functional/functional.ipynbindex 611cc15c4..0dcbef5dc 100644--- a/examples/functional/functional.ipynb+++ b/examples/functional/functional.ipynb@@ -2,9 +2,50 @@"cells": [{"cell_type": "code",- "execution_count": null,+ "execution_count": 1,"metadata": {},- "outputs": [],+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Requirement already satisfied: datasets in /opt/homebrew/lib/python3.11/site-packages (2.14.7)\n",+ "Requirement already satisfied: numpy>=1.17 in /opt/homebrew/lib/python3.11/site-packages (from datasets) (1.26.2)\n",+ "Requirement already satisfied: pyarrow>=8.0.0 in /opt/homebrew/lib/python3.11/site-packages (from datasets) (12.0.0)\n",+ "Requirement already satisfied: pyarrow-hotfix in /opt/homebrew/lib/python3.11/site-packages (from datasets) (0.6)\n",+ "Requirement already satisfied: dill<0.3.8,>=0.3.0 in /opt/homebrew/lib/python3.11/site-packages (from datasets) (0.3.6)\n",+ "Requirement already satisfied: pandas in /opt/homebrew/lib/python3.11/site-packages (from datasets) (2.1.4)\n",+ "Requirement already satisfied: requests>=2.19.0 in /opt/homebrew/lib/python3.11/site-packages (from datasets) (2.31.0)\n",+ "Requirement already satisfied: tqdm>=4.62.1 in /opt/homebrew/lib/python3.11/site-packages (from datasets) (4.66.1)\n",+ "Requirement already satisfied: xxhash in /opt/homebrew/lib/python3.11/site-packages (from datasets) (3.2.0)\n",+ "Requirement already satisfied: multiprocess in /opt/homebrew/lib/python3.11/site-packages (from datasets) (0.70.14)\n",+ "Requirement already satisfied: fsspec<=2023.10.0,>=2023.1.0 in /opt/homebrew/lib/python3.11/site-packages (from fsspec[http]<=2023.10.0,>=2023.1.0->datasets) (2023.10.0)\n",+ "Requirement already satisfied: aiohttp in /opt/homebrew/lib/python3.11/site-packages (from datasets) (3.9.1)\n",+ "Requirement already satisfied: huggingface-hub<1.0.0,>=0.14.0 in /opt/homebrew/lib/python3.11/site-packages (from datasets) (0.19.4)\n",+ "Requirement already satisfied: packaging in /opt/homebrew/lib/python3.11/site-packages (from datasets) (23.2)\n",+ "Requirement already satisfied: pyyaml>=5.1 in /opt/homebrew/lib/python3.11/site-packages (from datasets) (6.0.1)\n",+ "Requirement already satisfied: attrs>=17.3.0 in /opt/homebrew/lib/python3.11/site-packages (from aiohttp->datasets) (23.1.0)\n",+ "Requirement already satisfied: multidict<7.0,>=4.5 in /opt/homebrew/lib/python3.11/site-packages (from aiohttp->datasets) (6.0.4)\n",+ "Requirement already satisfied: yarl<2.0,>=1.0 in /opt/homebrew/lib/python3.11/site-packages (from aiohttp->datasets) (1.9.3)\n",+ "Requirement already satisfied: frozenlist>=1.1.1 in /opt/homebrew/lib/python3.11/site-packages (from aiohttp->datasets) (1.4.0)\n",+ "Requirement already satisfied: aiosignal>=1.1.2 in /opt/homebrew/lib/python3.11/site-packages (from aiohttp->datasets) (1.3.1)\n",+ "Requirement already satisfied: filelock in /opt/homebrew/lib/python3.11/site-packages (from huggingface-hub<1.0.0,>=0.14.0->datasets) (3.13.1)\n",+ "Requirement already satisfied: typing-extensions>=3.7.4.3 in /opt/homebrew/lib/python3.11/site-packages (from huggingface-hub<1.0.0,>=0.14.0->datasets) (4.8.0)\n",+ "Requirement already satisfied: charset-normalizer<4,>=2 in /opt/homebrew/lib/python3.11/site-packages (from requests>=2.19.0->datasets) (3.3.2)\n",+ "Requirement already satisfied: idna<4,>=2.5 in /opt/homebrew/lib/python3.11/site-packages (from requests>=2.19.0->datasets) (3.6)\n",+ "Requirement already satisfied: urllib3<3,>=1.21.1 in /opt/homebrew/lib/python3.11/site-packages (from requests>=2.19.0->datasets) (2.1.0)\n",+ "Requirement already satisfied: certifi>=2017.4.17 in /opt/homebrew/lib/python3.11/site-packages (from requests>=2.19.0->datasets) (2023.11.17)\n",+ "Requirement already satisfied: python-dateutil>=2.8.2 in /opt/homebrew/lib/python3.11/site-packages (from pandas->datasets) (2.8.2)\n",+ "Requirement already satisfied: pytz>=2020.1 in /opt/homebrew/lib/python3.11/site-packages (from pandas->datasets) (2023.3)\n",+ "Requirement already satisfied: tzdata>=2022.1 in /opt/homebrew/lib/python3.11/site-packages (from pandas->datasets) (2023.3)\n",+ "Requirement already satisfied: six>=1.5 in /opt/homebrew/lib/python3.11/site-packages (from python-dateutil>=2.8.2->pandas->datasets) (1.16.0)\n",+ "\n",+ "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.0\u001b[0m\n",+ "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython3.11 -m pip install --upgrade pip\u001b[0m\n",+ "Note: you may need to restart the kernel to use updated packages.\n"+ ]+ }+ ],"source": ["%load_ext autoreload\n","%autoreload 2\n",@@ -101,7 +142,6 @@"output_type": "stream","text": ["Prediction(\n",- " reasoning='produce the solution. We need to ensure that the JSON object we provide is valid and follows the specified schema. The error message indicates that there are trailing characters in the JSON object, which is causing it to be invalid. To avoid this error in the future, we need to make sure that the JSON object is correctly formatted and does not contain any additional characters outside of the specified structure.',\n"," solution=PythonCode(code='def has_close_elements(numbers: List[float], threshold: float) -> bool:\\n for i in range(len(numbers)):\\n for j in range(i+1, len(numbers)):\\n if abs(numbers[i] - numbers[j]) < threshold:\\n return True\\n return False')\n",")\n"]@@ -135,7 +175,7 @@" entry_point: str = InputField()\n"," solution: PythonCode = OutputField()\n","\n",- "predictor = TypedPredictor(CodeSignature, chain_of_thought=True, make_example=True)\n",+ "predictor = TypedPredictor(CodeSignature, make_example=True)\n","prediction = predictor(\n"," prompt=PythonCode(code=ds['test'][0]['prompt']),\n"," test=PythonCode(code=ds['test'][0]['test']),\n",@@ -197,8 +237,6 @@"\n","Entry Point: ${entry_point}\n","\n",- "Reasoning: Let's think step by step in order to ${produce the solution}. We ...\n",- "\n","Solution: ${solution}. Respond with a single JSON object using the schema {\"properties\": {\"code\": {\"title\": \"Code\", \"type\": \"string\"}}, \"required\": [\"code\"], \"title\": \"PythonCode\", \"type\": \"object\"}. For example: {\"code\": \"print('Hello, World!')\"}\n","\n","---\n",@@ -209,9 +247,9 @@"\n","Entry Point: has_close_elements\n","\n",- "Reasoning: Let's think step by step in order to\u001b[32m produce the solution. We need to iterate through the list of numbers and compare each pair of numbers to see if their absolute difference is less than the threshold.\n",+ "Solution:\u001b[32m {\"properties\": {\"code\": {\"title\": \"Code\", \"type\": \"string\"}}, \"required\": [\"code\"], \"title\": \"PythonCode\", \"type\": \"object\"}\n","\n",- "Solution: {\"properties\": {\"code\": {\"title\": \"Code\", \"type\": \"string\"}}, \"required\": [\"code\"], \"title\": \"PythonCode\", \"type\": \"object\"}. For example: {\"code\": \"from typing import List\\n\\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\\n for i in range(len(numbers)):\\n for j in range(i+1, len(numbers)):\\n if abs(numbers[i] - numbers[j]) < threshold:\\n return True\\n return False\"}\u001b[0m\n",+ "{\"code\": \"from typing import List\\n\\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\\n for i in range(len(numbers)):\\n for j in range(i+1, len(numbers)):\\n if abs(numbers[i] - numbers[j]) < threshold:\\n return True\\n return False\"}\u001b[0m\n","\n","\n","\n",@@ -233,8 +271,6 @@"\n","Past Error (solution): An error to avoid in the future\n","\n",- "Reasoning: Let's think step by step in order to ${produce the solution}. We ...\n",- "\n","Solution: ${solution}. Respond with a single JSON object using the schema {\"properties\": {\"code\": {\"title\": \"Code\", \"type\": \"string\"}}, \"required\": [\"code\"], \"title\": \"PythonCode\", \"type\": \"object\"}. For example: {\"code\": \"print('Hello, World!')\"}\n","\n","---\n",@@ -245,11 +281,9 @@"\n","Entry Point: has_close_elements\n","\n",- "Past Error (solution): 1 validation error for PythonCode Invalid JSON: trailing characters at line 1 column 125 [type=json_invalid, input_value='{\"properties\": {\"code\": ...ue\\\\n return False\"}', input_type=str] For further information visit https://errors.pydantic.dev/2.5/v/json_invalid\n",- "\n",- "Reasoning: Let's think step by step in order to\u001b[32m produce the solution. We need to ensure that the JSON object we provide is valid and follows the specified schema. The error message indicates that there are trailing characters in the JSON object, which is causing it to be invalid. To avoid this error in the future, we need to make sure that the JSON object is correctly formatted and does not contain any additional characters outside of the specified structure.\n",+ "Past Error (solution): 1 validation error for PythonCode Invalid JSON: trailing characters at line 3 column 1 [type=json_invalid, input_value='{\"properties\": {\"code\": ...ue\\\\n return False\"}', input_type=str] For further information visit https://errors.pydantic.dev/2.5/v/json_invalid\n","\n",- "Solution: {\"code\": \"def has_close_elements(numbers: List[float], threshold: float) -> bool:\\n for i in range(len(numbers)):\\n for j in range(i+1, len(numbers)):\\n if abs(numbers[i] - numbers[j]) < threshold:\\n return True\\n return False\"}\u001b[0m\n",+ "Solution:\u001b[32m {\"code\": \"def has_close_elements(numbers: List[float], threshold: float) -> bool:\\n for i in range(len(numbers)):\\n for j in range(i+1, len(numbers)):\\n if abs(numbers[i] - numbers[j]) < threshold:\\n return True\\n return False\"}\u001b[0m\n","\n","\n","\n"@@ -332,22 +366,28 @@"trainset = devset[:40]\n","testset = devset[40:]\n","\n",- "def metric(example, pred, trace=None):\n",- " if pred.solution.code is None:\n",- " return 0\n",- " error = execute_code(\n",- " \"from typing import List\\n\"\n",- " + f\"{pred.solution.code}\\n\"\n",- " + f\"{example.test.code}\\n\"\n",- " + f\"check({example.entry_point})\"\n",- " )\n",- " return int(error is None)\n",+ "def test_code(timeout=5):\n",+ " def metric(example, pred, trace=None):\n",+ " if pred.solution.code is None:\n",+ " return 0\n",+ " error = execute_code(\n",+ " \"from typing import List\\n\"\n",+ " + f\"{pred.solution.code}\\n\"\n",+ " + f\"{example.test.code}\\n\"\n",+ " + f\"check({example.entry_point})\",\n",+ " timeout=timeout,\n",+ " )\n",+ " return int(error is None)\n",+ " return metric\n",+ "\n",+ "metric5s = test_code(timeout=5)\n","\n","print(\"Score with the original model:\")\n",- "print(100 * sum(metric(example, example) for example in testset) / len(testset))\n",+ "metrix = test_code(timeout=5)\n",+ "print(100 * sum(metric5s(example, example) for example in testset) / len(testset))\n","\n","for example in devset:\n",- " if not metric(example, example):\n",+ " if not metric5s(example, example):\n"," print(\"Bad example:\")\n"," code = (\n"," \"from typing import List\\n\"\n",@@ -384,21 +424,7 @@"name": "stderr","output_type": "stream","text": [- "Average Metric: 0.0 / 1 (0.0): 0%| | 0/124 [00:00<?, ?it/s]"- ]- },- {- "name": "stdout",- "output_type": "stream",- "text": [- "Error for example in dev set: \t\t Too many retries\n"- ]- },- {- "name": "stderr",- "output_type": "stream",- "text": [- "Average Metric: 0.0 / 2 (0.0): 1%| | 1/124 [00:00<00:01, 66.59it/s]"+ " 0%| | 0/124 [00:00<?, ?it/s]"]},{@@ -412,7 +438,7 @@"name": "stderr","output_type": "stream","text": [- "Average Metric: 0.0 / 3 (0.0): 2%|▏ | 2/124 [00:00<00:01, 81.27it/s]"+ "Average Metric: 0.0 / 3 (0.0): 2%|▏ | 2/124 [00:00<00:01, 77.99it/s]"]},{@@ -426,7 +452,7 @@"name": "stderr","output_type": "stream","text": [- "Average Metric: 7.0 / 14 (50.0): 10%|█ | 13/124 [00:00<00:02, 49.54it/s]"+ "Average Metric: 24.0 / 37 (64.9): 29%|██▉ | 36/124 [00:00<00:01, 81.56it/s]"]},{@@ -440,7 +466,7 @@"name": "stderr","output_type": "stream","text": [- "Average Metric: 14.0 / 21 (66.7): 16%|█▌ | 20/124 [00:00<00:02, 49.54it/s]"+ "Average Metric: 25.0 / 40 (62.5): 31%|███▏ | 39/124 [00:00<00:01, 81.56it/s]"]},{@@ -454,50 +480,7 @@"name": "stderr","output_type": "stream","text": [- "Average Metric: 17.0 / 24 (70.8): 19%|█▊ | 23/124 [00:00<00:02, 49.54it/s]"- ]- },- {- "name": "stdout",- "output_type": "stream",- "text": [- "Error for example in dev set: \t\t Too many retries\n"- ]- },- {- "name": "stderr",- "output_type": "stream",- "text": [- "Average Metric: 29.0 / 41 (70.7): 32%|███▏ | 40/124 [00:00<00:01, 69.00it/s]"- ]- },- {- "name": "stdout",- "output_type": "stream",- "text": [- "Error for example in dev set: \t\t Too many retries\n",- "Error for example in dev set: \t\t Too many retries\n"- ]- },- {- "name": "stderr",- "output_type": "stream",- "text": [- "Average Metric: 34.0 / 55 (61.8): 44%|████▎ | 54/124 [00:00<00:01, 68.27it/s]"- ]- },- {- "name": "stdout",- "output_type": "stream",- "text": [- "Error for example in dev set: \t\t Too many retries\n"- ]- },- {- "name": "stderr",- "output_type": "stream",- "text": [- "Average Metric: 38.0 / 67 (56.7): 54%|█████▍ | 67/124 [00:01<00:00, 60.79it/s]"+ "Average Metric: 45.0 / 80 (56.2): 64%|██████▎ | 79/124 [00:00<00:00, 109.09it/s]"]},{@@ -511,7 +494,7 @@"name": "stderr","output_type": "stream","text": [- "Average Metric: 40.0 / 70 (57.1): 56%|█████▌ | 69/124 [00:01<00:00, 60.79it/s]"+ "Average Metric: 45.0 / 81 (55.6): 65%|██████▍ | 80/124 [00:00<00:00, 109.09it/s]"]},{@@ -525,21 +508,23 @@"name": "stderr","output_type": "stream","text": [- "Average Metric: 41.0 / 73 (56.2): 58%|█████▊ | 72/124 [00:01<00:00, 60.79it/s]"+ "Average Metric: 64.0 / 119 (53.8): 95%|█████████▌| 118/124 [00:01<00:00, 110.58it/s]"]},{"name": "stdout","output_type": "stream","text": [- "Error for example in dev set: \t\t Too many retries\n"+ "37\n",+ "15\n",+ "8\n"]},{"name": "stderr","output_type": "stream","text": [- "Average Metric: 62.0 / 124 (50.0): 100%|██████████| 124/124 [00:01<00:00, 92.27it/s]\n",+ "Average Metric: 66.0 / 124 (53.2): 100%|██████████| 124/124 [00:01<00:00, 116.06it/s]\n","/Users/ahle/repos/dspy/dspy/evaluate/evaluate.py:143: FutureWarning: DataFrame.applymap has been deprecated. Use DataFrame.map instead.\n"," df = df.applymap(truncate_cell)\n"]@@ -548,101 +533,95 @@"name": "stdout","output_type": "stream","text": [- "Average Metric: 62.0 / 124 (50.0%)\n"+ "Average Metric: 66.0 / 124 (53.2%)\n"]},{"data": {"text/html": ["<style type=\"text/css\">\n",- "#T_3b532 th {\n",+ "#T_ac8ed th {\n"," text-align: left;\n","}\n",- "#T_3b532 td {\n",+ "#T_ac8ed td {\n"," text-align: left;\n","}\n",- "#T_3b532_row0_col0, #T_3b532_row0_col1, #T_3b532_row0_col2, #T_3b532_row0_col3, #T_3b532_row0_col4, #T_3b532_row0_col5, #T_3b532_row0_col6, #T_3b532_row0_col7, #T_3b532_row1_col0, #T_3b532_row1_col1, #T_3b532_row1_col2, #T_3b532_row1_col3, #T_3b532_row1_col4, #T_3b532_row1_col5, #T_3b532_row1_col6, #T_3b532_row1_col7, #T_3b532_row2_col0, #T_3b532_row2_col1, #T_3b532_row2_col2, #T_3b532_row2_col3, #T_3b532_row2_col4, #T_3b532_row2_col5, #T_3b532_row2_col6, #T_3b532_row2_col7, #T_3b532_row3_col0, #T_3b532_row3_col1, #T_3b532_row3_col2, #T_3b532_row3_col3, #T_3b532_row3_col4, #T_3b532_row3_col5, #T_3b532_row3_col6, #T_3b532_row3_col7, #T_3b532_row4_col0, #T_3b532_row4_col1, #T_3b532_row4_col2, #T_3b532_row4_col3, #T_3b532_row4_col4, #T_3b532_row4_col5, #T_3b532_row4_col6, #T_3b532_row4_col7 {\n",+ "#T_ac8ed_row0_col0, #T_ac8ed_row0_col1, #T_ac8ed_row0_col2, #T_ac8ed_row0_col3, #T_ac8ed_row0_col4, #T_ac8ed_row0_col5, #T_ac8ed_row0_col6, #T_ac8ed_row1_col0, #T_ac8ed_row1_col1, #T_ac8ed_row1_col2, #T_ac8ed_row1_col3, #T_ac8ed_row1_col4, #T_ac8ed_row1_col5, #T_ac8ed_row1_col6, #T_ac8ed_row2_col0, #T_ac8ed_row2_col1, #T_ac8ed_row2_col2, #T_ac8ed_row2_col3, #T_ac8ed_row2_col4, #T_ac8ed_row2_col5, #T_ac8ed_row2_col6, #T_ac8ed_row3_col0, #T_ac8ed_row3_col1, #T_ac8ed_row3_col2, #T_ac8ed_row3_col3, #T_ac8ed_row3_col4, #T_ac8ed_row3_col5, #T_ac8ed_row3_col6, #T_ac8ed_row4_col0, #T_ac8ed_row4_col1, #T_ac8ed_row4_col2, #T_ac8ed_row4_col3, #T_ac8ed_row4_col4, #T_ac8ed_row4_col5, #T_ac8ed_row4_col6 {\n"," text-align: left;\n"," white-space: pre-wrap;\n"," word-wrap: break-word;\n"," max-width: 400px;\n","}\n","</style>\n",- "<table id=\"T_3b532\">\n",+ "<table id=\"T_ac8ed\">\n"," <thead>\n"," <tr>\n"," <th class=\"blank level0\" > </th>\n",- " <th id=\"T_3b532_level0_col0\" class=\"col_heading level0 col0\" >prompt</th>\n",- " <th id=\"T_3b532_level0_col1\" class=\"col_heading level0 col1\" >test</th>\n",- " <th id=\"T_3b532_level0_col2\" class=\"col_heading level0 col2\" >entry_point</th>\n",- " <th id=\"T_3b532_level0_col3\" class=\"col_heading level0 col3\" >example_solution</th>\n",- " <th id=\"T_3b532_level0_col4\" class=\"col_heading level0 col4\" >reasoning</th>\n",- " <th id=\"T_3b532_level0_col5\" class=\"col_heading level0 col5\" >pred_solution</th>\n",- " <th id=\"T_3b532_level0_col6\" class=\"col_heading level0 col6\" >metric</th>\n",- " <th id=\"T_3b532_level0_col7\" class=\"col_heading level0 col7\" >solution</th>\n",+ " <th id=\"T_ac8ed_level0_col0\" class=\"col_heading level0 col0\" >prompt</th>\n",+ " <th id=\"T_ac8ed_level0_col1\" class=\"col_heading level0 col1\" >test</th>\n",+ " <th id=\"T_ac8ed_level0_col2\" class=\"col_heading level0 col2\" >entry_point</th>\n",+ " <th id=\"T_ac8ed_level0_col3\" class=\"col_heading level0 col3\" >example_solution</th>\n",+ " <th id=\"T_ac8ed_level0_col4\" class=\"col_heading level0 col4\" >pred_solution</th>\n",+ " <th id=\"T_ac8ed_level0_col5\" class=\"col_heading level0 col5\" >metric</th>\n",+ " <th id=\"T_ac8ed_level0_col6\" class=\"col_heading level0 col6\" >solution</th>\n"," </tr>\n"," </thead>\n"," <tbody>\n"," <tr>\n",- " <th id=\"T_3b532_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n",- " <td id=\"T_3b532_row0_col0\" class=\"data row0 col0\" >code='\\n\\ndef triples_sum_to_zero(l: list):\\n \"\"\"\\n triples_sum_to_zero takes a list of integers as an input.\\n it returns True if there are three distinct elements in the list...</td>\n",- " <td id=\"T_3b532_row0_col1\" class=\"data row0 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate([1, 3, 5, 0]) == False\\n assert candidate([1, 3, 5, -1]) == False\\n assert candidate([1, 3, -2, 1]) == True\\n...</td>\n",- " <td id=\"T_3b532_row0_col2\" class=\"data row0 col2\" >triples_sum_to_zero</td>\n",- " <td id=\"T_3b532_row0_col3\" class=\"data row0 col3\" >code='\\n\\ndef triples_sum_to_zero(l: list):\\n \"\"\"\\n triples_sum_to_zero takes a list of integers as an input.\\n it returns True if there are three distinct elements in the list...</td>\n",- " <td id=\"T_3b532_row0_col4\" class=\"data row0 col4\" >produce the solution. We need to ensure that the JSON object we provide is valid and follows the specified schema. The error message indicates that...</td>\n",- " <td id=\"T_3b532_row0_col5\" class=\"data row0 col5\" >code='def triples_sum_to_zero(l: list):\\n for i in range(len(l)):\\n for j in range(i+1, len(l)):\\n for k in range(j+1, len(l)):\\n if l[i] + l[j] + l[k] == 0:\\n...</td>\n",- " <td id=\"T_3b532_row0_col6\" class=\"data row0 col6\" >0.0</td>\n",- " <td id=\"T_3b532_row0_col7\" class=\"data row0 col7\" >nan</td>\n",+ " <th id=\"T_ac8ed_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n",+ " <td id=\"T_ac8ed_row0_col0\" class=\"data row0 col0\" >code='\\n\\ndef triples_sum_to_zero(l: list):\\n \"\"\"\\n triples_sum_to_zero takes a list of integers as an input.\\n it returns True if there are three distinct elements in the list...</td>\n",+ " <td id=\"T_ac8ed_row0_col1\" class=\"data row0 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate([1, 3, 5, 0]) == False\\n assert candidate([1, 3, 5, -1]) == False\\n assert candidate([1, 3, -2, 1]) == True\\n...</td>\n",+ " <td id=\"T_ac8ed_row0_col2\" class=\"data row0 col2\" >triples_sum_to_zero</td>\n",+ " <td id=\"T_ac8ed_row0_col3\" class=\"data row0 col3\" >code='\\n\\ndef triples_sum_to_zero(l: list):\\n \"\"\"\\n triples_sum_to_zero takes a list of integers as an input.\\n it returns True if there are three distinct elements in the list...</td>\n",+ " <td id=\"T_ac8ed_row0_col4\" class=\"data row0 col4\" >code='def triples_sum_to_zero(l: list):\\n for i in range(len(l)):\\n for j in range(i+1, len(l)):\\n for k in range(j+1, len(l)):\\n if l[i] + l[j] + l[k] == 0:\\n...</td>\n",+ " <td id=\"T_ac8ed_row0_col5\" class=\"data row0 col5\" >1.0</td>\n",+ " <td id=\"T_ac8ed_row0_col6\" class=\"data row0 col6\" >nan</td>\n"," </tr>\n"," <tr>\n",- " <th id=\"T_3b532_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n",- " <td id=\"T_3b532_row1_col0\" class=\"data row1 col0\" >code='\\n\\ndef car_race_collision(n: int):\\n \"\"\"\\n Imagine a road that\\'s a perfectly straight infinitely long line.\\n n cars are driving left to right; simultaneously, a different set...</td>\n",- " <td id=\"T_3b532_row1_col1\" class=\"data row1 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate(2) == 4\\n assert candidate(3) == 9\\n assert candidate(4) == 16\\n assert candidate(8) == 64\\n assert candidate(10) == 100\\n\\n'</td>\n",- " <td id=\"T_3b532_row1_col2\" class=\"data row1 col2\" >car_race_collision</td>\n",- " <td id=\"T_3b532_row1_col3\" class=\"data row1 col3\" >code='\\n\\ndef car_race_collision(n: int):\\n \"\"\"\\n Imagine a road that\\'s a perfectly straight infinitely long line.\\n n cars are driving left to right; simultaneously, a different set...</td>\n",- " <td id=\"T_3b532_row1_col4\" class=\"data row1 col4\" >produce the solution. We need to ensure that the code provided is valid JSON format. The error message indicates that there are trailing characters at...</td>\n",- " <td id=\"T_3b532_row1_col5\" class=\"data row1 col5\" >code='def car_race_collision(n: int):\\n return n ** 2'</td>\n",- " <td id=\"T_3b532_row1_col6\" class=\"data row1 col6\" >1.0</td>\n",- " <td id=\"T_3b532_row1_col7\" class=\"data row1 col7\" >nan</td>\n",+ " <th id=\"T_ac8ed_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n",+ " <td id=\"T_ac8ed_row1_col0\" class=\"data row1 col0\" >code='\\n\\ndef car_race_collision(n: int):\\n \"\"\"\\n Imagine a road that\\'s a perfectly straight infinitely long line.\\n n cars are driving left to right; simultaneously, a different set...</td>\n",+ " <td id=\"T_ac8ed_row1_col1\" class=\"data row1 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate(2) == 4\\n assert candidate(3) == 9\\n assert candidate(4) == 16\\n assert candidate(8) == 64\\n assert candidate(10) == 100\\n\\n'</td>\n",+ " <td id=\"T_ac8ed_row1_col2\" class=\"data row1 col2\" >car_race_collision</td>\n",+ " <td id=\"T_ac8ed_row1_col3\" class=\"data row1 col3\" >code='\\n\\ndef car_race_collision(n: int):\\n \"\"\"\\n Imagine a road that\\'s a perfectly straight infinitely long line.\\n n cars are driving left to right; simultaneously, a different set...</td>\n",+ " <td id=\"T_ac8ed_row1_col4\" class=\"data row1 col4\" >code='def car_race_collision(n: int):\\n return n ** 2'</td>\n",+ " <td id=\"T_ac8ed_row1_col5\" class=\"data row1 col5\" >1.0</td>\n",+ " <td id=\"T_ac8ed_row1_col6\" class=\"data row1 col6\" >nan</td>\n"," </tr>\n"," <tr>\n",- " <th id=\"T_3b532_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n",- " <td id=\"T_3b532_row2_col0\" class=\"data row2 col0\" >code='\\n\\ndef incr_list(l: list):\\n \"\"\"Return list with elements incremented by 1.\\n >>> incr_list([1, 2, 3])\\n [2, 3, 4]\\n >>> incr_list([5, 3, 5, 2, 3, 3, 9,...</td>\n",- " <td id=\"T_3b532_row2_col1\" class=\"data row2 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate([]) == []\\n assert candidate([3, 2, 1]) == [4, 3, 2]\\n assert candidate([5, 2, 5, 2, 3, 3, 9, 0,...</td>\n",- " <td id=\"T_3b532_row2_col2\" class=\"data row2 col2\" >incr_list</td>\n",- " <td id=\"T_3b532_row2_col3\" class=\"data row2 col3\" >code='\\n\\ndef incr_list(l: list):\\n \"\"\"Return list with elements incremented by 1.\\n >>> incr_list([1, 2, 3])\\n [2, 3, 4]\\n >>> incr_list([5, 3, 5, 2, 3, 3, 9,...</td>\n",- " <td id=\"T_3b532_row2_col4\" class=\"data row2 col4\" >produce the solution. We need to ensure that the JSON object we provide follows the correct format and does not contain any trailing characters that...</td>\n",- " <td id=\"T_3b532_row2_col5\" class=\"data row2 col5\" >code='def incr_list(l: list):\\n return [x + 1 for x in l]'</td>\n",- " <td id=\"T_3b532_row2_col6\" class=\"data row2 col6\" >1.0</td>\n",- " <td id=\"T_3b532_row2_col7\" class=\"data row2 col7\" >nan</td>\n",+ " <th id=\"T_ac8ed_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n",+ " <td id=\"T_ac8ed_row2_col0\" class=\"data row2 col0\" >code='\\n\\ndef incr_list(l: list):\\n \"\"\"Return list with elements incremented by 1.\\n >>> incr_list([1, 2, 3])\\n [2, 3, 4]\\n >>> incr_list([5, 3, 5, 2, 3, 3, 9,...</td>\n",+ " <td id=\"T_ac8ed_row2_col1\" class=\"data row2 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate([]) == []\\n assert candidate([3, 2, 1]) == [4, 3, 2]\\n assert candidate([5, 2, 5, 2, 3, 3, 9, 0,...</td>\n",+ " <td id=\"T_ac8ed_row2_col2\" class=\"data row2 col2\" >incr_list</td>\n",+ " <td id=\"T_ac8ed_row2_col3\" class=\"data row2 col3\" >code='\\n\\ndef incr_list(l: list):\\n \"\"\"Return list with elements incremented by 1.\\n >>> incr_list([1, 2, 3])\\n [2, 3, 4]\\n >>> incr_list([5, 3, 5, 2, 3, 3, 9,...</td>\n",+ " <td id=\"T_ac8ed_row2_col4\" class=\"data row2 col4\" >code='def incr_list(l: list):\\n return [x + 1 for x in l]'</td>\n",+ " <td id=\"T_ac8ed_row2_col5\" class=\"data row2 col5\" >1.0</td>\n",+ " <td id=\"T_ac8ed_row2_col6\" class=\"data row2 col6\" >nan</td>\n"," </tr>\n"," <tr>\n",- " <th id=\"T_3b532_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n",- " <td id=\"T_3b532_row3_col0\" class=\"data row3 col0\" >code='\\n\\ndef pairs_sum_to_zero(l):\\n \"\"\"\\n pairs_sum_to_zero takes a list of integers as an input.\\n it returns True if there are two distinct elements in the list that\\n...</td>\n",- " <td id=\"T_3b532_row3_col1\" class=\"data row3 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate([1, 3, 5, 0]) == False\\n assert candidate([1, 3, -2, 1]) == False\\n assert candidate([1, 2, 3, 7]) == False\\n...</td>\n",- " <td id=\"T_3b532_row3_col2\" class=\"data row3 col2\" >pairs_sum_to_zero</td>\n",- " <td id=\"T_3b532_row3_col3\" class=\"data row3 col3\" >code='\\n\\ndef pairs_sum_to_zero(l):\\n \"\"\"\\n pairs_sum_to_zero takes a list of integers as an input.\\n it returns True if there are two distinct elements in the list that\\n...</td>\n",- " <td id=\"T_3b532_row3_col4\" class=\"data row3 col4\" >solve this issue. The error message indicates that there are trailing characters in the JSON object provided. To fix this, we need to ensure that...</td>\n",- " <td id=\"T_3b532_row3_col5\" class=\"data row3 col5\" >code='def pairs_sum_to_zero(l):\\n for i in range(len(l)):\\n for j in range(i+1, len(l)):\\n if l[i] + l[j] == 0:\\n return True\\n return False'</td>\n",- " <td id=\"T_3b532_row3_col6\" class=\"data row3 col6\" >1.0</td>\n",- " <td id=\"T_3b532_row3_col7\" class=\"data row3 col7\" >nan</td>\n",+ " <th id=\"T_ac8ed_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n",+ " <td id=\"T_ac8ed_row3_col0\" class=\"data row3 col0\" >code='\\n\\ndef pairs_sum_to_zero(l):\\n \"\"\"\\n pairs_sum_to_zero takes a list of integers as an input.\\n it returns True if there are two distinct elements in the list that\\n...</td>\n",+ " <td id=\"T_ac8ed_row3_col1\" class=\"data row3 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate([1, 3, 5, 0]) == False\\n assert candidate([1, 3, -2, 1]) == False\\n assert candidate([1, 2, 3, 7]) == False\\n...</td>\n",+ " <td id=\"T_ac8ed_row3_col2\" class=\"data row3 col2\" >pairs_sum_to_zero</td>\n",+ " <td id=\"T_ac8ed_row3_col3\" class=\"data row3 col3\" >code='\\n\\ndef pairs_sum_to_zero(l):\\n \"\"\"\\n pairs_sum_to_zero takes a list of integers as an input.\\n it returns True if there are two distinct elements in the list that\\n...</td>\n",+ " <td id=\"T_ac8ed_row3_col4\" class=\"data row3 col4\" >code='def pairs_sum_to_zero(l):\\n return any(-x in l for x in l if x != 0)\\n'</td>\n",+ " <td id=\"T_ac8ed_row3_col5\" class=\"data row3 col5\" >1.0</td>\n",+ " <td id=\"T_ac8ed_row3_col6\" class=\"data row3 col6\" >nan</td>\n"," </tr>\n"," <tr>\n",- " <th id=\"T_3b532_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n",- " <td id=\"T_3b532_row4_col0\" class=\"data row4 col0\" >code='\\n\\ndef change_base(x: int, base: int):\\n \"\"\"Change numerical base of input number x to base.\\n return string representation after the conversion.\\n base numbers are less than...</td>\n",- " <td id=\"T_3b532_row4_col1\" class=\"data row4 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate(8, 3) == \"22\"\\n assert candidate(9, 3) == \"100\"\\n assert candidate(234, 2) == \"11101010\"\\n assert candidate(16, 2) == \"10000\"\\n assert...</td>\n",- " <td id=\"T_3b532_row4_col2\" class=\"data row4 col2\" >change_base</td>\n",- " <td id=\"T_3b532_row4_col3\" class=\"data row4 col3\" >code='\\n\\ndef change_base(x: int, base: int):\\n \"\"\"Change numerical base of input number x to base.\\n return string representation after the conversion.\\n base numbers are less than...</td>\n",- " <td id=\"T_3b532_row4_col4\" class=\"data row4 col4\" >produce the solution. We need to ensure that the JSON object provided follows the correct format specified in the schema. The error message indicates that...</td>\n",- " <td id=\"T_3b532_row4_col5\" class=\"data row4 col5\" >code=\"def change_base(x: int, base: int):\\n result = ''\\n while x > 0:\\n result = str(x % base) + result\\n x //= base\\n return result\"</td>\n",- " <td id=\"T_3b532_row4_col6\" class=\"data row4 col6\" >1.0</td>\n",- " <td id=\"T_3b532_row4_col7\" class=\"data row4 col7\" >nan</td>\n",+ " <th id=\"T_ac8ed_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n",+ " <td id=\"T_ac8ed_row4_col0\" class=\"data row4 col0\" >code='\\n\\ndef change_base(x: int, base: int):\\n \"\"\"Change numerical base of input number x to base.\\n return string representation after the conversion.\\n base numbers are less than...</td>\n",+ " <td id=\"T_ac8ed_row4_col1\" class=\"data row4 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate(8, 3) == \"22\"\\n assert candidate(9, 3) == \"100\"\\n assert candidate(234, 2) == \"11101010\"\\n assert candidate(16, 2) == \"10000\"\\n assert...</td>\n",+ " <td id=\"T_ac8ed_row4_col2\" class=\"data row4 col2\" >change_base</td>\n",+ " <td id=\"T_ac8ed_row4_col3\" class=\"data row4 col3\" >code='\\n\\ndef change_base(x: int, base: int):\\n \"\"\"Change numerical base of input number x to base.\\n return string representation after the conversion.\\n base numbers are less than...</td>\n",+ " <td id=\"T_ac8ed_row4_col4\" class=\"data row4 col4\" >code='def change_base(x: int, base: int):\\n return str(int(str(x), base))'</td>\n",+ " <td id=\"T_ac8ed_row4_col5\" class=\"data row4 col5\" >0.0</td>\n",+ " <td id=\"T_ac8ed_row4_col6\" class=\"data row4 col6\" >nan</td>\n"," </tr>\n"," </tbody>\n","</table>\n"],"text/plain": [- "<pandas.io.formats.style.Styler at 0x1777bb350>"+ "<pandas.io.formats.style.Styler at 0x2b70c79d0>"]},"metadata": {},@@ -673,7 +652,7 @@"name": "stdout","output_type": "stream","text": [- "50.0\n"+ "53.23\n"]}],@@ -685,7 +664,7 @@" display_table=5,\n"," max_errors=100,\n",")\n",- "res = evaluator(predictor, metric)\n",+ "res = evaluator(predictor, metric5s)\n","print(res)"]},@@ -698,9 +677,291 @@},{"cell_type": "code",- "execution_count": null,+ "execution_count": 9,"metadata": {},- "outputs": [],+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Compiling...\n",+ "Going to sample between 1 and 4 traces per predictor.\n",+ "Will attempt to train 5 candidate sets.\n",+ "Error for example in dev set: \t\t Too many retries\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "Average Metric: 25.0 / 40 (62.5): 100%|██████████| 40/40 [00:01<00:00, 22.16it/s] \n",+ "/Users/ahle/repos/dspy/dspy/evaluate/evaluate.py:143: FutureWarning: DataFrame.applymap has been deprecated. Use DataFrame.map instead.\n",+ " df = df.applymap(truncate_cell)\n"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Average Metric: 25.0 / 40 (62.5%)\n",+ "Score: 62.5 for set: [0]\n",+ "New best score: 62.5 for seed -3\n",+ "Scores so far: [62.5]\n",+ "Best score: 62.5\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "Average Metric: 34.0 / 40 (85.0): 100%|██████████| 40/40 [00:18<00:00, 2.17it/s]\n"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Error for example in dev set: \t\t Too many retries\n",+ "Average Metric: 34.0 / 40 (85.0%)\n",+ "Score: 85.0 for set: [8]\n",+ "New best score: 85.0 for seed -2\n",+ "Scores so far: [62.5, 85.0]\n",+ "Best score: 85.0\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 10%|█ | 4/40 [00:02<00:19, 1.82it/s]\n"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Bootstrapped 4 full traces after 5 examples in round 0.\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "Average Metric: 33 / 40 (82.5): 100%|██████████| 40/40 [01:48<00:00, 2.72s/it] \n"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Average Metric: 33 / 40 (82.5%)\n",+ "Score: 82.5 for set: [8]\n",+ "Scores so far: [62.5, 85.0, 82.5]\n",+ "Best score: 85.0\n",+ "Average of max per entry across top 1 scores: 0.85\n",+ "Average of max per entry across top 2 scores: 0.975\n",+ "Average of max per entry across top 3 scores: 1.0\n",+ "Average of max per entry across top 5 scores: 1.0\n",+ "Average of max per entry across top 8 scores: 1.0\n",+ "Average of max per entry across top 9999 scores: 1.0\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 10%|█ | 4/40 [00:10<01:37, 2.70s/it]\n"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Bootstrapped 4 full traces after 5 examples in round 0.\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "Average Metric: 35 / 40 (87.5): 100%|██████████| 40/40 [00:12<00:00, 3.15it/s] \n"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Average Metric: 35 / 40 (87.5%)\n",+ "Score: 87.5 for set: [8]\n",+ "New best score: 87.5 for seed 0\n",+ "Scores so far: [62.5, 85.0, 82.5, 87.5]\n",+ "Best score: 87.5\n",+ "Average of max per entry across top 1 scores: 0.875\n",+ "Average of max per entry across top 2 scores: 0.975\n",+ "Average of max per entry across top 3 scores: 1.0\n",+ "Average of max per entry across top 5 scores: 1.0\n",+ "Average of max per entry across top 8 scores: 1.0\n",+ "Average of max per entry across top 9999 scores: 1.0\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 5%|▌ | 2/40 [00:03<01:07, 1.79s/it]\n"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Bootstrapped 2 full traces after 3 examples in round 0.\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "Average Metric: 36 / 40 (90.0): 100%|██████████| 40/40 [00:09<00:00, 4.35it/s] \n"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Average Metric: 36 / 40 (90.0%)\n",+ "Score: 90.0 for set: [8]\n",+ "New best score: 90.0 for seed 1\n",+ "Scores so far: [62.5, 85.0, 82.5, 87.5, 90.0]\n",+ "Best score: 90.0\n",+ "Average of max per entry across top 1 scores: 0.9\n",+ "Average of max per entry across top 2 scores: 0.95\n",+ "Average of max per entry across top 3 scores: 0.975\n",+ "Average of max per entry across top 5 scores: 1.0\n",+ "Average of max per entry across top 8 scores: 1.0\n",+ "Average of max per entry across top 9999 scores: 1.0\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 5%|▌ | 2/40 [00:05<01:37, 2.57s/it]\n"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Bootstrapped 1 full traces after 3 examples in round 0.\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "Average Metric: 34 / 40 (85.0): 100%|██████████| 40/40 [00:12<00:00, 3.31it/s] \n"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Average Metric: 34 / 40 (85.0%)\n",+ "Score: 85.0 for set: [8]\n",+ "Scores so far: [62.5, 85.0, 82.5, 87.5, 90.0, 85.0]\n",+ "Best score: 90.0\n",+ "Average of max per entry across top 1 scores: 0.9\n",+ "Average of max per entry across top 2 scores: 0.95\n",+ "Average of max per entry across top 3 scores: 0.975\n",+ "Average of max per entry across top 5 scores: 1.0\n",+ "Average of max per entry across top 8 scores: 1.0\n",+ "Average of max per entry across top 9999 scores: 1.0\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 8%|▊ | 3/40 [00:07<01:34, 2.56s/it]\n"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Bootstrapped 2 full traces after 4 examples in round 0.\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "Average Metric: 32 / 40 (80.0): 100%|██████████| 40/40 [00:18<00:00, 2.16it/s] \n"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Average Metric: 32 / 40 (80.0%)\n",+ "Score: 80.0 for set: [8]\n",+ "Scores so far: [62.5, 85.0, 82.5, 87.5, 90.0, 85.0, 80.0]\n",+ "Best score: 90.0\n",+ "Average of max per entry across top 1 scores: 0.9\n",+ "Average of max per entry across top 2 scores: 0.95\n",+ "Average of max per entry across top 3 scores: 0.975\n",+ "Average of max per entry across top 5 scores: 1.0\n",+ "Average of max per entry across top 8 scores: 1.0\n",+ "Average of max per entry across top 9999 scores: 1.0\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ " 5%|▌ | 2/40 [00:03<01:07, 1.76s/it]\n"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Bootstrapped 2 full traces after 3 examples in round 0.\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "Average Metric: 35 / 40 (87.5): 100%|██████████| 40/40 [00:12<00:00, 3.18it/s] "+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Average Metric: 35 / 40 (87.5%)\n",+ "Score: 87.5 for set: [8]\n",+ "Scores so far: [62.5, 85.0, 82.5, 87.5, 90.0, 85.0, 80.0, 87.5]\n",+ "Best score: 90.0\n",+ "Average of max per entry across top 1 scores: 0.9\n",+ "Average of max per entry across top 2 scores: 0.95\n",+ "Average of max per entry across top 3 scores: 0.975\n",+ "Average of max per entry across top 5 scores: 0.975\n",+ "Average of max per entry across top 8 scores: 1.0\n",+ "Average of max per entry across top 9999 scores: 1.0\n",+ "8 candidate programs found.\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "\n"+ ]+ }+ ],"source": ["from dspy.teleprompt.bootstrap import BootstrapFewShot\n","from dspy.teleprompt.random_search import BootstrapFewShotWithRandomSearch\n",@@ -708,7 +969,7 @@"print(\"Compiling...\")\n","compiled = BootstrapFewShotWithRandomSearch(\n","#compiled = BootstrapFewShot(\n",- " metric=metric,\n",+ " metric=metric5s,\n"," num_threads=30,\n"," num_candidate_programs=5,\n"," max_labeled_demos=8,\n",@@ -741,14 +1002,57 @@"name": "stderr","output_type": "stream","text": [- "Average Metric: 87 / 124 (70.2): 100%|██████████| 124/124 [00:29<00:00, 4.25it/s]"+ "Average Metric: 59.0 / 95 (62.1): 77%|███████▋ | 95/124 [00:16<00:04, 7.14it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Error for example in dev set: \t\t Too many retries\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "Average Metric: 74.0 / 120 (61.7): 97%|█████████▋| 120/124 [00:22<00:01, 2.43it/s]"]},{"name": "stdout","output_type": "stream","text": [- "Average Metric: 87 / 124 (70.2%)\n"+ "Error for example in dev set: \t\t Too many retries\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "Average Metric: 75.0 / 123 (61.0): 99%|█████████▉| 123/124 [00:25<00:00, 1.39it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Error for example in dev set: \t\t Too many retries\n"+ ]+ },+ {+ "name": "stderr",+ "output_type": "stream",+ "text": [+ "Average Metric: 75.0 / 124 (60.5): 100%|██████████| 124/124 [00:30<00:00, 4.07it/s]"+ ]+ },+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Error for example in dev set: \t\t Too many retries\n",+ "Average Metric: 75.0 / 124 (60.5%)\n"]},{@@ -762,88 +1066,88 @@"data": {"text/html": ["<style type=\"text/css\">\n",- "#T_bfcaa th {\n",+ "#T_1f859 th {\n"," text-align: left;\n","}\n",- "#T_bfcaa td {\n",+ "#T_1f859 td {\n"," text-align: left;\n","}\n",- "#T_bfcaa_row0_col0, #T_bfcaa_row0_col1, #T_bfcaa_row0_col2, #T_bfcaa_row0_col3, #T_bfcaa_row0_col4, #T_bfcaa_row0_col5, #T_bfcaa_row0_col6, #T_bfcaa_row1_col0, #T_bfcaa_row1_col1, #T_bfcaa_row1_col2, #T_bfcaa_row1_col3, #T_bfcaa_row1_col4, #T_bfcaa_row1_col5, #T_bfcaa_row1_col6, #T_bfcaa_row2_col0, #T_bfcaa_row2_col1, #T_bfcaa_row2_col2, #T_bfcaa_row2_col3, #T_bfcaa_row2_col4, #T_bfcaa_row2_col5, #T_bfcaa_row2_col6, #T_bfcaa_row3_col0, #T_bfcaa_row3_col1, #T_bfcaa_row3_col2, #T_bfcaa_row3_col3, #T_bfcaa_row3_col4, #T_bfcaa_row3_col5, #T_bfcaa_row3_col6, #T_bfcaa_row4_col0, #T_bfcaa_row4_col1, #T_bfcaa_row4_col2, #T_bfcaa_row4_col3, #T_bfcaa_row4_col4, #T_bfcaa_row4_col5, #T_bfcaa_row4_col6 {\n",+ "#T_1f859_row0_col0, #T_1f859_row0_col1, #T_1f859_row0_col2, #T_1f859_row0_col3, #T_1f859_row0_col4, #T_1f859_row0_col5, #T_1f859_row0_col6, #T_1f859_row1_col0, #T_1f859_row1_col1, #T_1f859_row1_col2, #T_1f859_row1_col3, #T_1f859_row1_col4, #T_1f859_row1_col5, #T_1f859_row1_col6, #T_1f859_row2_col0, #T_1f859_row2_col1, #T_1f859_row2_col2, #T_1f859_row2_col3, #T_1f859_row2_col4, #T_1f859_row2_col5, #T_1f859_row2_col6, #T_1f859_row3_col0, #T_1f859_row3_col1, #T_1f859_row3_col2, #T_1f859_row3_col3, #T_1f859_row3_col4, #T_1f859_row3_col5, #T_1f859_row3_col6, #T_1f859_row4_col0, #T_1f859_row4_col1, #T_1f859_row4_col2, #T_1f859_row4_col3, #T_1f859_row4_col4, #T_1f859_row4_col5, #T_1f859_row4_col6 {\n"," text-align: left;\n"," white-space: pre-wrap;\n"," word-wrap: break-word;\n"," max-width: 400px;\n","}\n","</style>\n",- "<table id=\"T_bfcaa\">\n",+ "<table id=\"T_1f859\">\n"," <thead>\n"," <tr>\n"," <th class=\"blank level0\" > </th>\n",- " <th id=\"T_bfcaa_level0_col0\" class=\"col_heading level0 col0\" >prompt</th>\n",- " <th id=\"T_bfcaa_level0_col1\" class=\"col_heading level0 col1\" >test</th>\n",- " <th id=\"T_bfcaa_level0_col2\" class=\"col_heading level0 col2\" >entry_point</th>\n",- " <th id=\"T_bfcaa_level0_col3\" class=\"col_heading level0 col3\" >example_solution</th>\n",- " <th id=\"T_bfcaa_level0_col4\" class=\"col_heading level0 col4\" >reasoning</th>\n",- " <th id=\"T_bfcaa_level0_col5\" class=\"col_heading level0 col5\" >pred_solution</th>\n",- " <th id=\"T_bfcaa_level0_col6\" class=\"col_heading level0 col6\" >metric</th>\n",+ " <th id=\"T_1f859_level0_col0\" class=\"col_heading level0 col0\" >prompt</th>\n",+ " <th id=\"T_1f859_level0_col1\" class=\"col_heading level0 col1\" >test</th>\n",+ " <th id=\"T_1f859_level0_col2\" class=\"col_heading level0 col2\" >entry_point</th>\n",+ " <th id=\"T_1f859_level0_col3\" class=\"col_heading level0 col3\" >example_solution</th>\n",+ " <th id=\"T_1f859_level0_col4\" class=\"col_heading level0 col4\" >pred_solution</th>\n",+ " <th id=\"T_1f859_level0_col5\" class=\"col_heading level0 col5\" >metric</th>\n",+ " <th id=\"T_1f859_level0_col6\" class=\"col_heading level0 col6\" >solution</th>\n"," </tr>\n"," </thead>\n"," <tbody>\n"," <tr>\n",- " <th id=\"T_bfcaa_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n",- " <td id=\"T_bfcaa_row0_col0\" class=\"data row0 col0\" >code='\\n\\ndef triples_sum_to_zero(l: list):\\n \"\"\"\\n triples_sum_to_zero takes a list of integers as an input.\\n it returns True if there are three distinct elements in the list...</td>\n",- " <td id=\"T_bfcaa_row0_col1\" class=\"data row0 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate([1, 3, 5, 0]) == False\\n assert candidate([1, 3, 5, -1]) == False\\n assert candidate([1, 3, -2, 1]) == True\\n...</td>\n",- " <td id=\"T_bfcaa_row0_col2\" class=\"data row0 col2\" >triples_sum_to_zero</td>\n",- " <td id=\"T_bfcaa_row0_col3\" class=\"data row0 col3\" >code='\\n\\ndef triples_sum_to_zero(l: list):\\n \"\"\"\\n triples_sum_to_zero takes a list of integers as an input.\\n it returns True if there are three distinct elements in the list...</td>\n",- " <td id=\"T_bfcaa_row0_col4\" class=\"data row0 col4\" >produce the solution. We need to find three distinct elements in the list that sum to zero. One way to approach this is to iterate...</td>\n",- " <td id=\"T_bfcaa_row0_col5\" class=\"data row0 col5\" >code='\\n\\ndef triples_sum_to_zero(l: list):\\n \"\"\"\\n triples_sum_to_zero takes a list of integers as an input.\\n it returns True if there are three distinct elements in the list...</td>\n",- " <td id=\"T_bfcaa_row0_col6\" class=\"data row0 col6\" >1</td>\n",+ " <th id=\"T_1f859_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n",+ " <td id=\"T_1f859_row0_col0\" class=\"data row0 col0\" >code='\\n\\ndef triples_sum_to_zero(l: list):\\n \"\"\"\\n triples_sum_to_zero takes a list of integers as an input.\\n it returns True if there are three distinct elements in the list...</td>\n",+ " <td id=\"T_1f859_row0_col1\" class=\"data row0 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate([1, 3, 5, 0]) == False\\n assert candidate([1, 3, 5, -1]) == False\\n assert candidate([1, 3, -2, 1]) == True\\n...</td>\n",+ " <td id=\"T_1f859_row0_col2\" class=\"data row0 col2\" >triples_sum_to_zero</td>\n",+ " <td id=\"T_1f859_row0_col3\" class=\"data row0 col3\" >code='\\n\\ndef triples_sum_to_zero(l: list):\\n \"\"\"\\n triples_sum_to_zero takes a list of integers as an input.\\n it returns True if there are three distinct elements in the list...</td>\n",+ " <td id=\"T_1f859_row0_col4\" class=\"data row0 col4\" >code='\\n\\ndef triples_sum_to_zero(l: list):\\n \"\"\"\\n triples_sum_to_zero takes a list of integers as an input.\\n it returns True if there are three distinct elements in the list...</td>\n",+ " <td id=\"T_1f859_row0_col5\" class=\"data row0 col5\" >1.0</td>\n",+ " <td id=\"T_1f859_row0_col6\" class=\"data row0 col6\" >nan</td>\n"," </tr>\n"," <tr>\n",- " <th id=\"T_bfcaa_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n",- " <td id=\"T_bfcaa_row1_col0\" class=\"data row1 col0\" >code='\\n\\ndef car_race_collision(n: int):\\n \"\"\"\\n Imagine a road that\\'s a perfectly straight infinitely long line.\\n n cars are driving left to right; simultaneously, a different set...</td>\n",- " <td id=\"T_bfcaa_row1_col1\" class=\"data row1 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate(2) == 4\\n assert candidate(3) == 9\\n assert candidate(4) == 16\\n assert candidate(8) == 64\\n assert candidate(10) == 100\\n\\n'</td>\n",- " <td id=\"T_bfcaa_row1_col2\" class=\"data row1 col2\" >car_race_collision</td>\n",- " <td id=\"T_bfcaa_row1_col3\" class=\"data row1 col3\" >code='\\n\\ndef car_race_collision(n: int):\\n \"\"\"\\n Imagine a road that\\'s a perfectly straight infinitely long line.\\n n cars are driving left to right; simultaneously, a different set...</td>\n",- " <td id=\"T_bfcaa_row1_col4\" class=\"data row1 col4\" >produce the solution. We can visualize the cars moving towards each other on an infinitely long road and calculate the number of collisions that would...</td>\n",- " <td id=\"T_bfcaa_row1_col5\" class=\"data row1 col5\" >code='\\n\\ndef car_race_collision(n: int):\\n \"\"\"\\n Imagine a road that\\'s a perfectly straight infinitely long line.\\n n cars are driving left to right; simultaneously, a different set...</td>\n",- " <td id=\"T_bfcaa_row1_col6\" class=\"data row1 col6\" >1</td>\n",+ " <th id=\"T_1f859_level0_row1\" class=\"row_heading level0 row1\" >1</th>\n",+ " <td id=\"T_1f859_row1_col0\" class=\"data row1 col0\" >code='\\n\\ndef car_race_collision(n: int):\\n \"\"\"\\n Imagine a road that\\'s a perfectly straight infinitely long line.\\n n cars are driving left to right; simultaneously, a different set...</td>\n",+ " <td id=\"T_1f859_row1_col1\" class=\"data row1 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate(2) == 4\\n assert candidate(3) == 9\\n assert candidate(4) == 16\\n assert candidate(8) == 64\\n assert candidate(10) == 100\\n\\n'</td>\n",+ " <td id=\"T_1f859_row1_col2\" class=\"data row1 col2\" >car_race_collision</td>\n",+ " <td id=\"T_1f859_row1_col3\" class=\"data row1 col3\" >code='\\n\\ndef car_race_collision(n: int):\\n \"\"\"\\n Imagine a road that\\'s a perfectly straight infinitely long line.\\n n cars are driving left to right; simultaneously, a different set...</td>\n",+ " <td id=\"T_1f859_row1_col4\" class=\"data row1 col4\" >code='\\n\\ndef car_race_collision(n: int):\\n \"\"\"\\n Imagine a road that\\'s a perfectly straight infinitely long line.\\n n cars are driving left to right; simultaneously, a different set...</td>\n",+ " <td id=\"T_1f859_row1_col5\" class=\"data row1 col5\" >1.0</td>\n",+ " <td id=\"T_1f859_row1_col6\" class=\"data row1 col6\" >nan</td>\n"," </tr>\n"," <tr>\n",- " <th id=\"T_bfcaa_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n",- " <td id=\"T_bfcaa_row2_col0\" class=\"data row2 col0\" >code='\\n\\ndef incr_list(l: list):\\n \"\"\"Return list with elements incremented by 1.\\n >>> incr_list([1, 2, 3])\\n [2, 3, 4]\\n >>> incr_list([5, 3, 5, 2, 3, 3, 9,...</td>\n",- " <td id=\"T_bfcaa_row2_col1\" class=\"data row2 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate([]) == []\\n assert candidate([3, 2, 1]) == [4, 3, 2]\\n assert candidate([5, 2, 5, 2, 3, 3, 9, 0,...</td>\n",- " <td id=\"T_bfcaa_row2_col2\" class=\"data row2 col2\" >incr_list</td>\n",- " <td id=\"T_bfcaa_row2_col3\" class=\"data row2 col3\" >code='\\n\\ndef incr_list(l: list):\\n \"\"\"Return list with elements incremented by 1.\\n >>> incr_list([1, 2, 3])\\n [2, 3, 4]\\n >>> incr_list([5, 3, 5, 2, 3, 3, 9,...</td>\n",- " <td id=\"T_bfcaa_row2_col4\" class=\"data row2 col4\" >produce the solution. We need to iterate through each element in the list and increment it by 1.</td>\n",- " <td id=\"T_bfcaa_row2_col5\" class=\"data row2 col5\" >code='\\n\\ndef incr_list(l: list):\\n \"\"\"Return list with elements incremented by 1.\\n >>> incr_list([1, 2, 3])\\n [2, 3, 4]\\n >>> incr_list([5, 3, 5, 2, 3, 3, 9,...</td>\n",- " <td id=\"T_bfcaa_row2_col6\" class=\"data row2 col6\" >1</td>\n",+ " <th id=\"T_1f859_level0_row2\" class=\"row_heading level0 row2\" >2</th>\n",+ " <td id=\"T_1f859_row2_col0\" class=\"data row2 col0\" >code='\\n\\ndef incr_list(l: list):\\n \"\"\"Return list with elements incremented by 1.\\n >>> incr_list([1, 2, 3])\\n [2, 3, 4]\\n >>> incr_list([5, 3, 5, 2, 3, 3, 9,...</td>\n",+ " <td id=\"T_1f859_row2_col1\" class=\"data row2 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate([]) == []\\n assert candidate([3, 2, 1]) == [4, 3, 2]\\n assert candidate([5, 2, 5, 2, 3, 3, 9, 0,...</td>\n",+ " <td id=\"T_1f859_row2_col2\" class=\"data row2 col2\" >incr_list</td>\n",+ " <td id=\"T_1f859_row2_col3\" class=\"data row2 col3\" >code='\\n\\ndef incr_list(l: list):\\n \"\"\"Return list with elements incremented by 1.\\n >>> incr_list([1, 2, 3])\\n [2, 3, 4]\\n >>> incr_list([5, 3, 5, 2, 3, 3, 9,...</td>\n",+ " <td id=\"T_1f859_row2_col4\" class=\"data row2 col4\" >code='\\n\\ndef incr_list(l: list):\\n \"\"\"Return list with elements incremented by 1.\\n >>> incr_list([1, 2, 3])\\n [2, 3, 4]\\n >>> incr_list([5, 3, 5, 2, 3, 3, 9,...</td>\n",+ " <td id=\"T_1f859_row2_col5\" class=\"data row2 col5\" >1.0</td>\n",+ " <td id=\"T_1f859_row2_col6\" class=\"data row2 col6\" >nan</td>\n"," </tr>\n"," <tr>\n",- " <th id=\"T_bfcaa_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n",- " <td id=\"T_bfcaa_row3_col0\" class=\"data row3 col0\" >code='\\n\\ndef pairs_sum_to_zero(l):\\n \"\"\"\\n pairs_sum_to_zero takes a list of integers as an input.\\n it returns True if there are two distinct elements in the list that\\n...</td>\n",- " <td id=\"T_bfcaa_row3_col1\" class=\"data row3 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate([1, 3, 5, 0]) == False\\n assert candidate([1, 3, -2, 1]) == False\\n assert candidate([1, 2, 3, 7]) == False\\n...</td>\n",- " <td id=\"T_bfcaa_row3_col2\" class=\"data row3 col2\" >pairs_sum_to_zero</td>\n",- " <td id=\"T_bfcaa_row3_col3\" class=\"data row3 col3\" >code='\\n\\ndef pairs_sum_to_zero(l):\\n \"\"\"\\n pairs_sum_to_zero takes a list of integers as an input.\\n it returns True if there are two distinct elements in the list that\\n...</td>\n",- " <td id=\"T_bfcaa_row3_col4\" class=\"data row3 col4\" >produce the solution. We need to iterate through the list and check if there are two distinct elements that sum up to zero. To do...</td>\n",- " <td id=\"T_bfcaa_row3_col5\" class=\"data row3 col5\" >code='\\n\\ndef pairs_sum_to_zero(l):\\n \"\"\"\\n pairs_sum_to_zero takes a list of integers as an input.\\n it returns True if there are two distinct elements in the list that\\n...</td>\n",- " <td id=\"T_bfcaa_row3_col6\" class=\"data row3 col6\" >1</td>\n",+ " <th id=\"T_1f859_level0_row3\" class=\"row_heading level0 row3\" >3</th>\n",+ " <td id=\"T_1f859_row3_col0\" class=\"data row3 col0\" >code='\\n\\ndef pairs_sum_to_zero(l):\\n \"\"\"\\n pairs_sum_to_zero takes a list of integers as an input.\\n it returns True if there are two distinct elements in the list that\\n...</td>\n",+ " <td id=\"T_1f859_row3_col1\" class=\"data row3 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate([1, 3, 5, 0]) == False\\n assert candidate([1, 3, -2, 1]) == False\\n assert candidate([1, 2, 3, 7]) == False\\n...</td>\n",+ " <td id=\"T_1f859_row3_col2\" class=\"data row3 col2\" >pairs_sum_to_zero</td>\n",+ " <td id=\"T_1f859_row3_col3\" class=\"data row3 col3\" >code='\\n\\ndef pairs_sum_to_zero(l):\\n \"\"\"\\n pairs_sum_to_zero takes a list of integers as an input.\\n it returns True if there are two distinct elements in the list that\\n...</td>\n",+ " <td id=\"T_1f859_row3_col4\" class=\"data row3 col4\" >code='\\n\\ndef pairs_sum_to_zero(l):\\n \"\"\"\\n pairs_sum_to_zero takes a list of integers as an input.\\n it returns True if there are two distinct elements in the list that\\n...</td>\n",+ " <td id=\"T_1f859_row3_col5\" class=\"data row3 col5\" >1.0</td>\n",+ " <td id=\"T_1f859_row3_col6\" class=\"data row3 col6\" >nan</td>\n"," </tr>\n"," <tr>\n",- " <th id=\"T_bfcaa_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n",- " <td id=\"T_bfcaa_row4_col0\" class=\"data row4 col0\" >code='\\n\\ndef change_base(x: int, base: int):\\n \"\"\"Change numerical base of input number x to base.\\n return string representation after the conversion.\\n base numbers are less than...</td>\n",- " <td id=\"T_bfcaa_row4_col1\" class=\"data row4 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate(8, 3) == \"22\"\\n assert candidate(9, 3) == \"100\"\\n assert candidate(234, 2) == \"11101010\"\\n assert candidate(16, 2) == \"10000\"\\n assert...</td>\n",- " <td id=\"T_bfcaa_row4_col2\" class=\"data row4 col2\" >change_base</td>\n",- " <td id=\"T_bfcaa_row4_col3\" class=\"data row4 col3\" >code='\\n\\ndef change_base(x: int, base: int):\\n \"\"\"Change numerical base of input number x to base.\\n return string representation after the conversion.\\n base numbers are less than...</td>\n",- " <td id=\"T_bfcaa_row4_col4\" class=\"data row4 col4\" >produce the solution. We need to convert the number `x` from its current base to the desired `base`. To do this, we can repeatedly divide...</td>\n",- " <td id=\"T_bfcaa_row4_col5\" class=\"data row4 col5\" >code='\\n\\ndef change_base(x: int, base: int):\\n \"\"\"Change numerical base of input number x to base.\\n return string representation after the conversion.\\n base numbers are less than...</td>\n",- " <td id=\"T_bfcaa_row4_col6\" class=\"data row4 col6\" >1</td>\n",+ " <th id=\"T_1f859_level0_row4\" class=\"row_heading level0 row4\" >4</th>\n",+ " <td id=\"T_1f859_row4_col0\" class=\"data row4 col0\" >code='\\n\\ndef change_base(x: int, base: int):\\n \"\"\"Change numerical base of input number x to base.\\n return string representation after the conversion.\\n base numbers are less than...</td>\n",+ " <td id=\"T_1f859_row4_col1\" class=\"data row4 col1\" >code='\\n\\nMETADATA = {}\\n\\n\\ndef check(candidate):\\n assert candidate(8, 3) == \"22\"\\n assert candidate(9, 3) == \"100\"\\n assert candidate(234, 2) == \"11101010\"\\n assert candidate(16, 2) == \"10000\"\\n assert...</td>\n",+ " <td id=\"T_1f859_row4_col2\" class=\"data row4 col2\" >change_base</td>\n",+ " <td id=\"T_1f859_row4_col3\" class=\"data row4 col3\" >code='\\n\\ndef change_base(x: int, base: int):\\n \"\"\"Change numerical base of input number x to base.\\n return string representation after the conversion.\\n base numbers are less than...</td>\n",+ " <td id=\"T_1f859_row4_col4\" class=\"data row4 col4\" >code='\\n\\ndef change_base(x: int, base: int):\\n \"\"\"Change numerical base of input number x to base.\\n return string representation after the conversion.\\n base numbers are less than...</td>\n",+ " <td id=\"T_1f859_row4_col5\" class=\"data row4 col5\" >1.0</td>\n",+ " <td id=\"T_1f859_row4_col6\" class=\"data row4 col6\" >nan</td>\n"," </tr>\n"," </tbody>\n","</table>\n"],"text/plain": [- "<pandas.io.formats.style.Styler at 0x29730c990>"+ "<pandas.io.formats.style.Styler at 0x2b2fa1410>"]},"metadata": {},@@ -874,7 +1178,7 @@"name": "stdout","output_type": "stream","text": [- "Compiled HumanEval score: 70.16\n"+ "Compiled HumanEval score: 60.48\n"]}],@@ -882,7 +1186,7 @@"print(\"Evaluating...\")\n","print(\n"," \"Compiled HumanEval score:\",\n",- " evaluator(compiled, metric=metric),\n",+ " evaluator(compiled, metric=test_code(timeout=100)),\n",")"]}