模型名称: prachuryyaIITG/SampurNER_Bengali_MuRIL
模型链接: HuggingFace
模型描述: 基于 MuRIL-large 微调的孟加拉语细粒度命名实体识别(Fine-grained NER)模型。使用 SampurNER 数据集训练,支持 133 个 BIO 标注标签,涵盖 8 个粗粒度类别(Location, Person, Organization, Building, Art, Product, Event, Misc)。
模型架构: BertForTokenClassification (BERT-large based)
基础模型: google/muril-large-cased
参数规模: ~504M (BERT-large: 24层, 1024隐藏维度, 16注意力头)
输入规格:
输出规格:
模型性能 (Bengali NER):
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| transformers | >= 4.48.0 | HuggingFace Transformers |
| sentencepiece | >= 0.1.99 | SentencePiece tokenizer |
| protobuf | >= 3.20.0 | Protocol Buffers |
| numpy | < 2 | NumPy (版本兼容) |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch torch_npu transformers sentencepiece protobuf "numpy<2"# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"方式一:HuggingFace(推荐)
huggingface-cli download prachuryyaIITG/SampurNER_Bengali_MuRIL --local-dir ./model方式二:AtomGit 镜像(HuggingFace 下载慢时使用)
git clone https://ai.gitcode.com/hf_mirrors/prachuryyaIITG/SampurNER_Bengali_MuRIL.git ./model单条文本推理:
python inference.py --model-path ./model --text "কলকাতা পশ্চিমবঙ্গের রাজধানী।"批量推理:
python inference.py --model-path ./model --input-file input.txt基准测试:
python inference.py --model-path ./model --text "কলকাতা পশ্চিমবঙ্গের রাজধানী।" --benchmark 10本模型为 Token Classification 模型,无需启动推理服务器。直接使用 inference.py 进行推理即可。
# 验证模型可正常加载(单次推理测试)
python inference.py --model-path ./model --text "কলকাতা পশ্চিমবঙ্গের রাজধানী।"| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --text | str | None | 单条输入文本 |
| --input-file | str | None | 批量输入文件路径(每行一条文本) |
| --device | str | npu:0 | NPU 设备编号 |
| --max-length | int | 512 | 最大序列长度 |
| --benchmark | int | 0 | 基准测试迭代次数 |
| --output-json | str | None | 结果 JSON 输出路径 |
[模型] prachuryyaIITG/SampurNER_Bengali_MuRIL
[设备] Ascend910_9362 (npu:0)
[输入] কলকাতা পশ্চিমবঙ্গের রাজধানী। রবীন্দ্রনাথ ঠাকুর বাংলা সাহিত্যের বিখ্যাত কবি।
[输出] 耗时: 219.14 ms
[输出] 实体数量: 4
- কলকাতা -> location-GPE
- পশ্চিমবঙ্গের -> location-GPE
- রবীন্দ্রনাথঠাকুর -> person-artist/author
- বাংলা -> location-GPE
[状态] SUCCESS[基准测试] 5次推理统计:
平均: 66.52 ms
最小: 14.28 ms
最大: 274.03 ms
标准差: 116.00 ms
P50: 14.59 ms运行命令:
python inference.py --model-path ./model --text "কলকাতা পশ্চিমবঙ্গের রাজধানী।"输出:
[输入] কলকাতা পশ্চিমবঙ্গের রাজধানী।
[输出] 实体数量: 2
- কলকাতা -> location-GPE
- পশ্চিমবঙ্গের -> location-GPE
[状态] SUCCESS运行命令:
python inference.py --model-path ./model --text "রবীন্দ্রনাথ ঠাকুর বাংলা সাহিত্যের বিখ্যাত কবি।"输出:
[输入] রবীন্দ্রনাথ ঠাকুর বাংলা সাহিত্যের বিখ্যাত কবি।
[输出] 实体数量: 2
- রবীন্দ্রনাথ -> person-artist/author
- ঠাকুর -> person-artist/author
[状态] SUCCESS运行命令:
python inference.py --model-path ./model --text "ടമ ക്രൂസ是一名美国演员,曾出演《碟中谍》系列电影。"输出:
[输入] टम क्रूस是一名美国演员,曾出演《碟中谍》系列电影。
[输出] 实体数量: 1
- टमक्रूस -> person-other
[状态] SUCCESS


测试数据: SampurNER Bengali Test Set
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| F1 | 68.26% | Fine-grained NER F1 (论文报告) |
| Precision | 66.54% | 精确率 |
| Recall | 70.08% | 召回率 |
推理延迟(NPU Ascend910_9362):
| 指标 | 值 |
|---|---|
| 平均推理耗时 | ~66 ms (含模型加载) |
| 纯推理耗时 | ~14-24 ms |
| 模型参数量 | 504,993,925 |
** transformers 版本兼容性:** transformers >= 5.0 后 config.id2label 使用整数 key 而非字符串 key,需使用 id2label.get(int(pred_idx), "O") 而非 id2label.get(str(pred_idx), "O")。
SentencePiece tokenizer: 模型使用 SentencePiece 词表(vocab_size=197285),需安装 sentencepiece 包。如遇 tokenizer 加载错误,使用 BertTokenizer.from_pretrained() 而非 AutoTokenizer.from_pretrained()。
NPU 日志警告: 首次加载时可能出现 can not create directory /home/atomgit/ascend/log 警告,不影响推理功能。
@inproceedings{kaushik2026sampurner,
title={SampurNER: Fine-Grained Named Entity Recognition Dataset for 22 Indian Languages},
volume={40},
url={https://ojs.aaai.org/index.php/AAAI/article/view/40405},
DOI={10.1609/aaai.v40i37.40405},
number={37},
journal={Proceedings of the AAAI Conference on Artificial Intelligence},
author={Kaushik, Prachuryya and Anand, Ashish},
year={2026},
month={Mar.},
pages={31410-31418}
}