feat: integrate PleIAs/CommonLingua byte-level LID model#4
Open
malteos wants to merge 1 commit into
Open
Conversation
Adds a `commonlingua` model wired into the registry, backed by a vendored copy of upstream's `model.py` (Apache 2.0, rev 43fe88d) so we don't need `weights_only=False` to load remote pickled code. The model is exposed via a new `[commonlingua]` optional extra that pulls only `torch` (no transformers stack); device selection mirrors AfroLID's MPS > CUDA > CPU. `requires_preprocessing = False` because the byte-level architecture relies on casing as a strong language signal — the OpenLID normer's lowercasing collapses Latin-script predictions. Eval on the full CommonLID dataset (373,230 samples) gives a micro accuracy of 77.58%, matching the model card's 77.63% claim.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds CommonLingua (PleIAs/CommonLingua) as a registered LID model under
model_id = "commonlingua". CommonLingua is a 2.35M-param byte-level model (Apache 2.0) covering 334 languages — it does not fit any existing extra because it ships a custom PyTorch architecture (no HF transformers integration, no tokenizer files).[commonlingua](pulls onlytorch, no transformers stack).model.pyis vendored atsrc/commonlid/vendor/commonlingua/model.py(Apache 2.0, rev43fe88d). Vendoring is preferred overweights_only=False+ remotemodel.pyso we never execute pickled remote code at load time.requires_preprocessing = False— byte-level model relies on casing as a strong language signal; the OpenLID normer's lowercasing collapses Latin-script predictions.Eval results
commonlidcommonlid_nanoThe full-CommonLID accuracy lines up with the model card's 77.63% strict-accuracy claim (delta 0.05%).
Test plan
make lint && make format-check && make typecheckcleanmake test— 237 tests pass, coverage 94.6%commonlid predict --model commonlingua --text "..."returns expected languagecommonlid+commonlid_nanoproduces well-formedsummary.jsonfilesmake leaderboard) renders both new rows🤖 Generated with Claude Code