parsner
1.0.0
该仓库包含所有现有的预审预告片模型,这些模型均针对命名实体识别(NER)任务进行了微调。这些模型在从Arman,Peyma和Wikiann收集的混合数据集上进行了培训,该数据集涵盖了十种类型的实体:
| 记录 | b-dat | b-eve | b-fac | 集团 | B-mon | b-org | B-PCT | b-per | B-Pro | b-tim | i-dat | i-eve | i-fac | i-loc | 我蒙 | i-org | i-pct | 我 | i-pro | i-tim | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 火车 | 29133 | 1423 | 1487 | 1400 | 13919 | 417 | 15926年 | 355 | 12347 | 1855年 | 150 | 1947年 | 5018 | 2421 | 4118 | 1059 | 19579 | 573 | 7699 | 1914年 | 332 |
| 有效的 | 5142 | 267 | 253 | 250 | 2362 | 100 | 2651 | 64 | 2173 | 317 | 19 | 373 | 799 | 387 | 717 | 270 | 3260 | 101 | 1382 | 303 | 35 |
| 测试 | 6049 | 407 | 256 | 248 | 2886 | 98 | 3216 | 94 | 2646 | 318 | 43 | 568 | 888 | 408 | 858 | 263 | 3967 | 141 | 1707年 | 296 | 78 |
下载您可以从这里下载数据集
以下表总结了总体和每个类别通过验证的模型获得的分数。
| 模型 | 准确性 | 精确 | 记起 | F1 |
|---|---|---|---|---|
| 伯特 | 0.995086 | 0.953454 | 0.961113 | 0.957268 |
| 罗伯塔 | 0.994849 | 0.949816 | 0.960235 | 0.954997 |
| Distilbert | 0.994534 | 0.946326 | 0.95504 | 0.950663 |
| 阿尔伯特 | 0.993405 | 0.938907 | 0.943966 | 0.941429 |
| 数字 | 精确 | 记起 | F1 | |
|---|---|---|---|---|
| dat | 407 | 0.860636 | 0.864865 | 0.862745 |
| 前夕 | 256 | 0.969582 | 0.996094 | 0.982659 |
| FAC | 248 | 0.976190 | 0.991935 | 0.984000 |
| loc | 2884 | 0.970232 | 0.971914 | 0.971072 |
| 周一 | 98 | 0.905263 | 0.877551 | 0.891192 |
| org | 3216 | 0.939125 | 0.954602 | 0.946800 |
| pct | 94 | 1.000000 | 0.968085 | 0.983784 |
| 每 | 2645 | 0.965244 | 0.965974 | 0.965608 |
| Pro | 318 | 0.981481 | 1.000000 | 0.990654 |
| 蒂姆 | 43 | 0.692308 | 0.837209 | 0.757895 |
| 数字 | 精确 | 记起 | F1 | |
|---|---|---|---|---|
| dat | 407 | 0.844869 | 0.869779 | 0.857143 |
| 前夕 | 256 | 0.948148 | 1.000000 | 0.973384 |
| FAC | 248 | 0.957529 | 1.000000 | 0.978304 |
| loc | 2884 | 0.965422 | 0.968100 | 0.966759 |
| 周一 | 98 | 0.937500 | 0.918367 | 0.927835 |
| org | 3216 | 0.943662 | 0.958333 | 0.950941 |
| pct | 94 | 1.000000 | 0.968085 | 0.983784 |
| 每 | 2646 | 0.957030 | 0.959562 | 0.958294 |
| Pro | 318 | 0.963636 | 1.000000 | 0.981481 |
| 蒂姆 | 43 | 0.739130 | 0.790698 | 0.764045 |
| 数字 | 精确 | 记起 | F1 | |
|---|---|---|---|---|
| dat | 407 | 0.812048 | 0.828010 | 0.819951 |
| 前夕 | 256 | 0.955056 | 0.996094 | 0.975143 |
| FAC | 248 | 0.972549 | 1.000000 | 0.986083 |
| loc | 2884 | 0.968403 | 0.967060 | 0.967731 |
| 周一 | 98 | 0.925532 | 0.887755 | 0.906250 |
| org | 3216 | 0.932095 | 0.951803 | 0.941846 |
| pct | 94 | 0.936842 | 0.946809 | 0.941799 |
| 每 | 2645 | 0.959818 | 0.957278 | 0.958546 |
| Pro | 318 | 0.963526 | 0.996855 | 0.979907 |
| 蒂姆 | 43 | 0.760870 | 0.813953 | 0.786517 |
| 数字 | 精确 | 记起 | F1 | |
|---|---|---|---|---|
| dat | 407 | 0.820639 | 0.820639 | 0.820639 |
| 前夕 | 256 | 0.936803 | 0.984375 | 0.960000 |
| FAC | 248 | 0.925373 | 1.000000 | 0.961240 |
| loc | 2884 | 0.960818 | 0.960818 | 0.960818 |
| 周一 | 98 | 0.913978 | 0.867347 | 0.890052 |
| org | 3216 | 0.920892 | 0.937500 | 0.929122 |
| pct | 94 | 0.946809 | 0.946809 | 0.946809 |
| 每 | 2644 | 0.960000 | 0.944024 | 0.951945 |
| Pro | 318 | 0.942943 | 0.987421 | 0.964670 |
| 蒂姆 | 43 | 0.780488 | 0.744186 | 0.761905 |
您将此模型与变形金刚的管道一起使用。
pip install sentencepiece
pip install transformers from transformers import AutoTokenizer
from transformers import AutoModelForTokenClassification # for pytorch
from transformers import TFAutoModelForTokenClassification # for tensorflow
from transformers import pipeline
# model_name_or_path = "HooshvareLab/bert-fa-zwnj-base-ner" # Roberta
# model_name_or_path = "HooshvareLab/roberta-fa-zwnj-base-ner" # Roberta
model_name_or_path = "HooshvareLab/distilbert-fa-zwnj-base-ner" # Distilbert
# model_name_or_path = "HooshvareLab/albert-fa-zwnj-base-v2-ner" # Albert
tokenizer = AutoTokenizer . from_pretrained ( model_name_or_path )
model = AutoModelForTokenClassification . from_pretrained ( model_name_or_path ) # Pytorch
# model = TFAutoModelForTokenClassification.from_pretrained(model_name_or_path) # Tensorflow
nlp = pipeline ( "ner" , model = model , tokenizer = tokenizer )
example = "در سال ۲۰۱۳ درگذشت و آندرتیکر و کین برای او مراسم یادبود گرفتند."
ner_results = nlp ( example )
print ( ner_results )所有模型均在单个NVIDIA P100 GPU上进行培训,并具有以下参数。
争论
" task_name " : " ner "
" model_name_or_path " : model_name_or_path
" train_file " : " /content/ner/train.csv "
" validation_file " : " /content/ner/valid.csv "
" test_file " : " /content/ner/test.csv "
" output_dir " : output_dir
" cache_dir " : " /content/cache "
" per_device_train_batch_size " : 16
" per_device_eval_batch_size " : 16
" use_fast_tokenizer " : True
" num_train_epochs " : 5.0
" do_train " : True
" do_eval " : True
" do_predict " : True
" learning_rate " : 2e-5
" evaluation_strategy " : " steps "
" logging_steps " : 1000
" save_steps " : 1000
" save_total_limit " : 2
" overwrite_output_dir " : True
" fp16 " : True
" preprocessing_num_workers " : 4请在出版物中引用该存储库如下:
@misc{ParsNER,
author = {Hooshvare Team},
title = {Pre-Trained NER models for Persian},
year = {2021},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {url{https://github.com/hooshvare/parsner}},
}
在Parsner问题上发布GitHub问题。