lumi_language_id
Utilities for reliable-enough language detection.
This is a maintained fork of the original (archived) lumi-language-id,
updated to work with numpy 2.x. It is published on PyPI as
lumi-language-id-2, but the import name stays lumi_language_id:
pip install lumi-language-id-2 # or: uv add lumi-language-id-2
This package wraps fastText's "lid.176" language-detection model with another
classifier, which is trained to produce better probability estimates. When that
probability is below 0.5 the answer is 'und' rather than a probable mistake. It
also applies text cleaning, so that the text it detects is unaffected by
punctuation, digits, or emoji.
Example:
>>> from lumi_language_id.tuned import TunedLanguageIdentifier
>>> lid = TunedLanguageIdentifier.load()
>>> lang, _prob = lid.detect_language("these are words")
>>> lang
'en'
>>> lang, _prob = lid.detect_language("aquí hay algunas palabras")
>>> lang
'es'
Changes in 3.0.0
- Long Chinese and Japanese text is no longer rejected. The original classifier
was trained on tweets and Wikipedia introductions and withheld fastText's
correct answer on long, spaceless CJK text: 47.7% of Mandarin web documents
and 64.8% of one Chinese financial corpus came back
'und'. It is now trained on FineWeb-2 and FineWeb, in full documents and short windows, with each language weighted by how much text it has on the web. - Kana-free simplified Chinese is no longer called Japanese. fastText labels
some short Chinese sentences
'ja'. A'ja'answer is replaced by the most likely Chinese label only when the text has no kana and contains a character that does not exist in Japanese (艺,发, but not shared kanji such as京), so kanji-only Japanese still reads as Japanese. align_to_fasttext(language, script)maps a language code to the fastText label for exactly that language, or'und'. The olderalign_language_to_fasttextaccepts a nearby language, so Cherokee and Hawaiian map to'en'.- The classifier knows which language fastText predicted. Its features now
include the web size of the predicted language, so a
'zh'answer on Mandarin (right 98% of the time) is no longer judged like one on Cantonese (right 2%). - Cost: on short text (10 to 500 characters) in common Latin-script languages,
a correct answer is withheld as
'und'somewhat more often (English 2.6% to 5.1%). Full documents are unaffected. LANGUAGES.md gives the measured behaviour for every language. - Breaking: the saved classifier is format version 2 (five features, counts log-scaled), and version 1 files are refused rather than silently misread. Some inputs get a different label than in 2.0.0 (kana-free Chinese, above).
See LANGUAGES.md for per-language accuracy, TRAINING.md to rebuild the classifier, and INSTRUCTIONS.md for development setup and publishing.
Data
The classifier is trained on samples of FineWeb-2 and FineWeb (English), both released by Hugging Face under the ODC-By 1.0 license. The training text itself is not redistributed; only the fitted classifier weights ship with the package.
Metadata
Release files for lumi-language-id-2 3.0.1
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 |
|---|---|---|---|---|
| lumi_language_id_2-3.0.1.tar.gz | 1.1 MB | Without provenance | Details for lumi_language_id_2-3.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lumi_language_id_2-3.0.1-py3-none-any.whl | Python 3 | none | any | Details for lumi_language_id_2-3.0.1-py3-none-any.whl |
Total release size: 1.9 MB
Release files / lumi_language_id_2-3.0.1.tar.gz
| Download URL | lumi_language_id_2-3.0.1.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7854e3f31505b6e0f6a227544b4a110cc80039cad5f742a01b64f097a50cf7b
|
|
BLAKE2b-256 checksum How to use checksums |
74e28089d14befee82972bec406f33e8a1f04f8f898c88cf0d16a17ab52dc52f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / lumi_language_id_2-3.0.1-py3-none-any.whl
| Download URL | lumi_language_id_2-3.0.1-py3-none-any.whl |
|---|---|
| Size | 800.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
db31d165532b611e493ea216a2fb3d8bbbe995698e8cdaf608180dfff97d7065
|
|
BLAKE2b-256 checksum How to use checksums |
ac417b311b9e5b4a048b4667f62fd76b007b4382334f9abe98d1f67dc622968e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for lumi-language-id-2 3.0.1
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.