Views
No views yet
B (beginning of a group), I (inside a group), O (outside / delimiter). The output is reconstructed into grouped sentences using __ as the group boundary separator.1from transformers import AutoTokenizer, AutoModelForTokenClassification
2import torch
3
4model_name = "manavdhamecha77/WG-GoogleMuril"
5
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForTokenClassification.from_pretrained(model_name)
8
9device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
10model.to(device)
11
12sentence = "राम ने बाजार से सब्जियां खरीदीं।"
13
14inputs = tokenizer(sentence, return_tensors="pt", truncation=True, max_length=128).to(device)
15
16with torch.no_grad():
17 outputs = model(**inputs)
18
19predictions = torch.argmax(outputs.logits, dim=-1)[0].tolist()
20tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0])
21
22# Label map: {0: "B", 1: "I", 2: "O"}
23id2label = {0: "B", 1: "I", 2: "O"}
24
25for token, pred in zip(tokens, predictions):
26 if token not in ["[CLS]", "[SEP]", "[PAD]"]:
27 print(f"{token:20s} {id2label[pred]}")AutoModelForTokenClassification with a class-weighted cross-entropy loss to address the dominant O-label imbalance (inverse-frequency weights upweight B and I labels). Labels are aligned to subword tokens using the tokenizer's word_ids() helper; only the first subword of each word is labeled, with subsequent subwords set to -100.| Parameter | Value |
|---|---|
| Optimizer | AdamW |
| Learning Rate | 3×10⁻⁵ |
| Batch Size | 8 (train/eval) |
| Epochs | 20 |
| Weight Decay | 0.01 |
| Label Map | B:0, I:1, O:2 |
| Hardware | H100 GPU (94GB) |
| Model | Dev EM (%) | Test EM (%) |
|---|---|---|
| MuRIL (this model) | 46.58 | 58.18 |
| XLM-Roberta | 39.00 | 53.36 |
| IndicBERT v2 | 35.40 | 52.73 |
1@inproceedings{dhamecha2025horizonwg,
2 title = {Team Horizon at {BHASHA} Task 2: Fine-tuning Multilingual Transformers for Indic Word Grouping},
3 author = {Dhamecha, Manav and Damor, Gaurav and Choudhary, Sunil and Mishra, Pruthwik},
4 booktitle = {Proceedings of the 1st Workshop on Benchmarks, Harmonization, Annotation, and Standardization for Human-Centric AI in Indian Languages (BHASHA 2025)},
5 year = {2025},
6 url = {https://aclanthology.org/2025.bhasha-1.18/}
7}