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

DSPy Only Predict #567

Merged
merged 26 commits into from
Mar 13, 2024

Conversation

KCaverly
Copy link
Collaborator

@KCaverly KCaverly commented Mar 6, 2024

This PR is intended to get a "DSPy Only Predict" running, ie. No dsp code running.
This is ultimately the point at which the Backend refactor becomes breaking,

TODOs, This includes a few main points:

1. Move over dsp's predict primitives:

  • Greedy & Partial decoding for Templates, allowing the dspy.Template to extract each field regardless of whether all fields were generated successfully.
  • Recursive "healing" for Template based generation calls. Ie. Some generate calls, often do not include all fields.
  • Tests for BackendTemplates with partially completed calls.
  • Ensure parameters for max_tokens, temperature and recursive workflow max_retries` are respected and exposed appropriately.

2. Introduce new DummyLanguageModel for use with the BaseLM.

  • Build backend agnostic Dummy Language Model.
  • Add tests for TemplateBackend generate calls without recovery.
  • Add tests for TemplateBackend generate calls with recovery.

3. Update Predict

  • Remove all stale attributes (lm)
  • Transition away from dsp.Example and dsp.Template to dspy.Example and dspy.Template.
  • Generate new predictions for Backend infrastructure.
  • Expand Predict tests to ensure functionality remains consistent.

Questions

1. Do we expect the 'non-Template' backends to use recursive healing functionality.

I imagine, non-Templates would not need this functionality. I have currently included it within the BaseBackend but it could be pulled out and included within the TemplateBackend only.

2. Load/Dump State for the current dspy.Predict class will be broken with this change.

Ultimately, starting this integration across the different module classes is going to be breaking. Are there specific concerns we have regarding this, how do we want to manage this? Migration details etc. Also is it worth merging the backend implementations earlier than transitioning the Module classes?

Let me know what you think? @CyrusOfEden @okhat.

Copy link
Collaborator

@CyrusNuevoDia CyrusNuevoDia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fantastic man! Really appreciate you. Looks like you went through quite a concept maze to get here and the result shows it.

Pinging @okhat to explain 'stage' in your TODO, had 1 nit. lmk what you think

dspy/backends/template.py Outdated Show resolved Hide resolved
Comment on lines +77 to +78
# TODO: What purpose does stage play here?
# assert self.stage in x, "The generated (input, output) example was not stored"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@okhat can you comment here?

@KCaverly
Copy link
Collaborator Author

KCaverly commented Mar 7, 2024

I decided to sneak in a fleshed out JSONBackend, will add tests such that the Predict works with either backend.

Copy link
Collaborator

@CyrusNuevoDia CyrusNuevoDia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small bug but overall looks great!

dspy/backends/base.py Outdated Show resolved Hide resolved
@KCaverly
Copy link
Collaborator Author

This is done, we have feature parity with DSPy from about a week or two ago, prior to COPRO/MIPRO.
I think we should merge this with the backend-refactor branch, pull main in, and do final tests that way.

We should only be failing on tests for the signature_opt, but that has been replaced by COPRO.

@KCaverly KCaverly marked this pull request as ready for review March 13, 2024 20:28
@CyrusNuevoDia CyrusNuevoDia merged commit 9fa4e12 into stanfordnlp:backend-refactor Mar 13, 2024
1 of 3 checks passed
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.

2 participants