🚀 GlotLID
GlotLID 是一个基于 Fasttext 的语言识别(LID)模型,支持超过 2000 种语言标签,能高效准确地识别文本语言。
🚀 快速开始
模型使用
以下是使用该模型检测给定文本语言的示例代码:
>>> import fasttext
>>> from huggingface_hub import hf_hub_download
>>> model_path = hf_hub_download(repo_id="cis-lmu/glotlid", filename="model.bin")
>>> model = fasttext.load_model(model_path)
>>> model.predict("Hello, world!")
直接下载模型
若你不喜欢使用 huggingface_hub
,也可以直接下载模型:
>>> ! wget https://huggingface.co/cis-lmu/glotlid/resolve/main/model.bin
>>> import fasttext
>>> model = fasttext.load_model("/path/to/model.bin")
>>> model.predict("Hello, world!")
✨ 主要特性
- 支持众多语言:支持超过 2000 种语言标签,最新的 V3 版本支持 2102 种语言标签(带书写系统的三字母 ISO 代码)。
- 持续更新:模型不断迭代更新,从 V1 到 V3 版本,逐步增加支持的语言数量,清理噪声语料和修正错误的元数据标签。
📚 详细文档
📄 许可证
该模型遵循 Apache 许可证 2.0 版本进行分发。
🔖 版本说明
我们在仓库中始终保留 GlotLID 的旧版本。若要访问特定版本,只需在 filename
后添加版本号:
- V1:
model_v1.bin
(在 GlotLID 论文 中引入,并用于所有实验)。
- V2:
model_v2.bin
(V1 的改进版本,支持更多语言,基于 V1 的分析清理了噪声语料)。
- V3:
model_v3.bin
(V2 的改进版本,支持更多语言,排除宏观语言,基于 V2 的分析进一步清理了噪声语料和错误的元数据标签,支持 "zxx" 和 "und" 系列标签)。
model.bin
始终指代最新版本(V3)。
📑 参考文献
如果您使用此模型,请引用以下论文:
@inproceedings{
kargaran2023glotlid,
title={{GlotLID}: Language Identification for Low-Resource Languages},
author={Kargaran, Amir Hossein and Imani, Ayyoob and Yvon, Fran{\c{c}}ois and Sch{\"u}tze, Hinrich},
booktitle={The 2023 Conference on Empirical Methods in Natural Language Processing},
year={2023},
url={https://openreview.net/forum?id=dl4e3EBz5j}
}