skillfed

stop-sequencer

Implementation of stop sequencer for Huggingface Transformers

stop-sequencer v1.2.3 77.6K downloads/30d#14,513 on PyPI16
License unclear Abandoned released

What it is and what it does

Stop Sequencer is a wrapper that lets you stop text generation when the model produces a specified stop sequence. You register stop texts (like "Ryan:" or "Kevin:") before calling generate(), and the package attempts to halt output when those patterns appear. However, due to limitations in the underlying implementation, the stop sequence may still appear in the output—you must manually post-process the result to remove it completely.

The package has no runtime dependencies. It works with both causal and seq2seq model types. The main trade-off is that it stops generation after the stop text appears, not before, so you need to strip the unwanted text from the result yourself.

Use it for:

  • Dialogue generation where you want output to stop when a specific speaker's name appears
  • Conditional text generation that should terminate at natural boundaries marked by specific tokens or phrases
  • Multi-turn conversation simulation where each turn should end at a designated marker
  • Controlled generation tasks where output length is bounded by semantic stop conditions rather than token limits alone

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Adds stop-sequence support to Huggingface Transformers text generation, allowing you to halt output when specified text patterns appear.

No. The package is abandoned (last commit 2023-06-06, no activity for 1165 days) and has a critical limitation: stop sequences still appear in output and require manual post-processing. License metadata is unclear. For modern workflows, investigate native alternatives in the underlying framework.

Install

stop-sequencer on PyPI

pip

pip install stop-sequencer

uv

uv add stop-sequencer

poetry

poetry add stop-sequencer

Installing stop-sequencer

Before you install

High install friction with no runtime dependencies. Package is abandoned as of June 2023 with no commits since; last release was 1165 days ago. Maintenance risk is significant for a specialized transformer integration.

License in practice

License treatment is unclear—the description excerpt shows Apache 2.0 text, but the metadata records no SPDX identifier and an empty license_raw field. Verify the actual license before use.

Quickstart

pip install stop-sequencer

from stop_sequencer import StopSequencer

stop_sequencer = StopSequencer(
    model,
    model_type="causal",
    tokenizer=tokenizer,
)
model = stop_sequencer.register_stop_texts(
    stop_texts=["Ryan:"],
    input_length=tokens.size(-1),
)
outputs = model.generate(tokens, max_length=100)

Post-processing of generated text is mandatory due to Transformers API limitations—stop sequences may appear in output and must be manually stripped.

Verify before relying

  • Whether the package works with current versions of transformers (last tested June 2023)
  • Compatibility with modern Huggingface Transformers API changes since abandonment
  • Whether Apache 2.0 license is the actual governing license despite metadata ambiguity

Package facts

License not declared (unclear)
Python support supports the current Python release (>=3)
Install friction high — source build required
Runtime dependencies none
Maintenance abandoned — 1,165 days since the last release
Last repo commit
First released
Downloads 77,572/month — #14,513 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: stop-sequencer-1.2.3.tar.gz

Programming Language :: Python :: 3Programming Language :: Python :: 3.2Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Scientific/Engineering :: Artificial IntelligenceTopic :: Software Development :: Libraries

Tags

stop sequence generation transformershalt text generation at patternearly stopping transformerscontrol generation terminationstop words text generationgeneration stopping criteria
text-generationabandoned

More Libraries packages