Skip to content

feat: streaming response for HookedTransformer.generate#847

Closed
hijohnnylin wants to merge 5 commits intoTransformerLensOrg:devfrom
hijohnnylin:add_streaming_response_to_generation
Closed

feat: streaming response for HookedTransformer.generate#847
hijohnnylin wants to merge 5 commits intoTransformerLensOrg:devfrom
hijohnnylin:add_streaming_response_to_generation

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.

@bryce13950
Copy link
Collaborator

bryce13950 commented May 7, 2025

Is this still relevant, or are we passing on this in favor of #908?

@hijohnnylin
Copy link
Author

hijohnnylin commented May 7, 2025 via email

@hijohnnylin hijohnnylin closed this May 7, 2025
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

Comments