Run this model with HF Jobs
Run Kashif786/Sindhi-DistilmBERT-MultiTask 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/Kashif786/Sindhi-DistilmBERT-MultiTask. 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/Kashif786/Sindhi-DistilmBERT-MultiTask 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 Kashif786/Sindhi-DistilmBERT-MultiTask with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Kashif786/Sindhi-DistilmBERT-MultiTask with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="Kashif786/Sindhi-DistilmBERT-MultiTask")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("Kashif786/Sindhi-DistilmBERT-MultiTask") model = AutoModel.from_pretrained("Kashif786/Sindhi-DistilmBERT-MultiTask", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Sindhi-DistilmBERT-MultiTask (Joint NER + POS + Sentiment Encoder)
Kashif786/Sindhi-DistilmBERT-MultiTask is a 147.80M-parameter, vocabulary-extended Distil-mBERT encoder fine-tuned jointly via Multi-Task Learning (MTL) for three core 52-letter Perso-Arabic Sindhi (sd) NLP tasks in a single forward pass:
- Named Entity Recognition (NER) —
23BIO tags across11entity types (PERSON,GPE,LOC,ORG,FAC,EVENT,ART,LANGUAGE,NORP,TITLE,OTHERS). - Part-of-Speech Tagging (POS) —
18Sindhi UPOS/morphosyntactic tags (NOUN,PROPN,VERB,AUX,ADJ,ADV,ADP,PRON,DET,CONJ,SCON,NUM,INTJ,SYM,PUNC,PERIOD,X,AdJ). - Sentiment Analysis — Binary sequence classification (
0: Negative,1: Positive) via[CLS]pooling.
Architecture Overview
flowchart TD
A["Sindhi Input Text (52-Letter Script)"] --> B["Extended Sindhi WordPiece Tokenizer (136,521 vocab, 0 UNK)"]
B --> C["Shared DistilBertModel Encoder (6 Layers, 768 Hidden, 12 Heads, 147.80M Params)"]
C --> D["ner_head: Linear(768 -> 23) | Token-Level BIO NER"]
C --> E["pos_head: Linear(768 -> 18) | Token-Level POS Tagging"]
C --> F["sent_head: Linear(768 -> 2) | Sequence-Level [CLS] Sentiment"]
| Property | Value |
|---|---|
| Developer | Kashif Ali Turk (Kashif786) — Supervised by Dr. Tafseer Ahmed (MAJU) |
| Backbone | Extended DistilBertModel (6 layers, 768 hidden dim, 12 attention heads, 3,072 FFN) |
| Vocabulary Size | 136,521 (119,547 base mBERT + 16,974 Sindhi WordPiece tokens; 0 [UNK] on Sindhi) |
| Total Parameters | 147,803,179 (147.80M, float32, 591.3 MB) |
| Multi-Task Heads | ner_head ([23, 768]), pos_head ([18, 768]), sent_head ([2, 768]) |
| Max Position Embeddings | 512 (trained with max_length=128) |
| License | Apache 2.0 |
Important Loading Note: Because this checkpoint uses three custom parallel task heads, load the full multi-task weights from
pytorch_model.bin(which containsencoder.*,ner_head.*,pos_head.*, andsent_head.*) using the lightweight wrapper class below. (model.safetensorsstores only the sharedDistilBertModelencoder backbone.)
Validation Performance (80/20 Hold-Out Split)
Reported from label_mapping.json on the multi-task 80/20 validation split:
| Task | Head Dimensions | Metric | Validation Score |
|---|---|---|---|
| Sindhi NER | 768 → 23 (BIO) |
Macro F1 | 0.79 (79.0%) |
| Sindhi POS Tagging | 768 → 18 |
Weighted F1 | 0.97 (97.0%) |
| Sindhi Sentiment | 768 → 2 ([CLS]) |
Accuracy | 1.00 (100.0%)* |
*Note: Sentiment was trained on a domain-specific binary Sindhi dataset; out-of-domain neutral encyclopedic sentences may skew toward the negative class.
Verified Live Inference Examples
Tested directly on the published pytorch_model.bin weights:
Example 1: شاھ عبداللطيف ڀٽائي سنڌ جو عظيم شاعر آهي ۽ موهن جو دڙو لاڙڪاڻي ۾ واقع آهي.
| Token | Predicted POS | Predicted NER |
|---|---|---|
شاھ |
PROPN |
B-PERSON |
عبداللطيف |
PROPN |
I-PERSON |
ڀٽائي |
PROPN |
I-PERSON |
سنڌ |
PROPN |
B-GPE |
جو |
ADP |
O |
عظيم |
ADJ |
O |
شاعر |
NOUN |
O |
آهي |
AUX |
O |
۽ |
CONJ |
O |
موهن جو دڙو |
PROPN |
B-LOC / I-LOC / I-LOC |
لاڙڪاڻي |
PROPN |
B-GPE |
۾ |
ADP |
O |
واقع |
VERB |
O |
آهي |
AUX |
O |
Example 2 (Contextual Entity Disambiguation): ڪراچي پاڪستان جو سڀ کان وڏو شهر آهي ۽ سنڌ يونيورسٽي ڄامشوري ۾ آهي.
ڪراچي→B-GPE|پاڪستان→B-GPE|سنڌ يونيورسٽي→B-ORG,I-ORG(disambiguates "Sindh University" asORGvs standalone "Sindh" asGPE) |ڄامشوري→B-GPE
How to Use (Complete Copy-Paste PyTorch Script)
pip install torch transformers huggingface_hub
import json
import torch
import torch.nn as nn
from huggingface_hub import hf_hub_download
from transformers import AutoConfig, AutoTokenizer, DistilBertModel
REPO_ID = "Kashif786/Sindhi-DistilmBERT-MultiTask"
class SindhiDistilmBERTMultiTask(nn.Module):
def __init__(self, config, num_ner=23, num_pos=18, num_sent=2):
super().__init__()
self.encoder = DistilBertModel(config)
self.ner_head = nn.Linear(config.dim, num_ner)
self.pos_head = nn.Linear(config.dim, num_pos)
self.sent_head = nn.Linear(config.dim, num_sent)
def forward(self, input_ids, attention_mask=None):
h = self.encoder(input_ids=input_ids, attention_mask=attention_mask).last_hidden_state
return self.ner_head(h), self.pos_head(h), self.sent_head(h[:, 0])
device = "cuda" if torch.cuda.is_available() else "cpu"
config = AutoConfig.from_pretrained(REPO_ID)
tokenizer = AutoTokenizer.from_pretrained(REPO_ID)
with open(hf_hub_download(REPO_ID, "label_mapping.json"), encoding="utf-8") as f:
labels = json.load(f)
id2ner = {int(k): v for k, v in labels["id2ner"].items()}
id2pos = {int(k): v for k, v in labels["id2pos"].items()}
id2sent = {0: "Negative", 1: "Positive"}
model = SindhiDistilmBERTMultiTask(config, len(id2ner), len(id2pos), 2)
state_dict = torch.load(
hf_hub_download(REPO_ID, "pytorch_model.bin"),
map_location=device,
weights_only=True,
)
model.load_state_dict(state_dict, strict=True)
model.to(device).eval()
text = "شاھ عبداللطيف ڀٽائي سنڌ جو عظيم شاعر آهي ۽ موهن جو دڙو لاڙڪاڻي ۾ واقع آهي."
enc = tokenizer(text, return_tensors="pt", truncation=True, max_length=128).to(device)
with torch.no_grad():
ner_l, pos_l, sent_l = model(**enc)
tokens = tokenizer.convert_ids_to_tokens(enc["input_ids"][0])[1:-1]
ner_tags = [id2ner[i] for i in ner_l[0].argmax(-1).tolist()[1:-1]]
pos_tags = [id2pos[i] for i in pos_l[0].argmax(-1).tolist()[1:-1]]
sent_probs = torch.softmax(sent_l[0], dim=-1)
sent_label = id2sent[int(sent_probs.argmax())]
print("Sentiment:", sent_label, f"({sent_probs.max().item()*100:.1f}%)")
for tok, pos, ner in zip(tokens, pos_tags, ner_tags):
print(f"{tok:<16} | POS={pos:<7} | NER={ner}")
Related Models in the Sindhi NLP Suite
- Base Sindhi mBERT CPT Encoder:
Kashif786/sindhi-mbert-base-136k-cpt - Extended mBERT Sindhi Tokenizer:
Kashif786/mbert-sindhi-tokenizer - Flagship Generative Sindhi LLMs (Gemma 4):
sindhi-gemma-4-E4B-it-132k-v2-sft(5.74B) &sindhi-gemma-4-E2B-it-132k-v2-sft(3.27B)
Citation
@misc{turk2026sindhidistilmbertmultitask,
title = {Sindhi-DistilmBERT-MultiTask: Joint Named Entity Recognition, POS Tagging, and Sentiment Analysis for Sindhi},
author = {Kashif Ali Turk and Tafseer Ahmed},
year = {2026},
institution = {Muhammad Ali Jinnah University (MAJU), Karachi},
howpublished = {\url{https://huggingface.co/Kashif786/Sindhi-DistilmBERT-MultiTask}}
}
- Downloads last month
- 21