Skip to content

optimize_settings

TextEvolve optimization settings

Classes

AbstractBatchSampler

Bases: BaseDataModel, ABC

Abstract training data sampling strategy

Functions

sample abstractmethod
sample(data: List[str]) -> List[str]

InferenceConfig

Bases: BaseDataModel

As part of the prompt optimization process, prompt inferencing needs to be conducted before evaluation. This configuration setting controls parameters used by the SimpleChainBuilder to create the inferencing chain.

Attributes

llm class-attribute instance-attribute
llm: str = Field(
    ...,
    title="LLM",
    description="The LLM to use for inference, must be registered by the backend configuration",
)
llm_bind_kwargs class-attribute instance-attribute
llm_bind_kwargs: Dict[str, Any] = Field(
    default_factory=dict,
    title="LLM Bind Kwargs",
    description="",
)
mapper_to_str_kwargs class-attribute instance-attribute
mapper_to_str_kwargs: Dict[str, Any] = Field(
    default_factory=dict,
    title="Mapper to String Kwargs",
    description="Additional kwargs passed to the mapper to_string method when rendering the prompt template before it is sent to the LLM",
)

NBatchSampler

Bases: AbstractBatchSampler

Randomly sample N samples from the training data

Attributes

n class-attribute instance-attribute
n: int = Field(
    ...,
    title="N",
    description="The number of samples to select",
)

Functions

sample
sample(data: List[str]) -> List[str]

OptimizeProfile

Bases: BaseDataModel

Profile settings and hyperparameters that govern the optimization process

Attributes

batch_sampler_factory class-attribute instance-attribute
batch_sampler_factory: IoCFactoryModel = Field(
    ...,
    title="Batch Sampling Factory",
    description="Factory for sampling training data batches",
)
beam_width class-attribute instance-attribute
beam_width: int = Field(
    default=3,
    title="Beam Width",
    description="Controls the number of candidate prompts retained after each expansion, balancing exploration and computational efficiency.",
)
eval_profile class-attribute instance-attribute
eval_profile: str = Field(
    ...,
    title="Eval Profile",
    description="The evaluation profile to use for scoring",
)
gradient_chat_render_format class-attribute instance-attribute
gradient_chat_render_format: str = Field(
    default="simple",
    title="Gradient Chat Render Format",
    description="Format used to render agent chat during an evaluation debate, eval chat is used as 'gradients'",
)
gradients_per_sample class-attribute instance-attribute
gradients_per_sample: int = Field(
    default=10, title="Gradients Per Sample", description=""
)
inference_config class-attribute instance-attribute
inference_config: InferenceConfig = Field(
    ..., title="Inference Config", description=__doc__
)
max_gradient_turns class-attribute instance-attribute
max_gradient_turns: int | None = Field(
    default=None,
    title="Max Gradient Turns",
    description="Maximum number of evaluation chat history turns to use in gradient history. When null, use entire eval chat history.",
)
monte_carlo_successors class-attribute instance-attribute
monte_carlo_successors: int = Field(
    default=5,
    title="Monte Carlo Successors",
    description="Number of random successors to to generate during expansion",
)
search_depth class-attribute instance-attribute
search_depth: int = Field(
    default=3,
    title="Search Depth",
    description="The number of iterations the optimization algorithm will run. This controls how deep the search process goes, allowing the algorithm to explore the space of possible inputs progressively.",
)

OptimizeSettings

Bases: BaseDataModel

Settings for the optimize service.

Attributes

chains class-attribute instance-attribute
chains: Dict[str, IoCFactoryModel] = Field(
    default_factory=dict,
    title="Chains",
    description="Chain definitions used by the TextEvolve optimization process",
)
profiles class-attribute instance-attribute
profiles: Dict[str, OptimizeProfile] = Field(
    default_factory=dict,
    title="Profile Factories",
    description="Optimization profile settings",
)

PctBatchSampler

Bases: AbstractBatchSampler

Randomly sample a percentage of the training data

Attributes

p class-attribute instance-attribute
p: float = Field(
    ...,
    gt=0,
    le=1.0,
    title="P",
    description="The percentage of samples to select",
)

Functions

sample
sample(data: List[str]) -> List[str]