Skip to content

feat: streaming response for HookedTransformer.generate #847

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

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

hijohnnylin
Copy link

Description

This adds a stream_output flag (default False) to HookedTransformer.generate which streams the tokens as they're generated, instead of waiting for the whole result to be generated first.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have not rewritten tests relating to key interfaces which would affect backward compatibility

@hijohnnylin
Copy link
Author

still a draft as I have not written docs, tests, etc.

@hijohnnylin
Copy link
Author

hijohnnylin commented Jan 31, 2025

the current implementation breaks existing calls where stream_output is false because yield forces the method to become a Generator even if that code path is not used. for now just copying the method.

@bryce13950 bryce13950 changed the base branch from main to dev February 3, 2025 22:57
@bryce13950
Copy link
Collaborator

Very nice! Looking forward to messing around with this. I will keep an eye out for a test, and then we can get it into a build right away.

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