Views
No views yet
ByteHybrid (3 × Conv1D → 1 × bidirectional attention with
RoPE → masked mean-pool → classifier head, with a 4096-bucket trigram-hash
embedding), vendored from
PleIAs/CommonLingua (Apache-2.0)
and trained from scratch on Rosetta Code + The Stack v1 across 107 canonical
programming languages.philomath-1209/programming-language-identificationCPUExecutionProvider, batch 64.| model | params | accuracy | macro F1 | weighted F1 | speed |
|---|---|---|---|---|---|
| programming-language-identification-100plus-lite (ONNX) | 2.35 M | 0.9094 | 0.9410 | 0.9361 | 2.37× |
| philomath-1209/programming-language-identification (ONNX) | 84 M | 0.8449 | 0.8445 | 0.8467 | 1.00× |
model.pt fp32 PyTorch checkpoint (CommonLingua format)
model.bf16.pt bf16 sidecar checkpoint (smaller, same accuracy in eval)
lang2idx.json 107-label index
training_metadata.json hyperparameters and dataset stats
training_history.json per-epoch loss / val_acc / val_macro_f1
onnx/
model.onnx ONNX export (opset 20, dynamic batch)
model.onnx.data external weights blob
lang2idx.json (mirror)
onnx_metadata.json parity report vs PyTorch1import torch, numpy as np, sys
2sys.path.append("path/to/code-language-id/src")
3from code_language_id.byte_hybrid import ByteHybrid, CONFIGS
4
5ckpt = torch.load("model.pt", map_location="cpu", weights_only=False)
6model = ByteHybrid(num_classes=ckpt["num_classes"], max_len=ckpt["max_len"],
7 **CONFIGS[ckpt["config"]]).eval()
8model.load_state_dict(ckpt["model_state_dict"])
9idx2lang = {v: k for k, v in ckpt["lang2idx"].items()}
10
11def encode(texts, max_len=ckpt["max_len"]):
12 out = np.full((len(texts), max_len), 256, dtype=np.int64)
13 for i, t in enumerate(texts):
14 b = t.encode("utf-8", errors="replace")[:max_len]
15 out[i, :len(b)] = np.frombuffer(b, dtype=np.uint8)
16 return torch.from_numpy(out)
17
18with torch.no_grad():
19 logits = model(encode(["def hello():\n print('hi')"]))
20print(idx2lang[int(logits.argmax(-1))]) # -> Python1import onnxruntime as ort, numpy as np, json
2
3sess = ort.InferenceSession("onnx/model.onnx", providers=["CPUExecutionProvider"])
4lang2idx = json.load(open("onnx/lang2idx.json"))
5idx2lang = {v: k for k, v in lang2idx.items()}
6MAX_LEN = 1023
7
8def encode(texts, max_len=MAX_LEN):
9 out = np.full((len(texts), max_len), 256, dtype=np.int64)
10 for i, t in enumerate(texts):
11 b = t.encode("utf-8", errors="replace")[:max_len]
12 out[i, :len(b)] = np.frombuffer(b, dtype=np.uint8)
13 return out
14
15logits = sess.run(None, {"byte_ids": encode(["fn main() {}"])})[0]
16print(idx2lang[int(logits.argmax(-1))]) # -> Rustcakiki/rosetta-code) + The Stack v1
(bigcode/the-stack), task-split to prevent leakage.
72,549 / 9,495 / 8,880 rows (train / val / test) across 107 canonical labels.training_metadata.json for the full hyperparameter dump.1@misc{mariappan2026codelangidlite,
2 author = {Mariappan, Vijayachandran},
3 title = {programming-language-identification-100plus-lite: Byte-level Programming Language Identification across 107 Languages},
4 year = {2026},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/FrameByFrame/programming-language-identification-100plus-lite}
7}1@misc{commonlingua,
2 author = {{PleIAs}},
3 title = {CommonLingua: Byte-level Language Identification for 334 Languages},
4 year = {2026},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/PleIAs/CommonLingua}
7}