Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap KNN with Random Search #1825

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

CyrusNuevoDia
Copy link
Collaborator

@CyrusNuevoDia CyrusNuevoDia commented Nov 19, 2024

Current KNNFewShot

Compile Time: Vectorize trainset examples
Test Time:

  1. When encountering a new example (which is the typical case)
  2. Run BootstrapFewShot to test out different static few-shot demos for each predictor using KNN'd examples as trainset
  3. Find the best program of static few-shot examples

New BootstrapKNN

Compile Time: Run BootstrapFewShot to collect traces and generate end-to-end demo sets
Test Time:
When a predictor is called, KNN of the input are few-shotted using the augmented demos for that predictor

New BootstrapKNNWithRandomSearch

Compile Time:

  1. Try zero-shot
  2. Try LabeledFewShot
  3. Try BootstrapKNN
  4. Try BootstrapKNN with random # of static demos fixed using the augmented demos for that predictor, and that predictor's demos are shuffled(static demos + knn demos)

Test Time:
When a predictor is called, KNN of the input are few-shotted using the augmented demos for that predictor. If num_static_demos ≠ 0, then that predictor's demos are shuffled(static demos + knn demos) such that len(static demos + knn demos) == max_labeled_demos

@CyrusNuevoDia CyrusNuevoDia force-pushed the bootstrap-knn-few-shot-with-random-search branch from fb2c355 to c8d3d98 Compare November 20, 2024 15:57
@CyrusNuevoDia CyrusNuevoDia marked this pull request as ready for review November 20, 2024 16:49
@CyrusNuevoDia CyrusNuevoDia requested a review from okhat November 20, 2024 16:56
ammirsm and others added 6 commits November 21, 2024 19:59
- Implement `__init__` method in `Embedding` class to accept an optional `api_key`.
- Update embedding call to include `api_key` parameter when invoking the embedding model.
- Enhance `BootstrapKNN` demo selection process by creating a list of dynamic demos.
- Add new dependencies in requirements file for project requirements.
…om-search' into bootstrap-knn-few-shot-with-random-search

# Conflicts:
#	dspy/predict/predict.py
#	dspy/teleprompt/bootstrap.py
#	dspy/teleprompt/random_search.py
#	testing/playbook.ipynb
…m:stanfordnlp/dspy into bootstrap-knn-few-shot-with-random-search
@ryanh-ai
Copy link

Excited to see this merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants