Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
3f96e0b4
Unverified
Commit
3f96e0b4
authored
Apr 07, 2023
by
Joao Gante
Committed by
GitHub
Apr 07, 2023
Browse files
Generate: add API warning to streamers (#22659)
add API warning
parent
f3341926
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
docs/source/en/generation_strategies.mdx
docs/source/en/generation_strategies.mdx
+6
-0
src/transformers/generation/streamers.py
src/transformers/generation/streamers.py
+12
-0
No files found.
docs/source/en/generation_strategies.mdx
View file @
3f96e0b4
...
...
@@ -145,6 +145,12 @@ The `generate()` supports streaming, through its `streamer` input. The `streamer
from a class that has the following methods: `put()` and `end()`. Internally, `put()` is used to push new tokens and
`end()` is used to flag the end of text generation.
<Tip warning={true}>
The API for the streamer classes is still under development and may change in the future.
</Tip>
In practice, you can craft your own streaming class for all sorts of purposes! We also have basic streaming classes
ready for you to use. For example, you can use the [`TextStreamer`] class to stream the output of `generate()` into
your screen, one word at a time:
...
...
src/transformers/generation/streamers.py
View file @
3f96e0b4
...
...
@@ -39,6 +39,12 @@ class TextStreamer(BaseStreamer):
"""
Simple text streamer that prints the token(s) to stdout as soon as entire words are formed.
<Tip warning={true}>
The API for the streamer classes is still under development and may change in the future.
</Tip>
Parameters:
tokenizer (`AutoTokenizer`):
The tokenized used to decode the tokens.
...
...
@@ -128,6 +134,12 @@ class TextIteratorStreamer(TextStreamer):
useful for applications that benefit from acessing the generated text in a non-blocking way (e.g. in an interactive
Gradio demo).
<Tip warning={true}>
The API for the streamer classes is still under development and may change in the future.
</Tip>
Parameters:
tokenizer (`AutoTokenizer`):
The tokenized used to decode the tokens.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment