Run this model with HF Jobs
Run litert-community/EdgeCoder-Multilingual-61M on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/litert-community/EdgeCoder-Multilingual-61M. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/litert-community/EdgeCoder-Multilingual-61M on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use litert-community/EdgeCoder-Multilingual-61M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/EdgeCoder-Multilingual-61M with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Add the EdgeCoder-Multilingual-61M LiteRT graph, example script and card
Browse filesFiles changed (4)
- LICENSEAdded+202
- README.mdAdded+122
- edgecoder_encode_128_fp32.tfliteAdded+3
- example.pyAdded+104
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122---license: apache-2.0language:- multilingual- en- ru- zh- es- de- fr- ja- it- pt- pl- nl- vi- id- ar- cs- tr- hu- sv- ro- uk- ko- el- "no"- da- fi- sk- bg- hi- hr- bs- lt- sl- he- bn- sr- lv- et- ms- ur- mk- la- be- mt- sw- ga- yipipeline_tag: feature-extractionbase_model: knowledgator/EdgeCoder-Multilingual-61Mbase_model_relation: quantizedlibrary_name: literttags:- litert- tflite- on-device- feature-extraction- multilingual---
# EdgeCoder-Multilingual-61M for LiteRT
This repository holds [knowledgator/EdgeCoder-Multilingual-61M](https://huggingface.co/knowledgator/EdgeCoder-Multilingual-61M), the author's multilingual text encoder for 46 languages, converted without quantization to one float32 LiteRT graph for the CPU. The graph takes 128 tokens and returns a feature vector of 384 values for each of them. On a Pixel 8a CPU with LiteRT 2.2.0 set to 4 threads, one run of the graph took 193.4 ms (median of 20 runs, 2026-12-05). Speed still being tuned (updates follow).
Run it with Python on a computer (we ran `example.py` on an arm64 Mac):
```bashpip install ai-edge-litert==2.2.0 transformers numpy huggingface_hubhf download litert-community/EdgeCoder-Multilingual-61M --local-dir EdgeCoder-Multilingual-61Mcd EdgeCoder-Multilingual-61Mpython example.py 'EdgeCoder — компактний багатомовний енкодер.' '小さなモデルで多言語の文章を処理する。'```
In an Android app, give the graph the inputs listed under [The graph](#the-graph).
On a Pixel 8a, LiteRT 2.2.0 could not compile the graph for the GPU (2026-12-05). Its log lists `GATHER_ND` among the operations the GPU delegate does not support. Run the graph on the CPU. The input is fixed at 128 tokens (the author's model takes up to 8192 tokens): shorter text is padded and longer text is cut. As the author's card says, the model is a backbone that needs fine-tuning for classification, token classification, retrieval or embedding tasks.
## Example output
`example.py` loads the author's tokenizer from the author's repository, knowledgator/EdgeCoder-Multilingual-61M, at revision `d2b4066c768e16b763c0693f6ad474c520ce64e3`. `--tokenizer <folder>` loads a local copy instead. The script runs the graph on the CPU with ai-edge-litert and averages the features of each text's real tokens into one vector.
On 2026-12-05, in a new Python 3.12.13 environment on an arm64 Mac, where the `pip install` line above installed ai-edge-litert 2.2.0, transformers 5.26.0, numpy 2.5.5 and huggingface_hub 2.6.0, the `example.py` command above printed this:
```texttext 1 per-token features shape: (1, 128, 384)text 1 mean-pooled first 6: [0.344991, 0.238103, -0.290134, 0.122885, 0.141884, -0.251515]text 1 mean-pooled L2 norm: 4.802272text 2 per-token features shape: (1, 128, 384)text 2 mean-pooled first 6: [0.346773, 0.213815, -0.305823, 0.085307, 0.165460, -0.211308]text 2 mean-pooled L2 norm: 4.899470cosine similarity: 0.954984```
## The graph
`edgecoder_encode_128_fp32.tflite` (264,419,180 bytes) has the signature `encode_128`:
| | name | type | size | meaning ||---|---|---|---|---|| input | `input_ids` | int32 | [1, 128] | token ids from the author's tokenizer, padded or cut to 128 || input | `attention_mask` | int32 | [1, 128] | 1 for a real token, 0 for padding || output | `last_hidden_state` | float32 | [1, 128, 384] | a feature vector of 384 values for each token |
## Accuracy
On 2026-12-05, the graph's features for all 217 real tokens of eight test inputs matched the author's model on an arm64 Mac CPU (ai-edge-litert 2.2.0) and on a Pixel 8a CPU (LiteRT 2.2.0), both set to 1 thread. Every feature value met `|LiteRT − reference| ≤ 2e-4 + 1e-4 × |reference|`.
The reference is the author's model, run in float32 on an arm64 Mac CPU with PyTorch 2.7.1 and transformers 4.52.4. The eight inputs of 128 tokens are the example sentence of the author's card, a Japanese sentence, an Arabic sentence, a text that mixes scripts with whitespace and code, an empty text, a text of special-token strings, a Spanish–Korean text pair, and a long text cut to 128 tokens.
## Speed
The 193.4 ms median at the top comes from an Android app that ran the graph with LiteRT 2.2.0's `CompiledModel` API on a Pixel 8a CPU on 2026-12-05. We set the runtime to 4 threads and did not read back how many it used. After 5 warm-up runs, the 20 timed runs on the example sentence of the author's card took between 165.3 and 278.4 ms each. The times exclude writing the inputs and reading the output.
## How it was made
We converted the author's checkpoint at revision `d2b4066c768e16b763c0693f6ad474c520ce64e3` to LiteRT with litert-torch 0.9.4, PyTorch 2.13.0 and transformers 5.14.1.
## License
The files in this repository are under the Apache License 2.0, the license that [the author's card](https://huggingface.co/knowledgator/EdgeCoder-Multilingual-61M) declares for the model. [`LICENSE`](https://huggingface.co/litert-community/EdgeCoder-Multilingual-61M/blob/main/LICENSE) is the Apache License 2.0 text. The tokenizer is not in this repository: it comes from the author's repository. Credit for the model goes to Knowledgator Engineering, and the author's card gives the citation of their paper.123version https://git-lfs.github.com/spec/v1oid sha256:67059d70e14edaa681e8cf3c4360bf65018c2f9db9e09c7fa053776e4bc4bef5size 264419180123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104"""Run the FP32 EdgeCoder encode_128 LiteRT graph on the CPU.
Requires ai-edge-litert, numpy, and transformers.Place the graph beside this script or pass its path with --model.Use --tokenizer with a local copy of the pinned tokenizer for offline runs."""
import argparsefrom pathlib import Path
import numpy as np
TOKENIZER_REPO = "knowledgator/EdgeCoder-Multilingual-61M"TOKENIZER_REVISION = "d2b4066c768e16b763c0693f6ad474c520ce64e3"GRAPH_NAME = "edgecoder_encode_128_fp32.tflite"SEQUENCE_LENGTH = 128
def load_tokenizer(source): from transformers import AutoTokenizer
return AutoTokenizer.from_pretrained( source, revision=TOKENIZER_REVISION if source == TOKENIZER_REPO else None, local_files_only=Path(source).is_dir(), trust_remote_code=False, use_fast=True, padding_side="right", truncation_side="right", )
def open_encoder(model_path): from ai_edge_litert.interpreter import Interpreter
interpreter = Interpreter(model_path=str(model_path), num_threads=1) return interpreter.get_signature_runner("encode_128")
def encode_text(encoder, tokenizer, text): tokens = tokenizer( text, padding="max_length", truncation=True, max_length=SEQUENCE_LENGTH, return_attention_mask=True, return_token_type_ids=False, return_tensors="np", ) inputs = { name: tokens[name].astype(np.int32, copy=False) for name in ("input_ids", "attention_mask") } return encoder(**inputs)["last_hidden_state"], inputs
def main(): parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) parser.add_argument("text", help="first text to encode") parser.add_argument("second_text", nargs="?", help="optional second text to encode") parser.add_argument( "--model", type=Path, default=Path(__file__).absolute().with_name(GRAPH_NAME), help="path to the FP32 LiteRT graph (default: beside this script)", ) parser.add_argument( "--tokenizer", default=TOKENIZER_REPO, help="tokenizer directory or Hugging Face repository (default: the author's pinned revision)", ) args = parser.parse_args() if not args.model.is_file(): parser.error(f"model file not found: {args.model}")
tokenizer = load_tokenizer(args.tokenizer) encoder = open_encoder(args.model) texts = (args.text,) if args.second_text is None else (args.text, args.second_text) pooled_vectors = [] norms = [] for number, text in enumerate(texts, start=1): features, inputs = encode_text(encoder, tokenizer, text) valid = inputs["attention_mask"][0].astype(bool) if not valid.any(): parser.error(f"text {number} has no valid tokens") # The raw encoder is a backbone for fine-tuning. Pool valid rows to illustrate its features. pooled = features[0, valid].mean(axis=0) norm = float(np.linalg.norm(pooled)) first_values = ", ".join(f"{value:.6f}" for value in pooled[:6]) print(f"text {number} per-token features shape: {features.shape}") print(f"text {number} mean-pooled first 6: [{first_values}]") print(f"text {number} mean-pooled L2 norm: {norm:.6f}") pooled_vectors.append(pooled) norms.append(norm)
if len(pooled_vectors) == 2: denominator = norms[0] * norms[1] if denominator == 0: print("cosine similarity: undefined (zero-norm vector)") else: cosine = float(np.dot(*pooled_vectors)) / denominator print(f"cosine similarity: {np.clip(cosine, -1.0, 1.0):.6f}")
if __name__ == "__main__": main()LICENSEAdded+202
README.mdAdded+122
edgecoder_encode_128_fp32.tfliteAdded+3
example.pyAdded+104