Skip to content

armgit / dspy

Public Imported from GitHub
0

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

Python

fix typos

J Sf8a1253dd234
diff --git a/dspy/predict/predict.py b/dspy/predict/predict.py
index 5285f09fa..68d8c20ce 100644
--- a/dspy/predict/predict.py
+++ b/dspy/predict/predict.py
@@ -124,6 +124,6 @@ class Predict(Parameter):
# TODO: get some defaults during init from the context window?
# # TODO: FIXME: Hmm, I guess expected behavior is that contexts can
-# affect exeuction. Well, we need to determine whether context dominates, __init__ demoninates, or forward dominates.
+# affect execution. Well, we need to determine whether context dominates, __init__ demoninates, or forward dominates.
# Generally, unless overwritten, we'd see n=None, temperature=None.
# That will eventually mean we have to learn them.
diff --git a/dspy/primitives/python_interpreter.py b/dspy/primitives/python_interpreter.py
index c47da27f0..f05ec0111 100644
--- a/dspy/primitives/python_interpreter.py
+++ b/dspy/primitives/python_interpreter.py
@@ -43,7 +43,7 @@ class PythonInterpreter():
r"""A customized python interpreter to control the execution of
LLM-generated codes. The interpreter makes sure the code can only execute
functions given in action space and import white list. It also supports
- fuzzy variable matching to reveive uncertain input variable name.
+ fuzzy variable matching to receive uncertain input variable name.
.. highlight:: none
@@ -116,9 +116,9 @@ class PythonInterpreter():
code (str): Generated python code to be executed.
state (Optional[Dict[str, Any]], optional): External variables that
may be used in the generated code. (default: :obj:`None`)
- fuzz_state (Optional[Dict[str, Any]], optional): External varibles
- that do not have certain varible names. The interpreter will
- use fuzzy matching to access these varibales. For example, if
+ fuzz_state (Optional[Dict[str, Any]], optional): External variables
+ that do not have certain variable names. The interpreter will
+ use fuzzy matching to access these variables. For example, if
:obj:`fuzz_state` has a variable :obj:`image`, the generated
code can use :obj:`input_image` to access it. (default:
:obj:`None`)
@@ -577,7 +577,7 @@ class CodePrompt(TextPrompt):
Args:
interpreter (PythonInterpreter, optional): interpreter to be used
during code execution. (default: :obj:`None`)
- user_variable (Optional[Dict[str, Any]]): varibales that can be
+ user_variable (Optional[Dict[str, Any]]): variables that can be
used in the code, which applying fuzzy matching, such as images
or documents. (default: :obj:`None`)
diff --git a/dspy/teleprompt/random_search.py b/dspy/teleprompt/random_search.py
index 04399d412..8605cd427 100644
--- a/dspy/teleprompt/random_search.py
+++ b/dspy/teleprompt/random_search.py
@@ -40,7 +40,7 @@ class BootstrapFewShotWithRandomSearch(Teleprompter):
self.num_candidate_sets = num_candidate_programs
# self.max_num_traces = 1 + int(max_bootstrapped_demos / 2.0 * self.num_candidate_sets)
- # Semi-hacky way to get the parent class's _boostrap function to stop early.
+ # Semi-hacky way to get the parent class's _bootstrap function to stop early.
# self.max_bootstrapped_demos = self.max_num_traces
self.max_labeled_demos = max_labeled_demos
diff --git a/dspy/teleprompt/signature_opt.py b/dspy/teleprompt/signature_opt.py
index d0c2f2d69..4c047b3da 100644
--- a/dspy/teleprompt/signature_opt.py
+++ b/dspy/teleprompt/signature_opt.py
@@ -20,7 +20,7 @@ Note that this teleprompter takes in the following parameters:
* prompt_model: The model used for prompt generation. When unspecified, defaults to the model set in settings (ie. dspy.settings.configure(lm=task_model)).
* metric: The task metric used for optimization.
* breadth: The number of new prompts to generate at each iteration. Default=10.
-* depth: The number of times we should ask our prompt model to genereate new prompts, with the history of the past prompts as input. Default=3.
+* depth: The number of times we should ask our prompt model to generate new prompts, with the history of the past prompts as input. Default=3.
* init_temperature: The temperature used to generate new prompts. Higher roughly equals more creative. Default=1.4.
* verbose: Tells the method whether or not to print intermediate steps.
* track_stats: Tells the method whether or not to track statistics about the optimization process.
diff --git a/dspy/teleprompt/signature_opt_bayesian.py b/dspy/teleprompt/signature_opt_bayesian.py
index 790af70e6..b39e7c7f3 100644
--- a/dspy/teleprompt/signature_opt_bayesian.py
+++ b/dspy/teleprompt/signature_opt_bayesian.py
@@ -81,7 +81,7 @@ class ObservationSummarizer(dspy.Signature):
class DatasetDescriptor(dspy.Signature):
("""Given several examples from a dataset please write observations about trends that hold for most or all of the samples. """
- """Some areas you may consider in your observations: topics, content, syntax, conciceness, etc. """
+ """Some areas you may consider in your observations: topics, content, syntax, conciseness, etc. """
"""It will be useful to make an educated guess as to the nature of the task this dataset will enable. Don't be afraid to be creative""")
examples = dspy.InputField(desc="Sample data points from the dataset")
@@ -90,7 +90,7 @@ class DatasetDescriptor(dspy.Signature):
class DatasetDescriptorWithPriorObservations(dspy.Signature):
("""Given several examples from a dataset please write observations about trends that hold for most or all of the samples. """
"""I will also provide you with a few observations I have already made. Please add your own observations or if you feel the observations are comprehensive say 'COMPLETE' """
- """Some areas you may consider in your observations: topics, content, syntax, conciceness, etc. """
+ """Some areas you may consider in your observations: topics, content, syntax, conciseness, etc. """
"""It will be useful to make an educated guess as to the nature of the task this dataset will enable. Don't be afraid to be creative""")
examples = dspy.InputField(desc="Sample data points from the dataset")
diff --git a/dspy/teleprompt/teleprompt_optuna.py b/dspy/teleprompt/teleprompt_optuna.py
index 5528e5fb0..4847ce939 100644
--- a/dspy/teleprompt/teleprompt_optuna.py
+++ b/dspy/teleprompt/teleprompt_optuna.py
@@ -23,7 +23,7 @@ class BootstrapFewShotWithOptuna(Teleprompter):
self.num_candidate_sets = num_candidate_programs
# self.max_num_traces = 1 + int(max_bootstrapped_demos / 2.0 * self.num_candidate_sets)
- # Semi-hacky way to get the parent class's _boostrap function to stop early.
+ # Semi-hacky way to get the parent class's _bootstrap function to stop early.
# self.max_bootstrapped_demos = self.max_num_traces
self.max_labeled_demos = max_labeled_demos
diff --git a/examples/knn.ipynb b/examples/knn.ipynb
index e54814232..51a50654c 100644
--- a/examples/knn.ipynb
+++ b/examples/knn.ipynb
@@ -5,7 +5,7 @@
"metadata": {},
"source": [
"# DSPy KNN few-shot example \n",
- "This noteboook shows how KNN few-shot can be implemented with DSPy using the **KNNFewShot** teleprompter. To illustrate, we use the HotPotQA dataset. Please see [intro.ipynb](../intro.ipynb) for other example use cases of DSPy.\n"
+ "This notebook shows how KNN few-shot can be implemented with DSPy using the **KNNFewShot** teleprompter. To illustrate, we use the HotPotQA dataset. Please see [intro.ipynb](../intro.ipynb) for other example use cases of DSPy.\n"
]
},
{
diff --git a/examples/longformqa/longformqa_assertions.ipynb b/examples/longformqa/longformqa_assertions.ipynb
index 75403383e..7dab608df 100644
--- a/examples/longformqa/longformqa_assertions.ipynb
+++ b/examples/longformqa/longformqa_assertions.ipynb
@@ -553,7 +553,7 @@
"\n",
"We can also leverage **DSPy**'s advanced compiling features to enhance our program's performance. \n",
"\n",
- "For this, we utilize the `BootstrapFewShotWithRandomSearch` teleprompter, which automatically incorporates few-shot demonstrations and conducts a random search over a candidate set to output the best compiled program. We evaluate this over the `answer_correctness` metric as our ultimate goal is indeed to generate correct answers to the `HotPotQA` questions from the paragraphs, aiming to optimize both instrinsic and extrinsic metrics as a result. \n",
+ "For this, we utilize the `BootstrapFewShotWithRandomSearch` teleprompter, which automatically incorporates few-shot demonstrations and conducts a random search over a candidate set to output the best compiled program. We evaluate this over the `answer_correctness` metric as our ultimate goal is indeed to generate correct answers to the `HotPotQA` questions from the paragraphs, aiming to optimize both intrinsic and extrinsic metrics as a result. \n",
"\n",
"Let's evaluate this on the LongFormQA program first:"
]
@@ -592,24 +592,24 @@
]
},
{
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "**Note** This pipeline on the other hand sets both the teacher and student with `LongFormQAWithAssertions()` to ensure the teacher correctly instructs the student with the right bootstrapped examples and the student has the chance to self-correct with **Assertions** for any examples that are still deemed incorrect."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "longformqa = LongFormQA()\n",
- "teleprompter = BootstrapFewShotWithRandomSearch(metric = answer_correctness, max_bootstrapped_demos=2, num_candidate_programs=6)\n",
- "cited_longformqa_student_teacher = teleprompter.compile(student=assert_transform_module(LongFormQAWithAssertions().map_named_predictors(Retry), backtrack_handler), teacher = assert_transform_module(LongFormQAWithAssertions().map_named_predictors(Retry), backtrack_handler), trainset=trainset, valset=devset[:100])\n",
- "evaluate(cited_longformqa_student_teacher)"
- ]
- }
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "**Note** This pipeline on the other hand sets both the teacher and student with `LongFormQAWithAssertions()` to ensure the teacher correctly instructs the student with the right bootstrapped examples and the student has the chance to self-correct with **Assertions** for any examples that are still deemed incorrect."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "longformqa = LongFormQA()\n",
+ "teleprompter = BootstrapFewShotWithRandomSearch(metric = answer_correctness, max_bootstrapped_demos=2, num_candidate_programs=6)\n",
+ "cited_longformqa_student_teacher = teleprompter.compile(student=assert_transform_module(LongFormQAWithAssertions().map_named_predictors(Retry), backtrack_handler), teacher = assert_transform_module(LongFormQAWithAssertions().map_named_predictors(Retry), backtrack_handler), trainset=trainset, valset=devset[:100])\n",
+ "evaluate(cited_longformqa_student_teacher)"
+ ]
+ }
],
"metadata": {
"kernelspec": {
diff --git a/examples/tweets/compiling_langchain.ipynb b/examples/tweets/compiling_langchain.ipynb
index e847df323..63a8d5525 100644
--- a/examples/tweets/compiling_langchain.ipynb
+++ b/examples/tweets/compiling_langchain.ipynb
@@ -117,7 +117,7 @@
"- **Input:** A factual **question**, which may be fairly complex.\n",
"- **Output:** An engaging **tweet** that correctly answers the question from the retrieved info.\n",
"\n",
- "Let's use LangChain's expression langugage (LCEL) to illustrate this. Any prompt here will do, we will optimize the final prompt with DSPy.\n",
+ "Let's use LangChain's expression language (LCEL) to illustrate this. Any prompt here will do, we will optimize the final prompt with DSPy.\n",
"\n",
"Considering that, let's just keep it to the barebones: **Given {context}, answer the question {question} as a tweet.**"
]
diff --git a/intro.ipynb b/intro.ipynb
index 60bc0ebaf..bbdbc194f 100644
--- a/intro.ipynb
+++ b/intro.ipynb
@@ -130,7 +130,7 @@
"source": [
"### 2] Task Examples\n",
"\n",
- "**DSPy** accomodates a wide variety of applications and tasks. **In this intro notebook, we will work on the example task of multi-hop question answering (QA).**\n",
+ "**DSPy** accommodates a wide variety of applications and tasks. **In this intro notebook, we will work on the example task of multi-hop question answering (QA).**\n",
"\n",
"Other notebooks and tutorials will present different tasks. Now, let us load a tiny sample from the HotPotQA multi-hop dataset."
]
@@ -1010,7 +1010,7 @@
"source": [
"##### Evaluating the Retrieval\n",
"\n",
- "It may also be instructive to look at the accuracy of retrieval. There are multiple ways to do this. Often, we can just check whether the rertieved passages contain the answer.\n",
+ "It may also be instructive to look at the accuracy of retrieval. There are multiple ways to do this. Often, we can just check whether the retrieved passages contain the answer.\n",
"\n",
"That said, since our dev set includes the gold titles that should be retrieved, we can just use these here."
]