Skip to content

armgit / dspy

Public Imported from GitHub
0

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

Python

lint fixes

Herumb Shandilya5a2c7141c11e
diff --git a/dspy/experimental/synthesizer/config.py b/dspy/experimental/synthesizer/config.py
index 646df9f02..609efbe12 100644
--- a/dspy/experimental/synthesizer/config.py
+++ b/dspy/experimental/synthesizer/config.py
@@ -1,8 +1,10 @@
-import dspy
+from typing import Optional, Union
-from typing import Union, List, Optional
from pydantic import BaseModel, field_validator
+import dspy
+
+
class SynthesizerArguments(BaseModel):
# [TODO]
feedback_mode: Optional[str] = None
diff --git a/dspy/experimental/synthesizer/instructions.py b/dspy/experimental/synthesizer/instructions.py
index 1e0f13ee7..2fa65493a 100644
--- a/dspy/experimental/synthesizer/instructions.py
+++ b/dspy/experimental/synthesizer/instructions.py
@@ -1,5 +1,5 @@
-INPUT_GENERATION_TASK_WITH_EXAMPLES = f"""Create synthetic data using the task description and the provided knowledge seed. Your task is to generate diverse and imaginative data that aligns with the given task description and knowledge seed. You are encouraged to be creative and not limit yourself, allowing for a wide range of synthetic data that reflects the characteristics and details provided in the task description. The data should be unique and varied, showcasing originality and creativity while maintaining relevance to the task and knowledge seed.
+INPUT_GENERATION_TASK_WITH_EXAMPLES = """Create synthetic data using the task description and the provided knowledge seed. Your task is to generate diverse and imaginative data that aligns with the given task description and knowledge seed. You are encouraged to be creative and not limit yourself, allowing for a wide range of synthetic data that reflects the characteristics and details provided in the task description. The data should be unique and varied, showcasing originality and creativity while maintaining relevance to the task and knowledge seed.
Additionally I'll be providing you some data I generated before hand, make sure the data you generate if consistent with task I provided but different from the data I provided in every way possible."""
-INPUT_GENERATION_TASK_WITH_FEEDBACK = f""""""
\ No newline at end of file
+INPUT_GENERATION_TASK_WITH_FEEDBACK = """"""
\ No newline at end of file
diff --git a/dspy/experimental/synthesizer/signatures.py b/dspy/experimental/synthesizer/signatures.py
index 1ca0cb759..0597dfdd5 100644
--- a/dspy/experimental/synthesizer/signatures.py
+++ b/dspy/experimental/synthesizer/signatures.py
@@ -2,6 +2,7 @@ import dspy
from .utils import format_examples
+
class UnderstandTask(dspy.Signature):
"""I'll be providing you a task description. Your task is to prepare a concise, comprehensible summary that captures the broad essence and purpose of this task description. Your summary should illuminate the general objective and the type of problem being solved, offering a clear picture of what the task entails at a high level. Avoid getting into the nuances or specifics of individual datapoints, models, examples, algorithms, or any intricate technicalities. Your explanation should serve to clarify the task's overall goal and its basic premise without touching on methodologies or solutions."""
diff --git a/dspy/experimental/synthesizer/synthesizer.py b/dspy/experimental/synthesizer/synthesizer.py
index 4d62b3e77..d85f2cdb4 100644
--- a/dspy/experimental/synthesizer/synthesizer.py
+++ b/dspy/experimental/synthesizer/synthesizer.py
@@ -1,10 +1,14 @@
-import dspy
import random
+from collections.abc import Mapping
+from typing import List, Optional, Union
from datasets import Dataset
from tqdm import tqdm, trange
-from typing import List, Union, Optional, Mapping
+import dspy
+
+from .config import SynthesizerArguments
+from .instructions import INPUT_GENERATION_TASK_WITH_EXAMPLES
from .signatures import (
ExplainTask,
GenerateFieldDescription,
@@ -12,8 +16,6 @@ from .signatures import (
GenerateOutputFieldsData,
UnderstandTask,
)
-from .config import SynthesizerArguments
-from .instructions import INPUT_GENERATION_TASK_WITH_EXAMPLES
from .utils import format_examples
__all__ = ["Synthesizer"]
@@ -73,7 +75,7 @@ class Synthesizer:
-1,
"ground_source",
dspy.InputField(
- prefix=f"Pre-Generated Examples:",
+ prefix="Pre-Generated Examples:",
desc="Pre-Generated Examples to differ the inputs around.",
format=format_examples,
),
@@ -159,13 +161,13 @@ class Synthesizer:
task_description=task_description,
knowledge_seed=iter_seed,
ground_source=example_for_optimization,
- config=dict(temperature=iter_temperature, n=batch_size)
+ config=dict(temperature=iter_temperature, n=batch_size),
)
else:
inputs = self.input_predictor(
task_description=task_description,
knowledge_seed=iter_seed,
- config=dict(temperature=iter_temperature, n=batch_size)
+ config=dict(temperature=iter_temperature, n=batch_size),
)
input_kwargs = [{
diff --git a/dspy/experimental/synthesizer/utils.py b/dspy/experimental/synthesizer/utils.py
index b52ae9016..f08b142e1 100644
--- a/dspy/experimental/synthesizer/utils.py
+++ b/dspy/experimental/synthesizer/utils.py
@@ -1,6 +1,8 @@
-import dspy
from typing import List
+import dspy
+
+
def format_examples(examples: List[dspy.Example]) -> str:
if isinstance(examples, str):
return examples