|
|
TextSlinger: Fast and Accurate Text Predictions in Python |
TextSlinger predicts characters and words from accepted text and optional noisy input observations. It supports character n-grams through KenLM, Prediction by Partial Matching (PPM), Hugging Face subword language models, and Byte Latent Transformer (BLT).
Use it to build predictive text-entry applications, score supplied strings, or evaluate prediction quality and latency. Results include probability evidence and bounds on uncertainty left by a limited search.
Getting started
TextSlinger requires Python 3.12 or newer. Python 3.13 is recommended for new environments.
Follow the
installation guide to install the library, choose a PyTorch build for your
device, and download any model assets you need. The base install (pip install textslinger) supports
PPM without PyTorch or KenLM. Install textslinger[ngram] for KenLM or textslinger[llm] for neural
models; evaluation scripts use textslinger[eval].
This small PPM example trains from text and needs no downloaded model:
from textslinger import PPM
model = PPM.from_training_texts(["the cat sat ", "the car stopped "])
characters = model.predict_characters(
left_context="the ca",
output_characters=tuple("abcdefghijklmnopqrstuvwxyz "),
)
words = model.predict_words(left_context="the ca", nbest=3)
print([prediction.character for prediction in characters.top(3)])
print([prediction.word for prediction in words.predictions])
Every character request specifies its output alphabet. Word requests can restrict spellings, endings and vocabulary, or supply likelihoods for uncertain input. See the prediction API for examples, result interpretation, quantized model loading and cancellation.
Capabilities and limits
- Character prediction supports Unicode output across token boundaries for supported byte tokenizers. Unicode word prediction has narrower support; see Unicode scope.
- Word prediction supports autocomplete, complete-input recognition, and mixtures of the two. Noisy observations describe input after the accepted context, rather than replacing that context.
- Search bounds describe unexplored probability mass within the model's conditioning policy. They do not bound every source of numerical or tokenization error; see probability bounds.
- Optional compilation prepares frequently used subword-model calculations before serving
requests. Long-running applications can use
prepare_compilation(). Uncovered cases use ordinary inference without compiling during a request.
Documentation
| Guide | Contents |
|---|---|
| Installation | Environments, dependencies and model assets |
| Prediction API | Model construction, requests, results and cancellation |
| Scripts | Evaluation, simulation and profiling commands |
| Tests | Backend checks, precision and regression references |
| Subword engine | Search algorithms, caching, compilation and diagnostics |
| Optimization decisions | Measured benefits, limitations and rejected approaches |
| Mathematical overview | Inference model with a touchscreen example |
| Mathematical implementation | How the model maps to code |
For HTTP and WebSocket serving, use TextSlinger Server.
This material is based upon work supported by the NSF under Grant No. IIS-1909089 and IIS-2402876.
Metadata
Release files for textslinger 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| textslinger-0.5.0.tar.gz | 309.6 kB | Without provenance | Details for textslinger-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| textslinger-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for textslinger-0.5.0-py3-none-any.whl |
Total release size: 600.5 kB
Release files / textslinger-0.5.0.tar.gz
| Download URL | textslinger-0.5.0.tar.gz |
|---|---|
| Size | 309.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0289b2e13627d0e02696fa32cbffed6d4ab9c3c1aa31aa56b48d9c73cfa3e0a
|
|
BLAKE2b-256 checksum How to use checksums |
dacd5f682ea78f0a95b848298c69c87199cae1c3ab9fe668d447460561908515
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.13.18
|
Release files / textslinger-0.5.0-py3-none-any.whl
| Download URL | textslinger-0.5.0-py3-none-any.whl |
|---|---|
| Size | 290.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a890ccb94c98026794a149aa31c266ba14012f1bbd4910b6039783def86d2679
|
|
BLAKE2b-256 checksum How to use checksums |
b245b32b5fc9c7a2659bb5fcbb75e6480c6441464c2dcf48fc0fa724300f511c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.13.18
|
Security for textslinger 0.5.0
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.