Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

make num_trials a required variable, plus minor changes to notebook

klopsahlong695cefcee02e
diff --git a/dspy/teleprompt/mipro_optimizer.py b/dspy/teleprompt/mipro_optimizer.py
index 3125c562c..c9045ff79 100644
--- a/dspy/teleprompt/mipro_optimizer.py
+++ b/dspy/teleprompt/mipro_optimizer.py
@@ -103,7 +103,7 @@ class DatasetDescriptorWithPriorObservations(dspy.Signature):
observations = dspy.OutputField(desc="Somethings that holds true for most or all of the data you observed or COMPLETE if you have nothing to add")
class MIPRO(Teleprompter):
- def __init__(self, prompt_model=None, task_model=None, teacher_settings={}, num_candidates=10, metric=None, init_temperature=1.0, verbose=False, track_stats=True, view_data_batch_size=10):
+ def __init__(self, metric, prompt_model=None, task_model=None, teacher_settings={}, num_candidates=10, init_temperature=1.0, verbose=False, track_stats=True, view_data_batch_size=10):
self.num_candidates = num_candidates
self.metric = metric
self.init_temperature = init_temperature
@@ -275,7 +275,7 @@ class MIPRO(Teleprompter):
return candidates, evaluated_candidates
- def compile(self, student, *, trainset, max_bootstrapped_demos, max_labeled_demos, eval_kwargs, seed=42, view_data=True, view_examples=True, requires_permission_to_run=True, num_trials=None):
+ def compile(self, student, *, trainset, num_trials, max_bootstrapped_demos, max_labeled_demos, eval_kwargs, seed=42, view_data=True, view_examples=True, requires_permission_to_run=True):
# Define ANSI escape codes for colors
YELLOW = '\033[93m'
BLUE = '\033[94m'
diff --git a/examples/qa/hotpot/hotpotqa_with_MIPRO.ipynb b/examples/qa/hotpot/hotpotqa_with_MIPRO.ipynb
index e50831c93..964c6329c 100644
--- a/examples/qa/hotpot/hotpotqa_with_MIPRO.ipynb
+++ b/examples/qa/hotpot/hotpotqa_with_MIPRO.ipynb
@@ -66,7 +66,7 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 10,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@@ -74,7 +74,16 @@
"id": "JpijP_d7qZH2",
"outputId": "422dc4d0-4574-4e4b-935a-c7b4c875472f"
},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The autoreload extension is already loaded. To reload it, use:\n",
+ " %reload_ext autoreload\n"
+ ]
+ }
+ ],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
@@ -117,7 +126,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 11,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
@@ -175,7 +184,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 12,
"metadata": {
"id": "UHWzGRVgqZH2"
},
@@ -219,7 +228,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 13,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
@@ -420,7 +429,7 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 14,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@@ -433,14 +442,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "Average Metric: 0 / 2 (0.0): 0%| | 1/500 [00:00<03:17, 2.52it/s]"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "Average Metric: 80 / 500 (16.0): 100%|██████████| 500/500 [00:33<00:00, 15.10it/s]\n",
+ "Average Metric: 80 / 500 (16.0): 100%|██████████| 500/500 [00:30<00:00, 16.16it/s]\n",
"/lfs/0/kristaoo/dspy/dspy/evaluate/evaluate.py:187: FutureWarning: DataFrame.applymap has been deprecated. Use DataFrame.map instead.\n",
" df = df.applymap(truncate_cell)\n"
]
@@ -456,7 +458,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "Average Metric: 107 / 500 (21.4): 100%|██████████| 500/500 [00:32<00:00, 15.31it/s]"
+ "Average Metric: 107 / 500 (21.4): 100%|██████████| 500/500 [00:30<00:00, 16.50it/s]\n"
]
},
{
@@ -465,13 +467,6 @@
"text": [
"Average Metric: 107 / 500 (21.4%)\n"
]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "\n"
- ]
}
],
"source": [
@@ -515,7 +510,7 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 15,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@@ -523,15 +518,7 @@
"id": "TpFW7IaYqZH3",
"outputId": "b83c427f-953d-4fa7-b19c-03704369ab53"
},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "/lfs/0/kristaoo/dspy/examples/qa/hotpot/MIPRO_notebook_cache/compiler\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"import cloudpickle as pickle\n",
"from dspy.teleprompt import MIPRO\n",
@@ -569,7 +556,7 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 16,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@@ -582,7 +569,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "Average Metric: 192 / 500 (38.4): 100%|██████████| 500/500 [00:30<00:00, 16.24it/s]\n"
+ "Average Metric: 192 / 500 (38.4): 100%|██████████| 500/500 [00:30<00:00, 16.19it/s]\n"
]
},
{
@@ -596,7 +583,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "Average Metric: 193 / 500 (38.6): 100%|██████████| 500/500 [00:32<00:00, 15.53it/s]\n"
+ "Average Metric: 193 / 500 (38.6): 100%|██████████| 500/500 [00:30<00:00, 16.22it/s]\n"
]
},
{
@@ -632,7 +619,7 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 17,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
@@ -692,7 +679,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 18,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"