stanfordnlp / dspy

DSPy: The framework for programming—not prompting—foundation models
https://dspy-docs.vercel.app/
MIT License
13.82k stars 1.06k forks source link

fix(MiproV2): custom view_data_batch_size for dataset summary creation #1217

Open shubham-skr opened 3 days ago

shubham-skr commented 3 days ago

Scenario: When compiling with MiproV2, my large trainset examples led to an error - model context limit exceeded. To address this, I set a custom view_data_batch_size. However, the error persisted as the parameter value was not reflected during dataset summary generation.

Problem: The custom view_data_batch_size is not applied during the creation of the dataset summary in GroundedProposer. This occurs because the create_dataset_summary() function within the GroundedProposer defaults to a predefined batch size, ignoring the custom view_data_batch_size parameter value.

image image

Solution: The solution involves passing the view_data_batch_size parameter to GroundedProposer in MiproV2, ensuring it is utilized when create_dataset_summary() is called in GroundedProposer.

Testing: Verified that the changes made in this PR successfully resolve this issue and the view_data_batch_size parameter set upon initialization of MIPROv2 optimizer is getting used for dataset summary generation. (Also, if not set by the user then it uses the default value of 10 defined in MIRPOv2 class).

Feel free to adjust the specifics as needed to better match the project's requirements or to add additional information.

shubham-skr commented 12 hours ago

Yeah, that would be great. Thanks @XenonMolecule.