Skip to main content

transformers-stream-generator

PyPI - Python Version PyPI GitHub license badge Blog

Description

This is a text generation method which returns a generator, streaming out each token in real-time during inference, based on Huggingface/Transformers.

Web Demo

  • original
  • stream

Installation

pip install transformers-stream-generator

Usage

  1. just add two lines of code before your original code
from transformers_stream_generator import init_stream_support
init_stream_support()
  1. add do_stream=True in model.generate function and keep do_sample=True, then you can get a generator
generator = model.generate(input_ids, do_stream=True, do_sample=True)
for token in generator:
    word = tokenizer.decode(token)
    print(word)

Example

Metadata

Release files for transformers-stream-generator 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for transformers-stream-generator 0.0.5
File Size Uploaded Provenance Actions
transformers-stream-generator-0.0.5.tar.gz 13.0 kB Without provenance Details for transformers-stream-generator-0.0.5.tar.gz

Release files / transformers-stream-generator-0.0.5.tar.gz

Download URL transformers-stream-generator-0.0.5.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
271deace0abf9c0f83b36db472c8ba61fdc7b04d1bf89d845644acac2795ed57
BLAKE2b-256 checksum
How to use checksums
42c265f13aec253100e1916e9bd7965fe17bde796ebabeb1265f45191ab4ddc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Security for transformers-stream-generator 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page