Open darinkishore opened 6 months ago
f34240e60d
)Here are the sandbox execution logs prior to making any changes:
94d03ce
Checking docs/teleprompters/teleprompters.md for syntax errors... ✅ docs/teleprompters/teleprompters.md has no syntax errors!
1/1 ✓Checking docs/teleprompters/teleprompters.md for syntax errors... ✅ docs/teleprompters/teleprompters.md has no syntax errors!
Sandbox passed on the latest main
, so sandbox checks will be enabled for this issue.
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
docs/teleprompters/teleprompters.md
✓ https://github.com/darinkishore/dspy/commit/e344da508577d549d00d057789e8d1b41cd649eb Edit
Modify docs/teleprompters/teleprompters.md with contents:
• Review the code for each class in the `/dspy/teleprompt/*` directory.
• Update the description of each class in the `teleprompters.md` file to accurately reflect the current functionality of the class. This includes the `LabeledFewShot`, `BootstrapFewShot`, `Ensemble`, `BootstrapFewShotWithRandomSearch`, and `BootstrapFinetune` classes.
• Update the description of the constructor for each class. This includes the purpose of the constructor and the parameters it accepts.
• Update the description of the methods for each class. This includes the purpose of the method, the parameters it accepts, and what it returns.
• Update the examples for each class to ensure they accurately demonstrate how to use the class and its methods.
• Ensure that the documentation is clear, concise, and easy to understand.
--- +++ @@ -18,7 +18,7 @@ ### Constructor -The constructor initializes the `LabeledFewShot` class and sets up its attributes, particularly defining `k` number of samples to be used by the predictor. +The constructor initializes the `LabeledFewShot` class with the specified number of demos `k` to be used for each predictor. If `sample` is `True`, this number of demos will be chosen randomly from the `trainset`. Otherwise, the first `k` demos from the `trainset` will be selected. to be used by the predictor. ```python class LabeledFewShot(Teleprompter): @@ -33,11 +33,12 @@ #### `compile(self, student, *, trainset)` -This method compiles the `LabeledFewShot` instance by configuring the `student` predictor. It assigns subsets of the `trainset` in each student's predictor's `demos` attribute. If the `trainset` is empty, the method returns the original `student`. +This method compiles the `LabeledFewShot` instance by preparing the `student` module with demo samples from the `trainset` for each of the student's predictors. It decides whether to sample randomly from the training demoes or to take the first `k` demoes based on the `sample` parameter. `k` denotes the limit on the number of demoes to use, which was set during the construction of the `LabeledFewShot` instance. It assigns subsets of the `trainset` in each student's predictor's `demos` attribute. If the `trainset` is empty, the method returns the original `student`. **Parameters:** - `student` (_Teleprompter_): Student predictor to be compiled. -- `trainset` (_list_): Training dataset for compiling with student predictor. +- `trainset` (_list_): A list of example objects to be used as training demos. +- `sample` (_bool_, optional): Determines if the demos should be randomly sampled from the `trainset`. Defaults to `True`. **Returns:** - The compiled `student` predictor with assigned training samples for each predictor or the original `student` if the `trainset` is empty. @@ -121,9 +122,9 @@ #Assume defined RAG class ... -#Define teleprompter and include teacher + teacher = dspy.OpenAI(model='gpt-3.5-turbo', api_key = openai.api_key, api_provider = "openai", model_type = "chat") -teleprompter = BootstrapFewShot(teacher_settings=dict({'lm': teacher})) + # Compile! compiled_rag = teleprompter.compile(student=RAG(), trainset=trainset) @@ -141,8 +142,8 @@ ``` **Parameters:** -- `reduce_fn` (_callable_, _optional_): Function used to reduce multiple outputs from different programs into a single output. A common choice is `dspy.majority`. Defaults to `None`. -- `size` (_int_, _optional_): Number of programs to randomly select for ensembling. If not specified, all programs will be used. Defaults to `None`. +- `reduce_fn` (_callable_, _optional_): Function used to reduce multiple outputs from different programs into a single output. A common choice is `dspy.majority`. If set to `None`, all sampled outputs will be returned as a list. Defaults to `None`. +- `size` (_int_, _optional_): Number of programs to randomly select for ensembling if not all programs are to be used for reduction. If not specified, all programs will be used. Defaults to `None`. - `deterministic` (_bool_, _optional_): Specifies whether ensemble should operate deterministically. Currently, setting this to `True` will raise an error as this feature is pending implementation. Defaults to `False`. ### Method @@ -180,7 +181,7 @@ The constructor initializes the `BootstrapFewShotWithRandomSearch` class and sets up its attributes. It inherits from the `BootstrapFewShot` class and introduces additional attributes for the random search process. ```python -class BootstrapFewShotWithRandomSearch(BootstrapFewShot): +class BootstrapFewShotWithRandomSearch(LabeledFewShot): def __init__(self, metric, teacher_settings={}, max_bootstrapped_demos=4, max_labeled_demos=16, max_rounds=1, num_candidate_programs=16, num_threads=6): self.metric = metric self.teacher_settings = teacher_settings @@ -272,7 +273,7 @@ ```python #Assume defined trainset -#Assume defined RAG class +# Assume the RAG class is already defined as shown earlier ... #Define teleprompter
docs/teleprompters/teleprompters.md
✓ Edit
Check docs/teleprompters/teleprompters.md with contents:
Ran GitHub Actions for e344da508577d549d00d057789e8d1b41cd649eb:
I have finished reviewing the code for completeness. I did not find errors for sweep/update_teleprompt_documentation
.
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord
Please update the
teleprompters.md
documentation indocs/teleprompters
. This documentation is based on/dspy/teleprompt/*
.Good luck. Please be thorough and comprehensive.
Checklist
- [X] Modify `docs/teleprompters/teleprompters.md` ✓ https://github.com/darinkishore/dspy/commit/e344da508577d549d00d057789e8d1b41cd649eb [Edit](https://github.com/darinkishore/dspy/edit/sweep/update_teleprompt_documentation/docs/teleprompters/teleprompters.md#L2-L282) - [X] Running GitHub Actions for `docs/teleprompters/teleprompters.md` ✓ [Edit](https://github.com/darinkishore/dspy/edit/sweep/update_teleprompt_documentation/docs/teleprompters/teleprompters.md#L2-L282)