Skip to content

Commit

Permalink
Generate: add API warning to streamers (huggingface#22659)
Browse files Browse the repository at this point in the history
add API warning
  • Loading branch information
gante authored Apr 7, 2023
1 parent f334192 commit 3f96e0b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/source/en/generation_strategies.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions src/transformers/generation/streamers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 3f96e0b

Please sign in to comment.