stop-sequencer
Implementation of stop sequencer for Huggingface Transformers
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-sequenceruv
uv add stop-sequencerpoetry
poetry add stop-sequencerInstalling 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
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
transformers-stream-generatorModifies Hugging Face Transformers…
permissive · top 15,000 on PyPI
lm-format-enforcerConstrains language model token generation to…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-transformersAdds distributed tracing to HuggingFace…
permissive · top 5,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
tokieA fast, Rust-backed tokenizer library that…
permissive · top 15,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
sentence-transformersComputes embeddings and reranking scores for…
permissive · top 1,000 on PyPI
adaptersAdapters adds parameter-efficient fine-tuning…
permissive · top 15,000 on PyPI
semchunksemchunk splits text into semantically…
permissive · top 5,000 on PyPI
pytorch-pretrained-bertProvides PyTorch implementations of BERT, GPT,…
permissive · top 15,000 on PyPI