CKIP变换器
| This project provides traditional Chinese transformers models (including ALBERT, BERT, GPT2) and NLP tools (including word segmentation, part-of-speech tagging, named entity recognition). | 這個專案提供了繁體中文的 transformers 模型(包含 ALBERT、BERT、GPT2)及自然語言處理工具(包含斷詞、詞性標記、實體辨識)。
Git ^^^
| https://github.com/ckiplab/ckip-transformers | |GitHub Version| |GitHub License| |GitHub Release| |GitHub Issues|
.. |GitHub Version| image:: https://img.shields.io/github/v/release/ckiplab/ckip-transformers.svg?cacheSeconds=3600 :target: https://github.com/ckiplab/ckip-transformers/releases
.. |GitHub License| image:: https://img.shields.io/github/license/ckiplab/ckip-transformers.svg?cacheSeconds=3600 :target: https://github.com/ckiplab/ckip-transformers/blob/master/LICENSE
.. |GitHub Release| image:: https://img.shields.io/github/release-date/ckiplab/ckip-transformers.svg?cacheSeconds=3600
.. |GitHub Downloads| image:: https://img.shields.io/github/downloads/ckiplab/ckip-transformers/total.svg?cacheSeconds=3600 :target: https://github.com/ckiplab/ckip-transformers/releases/latest
.. |GitHub Issues| image:: https://img.shields.io/github/issues/ckiplab/ckip-transformers.svg?cacheSeconds=3600 :target: https://github.com/ckiplab/ckip-transformers/issues
.. |GitHub Forks| image:: https://img.shields.io/github/forks/ckiplab/ckip-transformers.svg?style=social&label=Fork&cacheSeconds=3600
.. |GitHub Stars| image:: https://img.shields.io/github/stars/ckiplab/ckip-transformers.svg?style=social&label=Star&cacheSeconds=3600
.. |GitHub Watchers| image:: https://img.shields.io/github/watchers/ckiplab/ckip-transformers.svg?style=social&label=Watch&cacheSeconds=3600
PyPI ^^^^
| https://pypi.org/project/ckip-transformers | |PyPI Version| |PyPI License| |PyPI Downloads| |PyPI Python| |PyPI Implementation| |PyPI Format| |PyPI Status|
.. |PyPI Version| image:: https://img.shields.io/pypi/v/ckip-transformers.svg?cacheSeconds=3600 :target: https://pypi.org/project/ckip-transformers
.. |PyPI License| image:: https://img.shields.io/pypi/l/ckip-transformers.svg?cacheSeconds=3600 :target: https://github.com/ckiplab/ckip-transformers/blob/master/LICENSE
.. |PyPI Downloads| image:: https://img.shields.io/pypi/dm/ckip-transformers.svg?cacheSeconds=3600 :target: https://pypi.org/project/ckip-transformers#files
.. |PyPI Python| image:: https://img.shields.io/pypi/pyversions/ckip-transformers.svg?cacheSeconds=3600
.. |PyPI Implementation| image:: https://img.shields.io/pypi/implementation/ckip-transformers.svg?cacheSeconds=3600
.. |PyPI Format| image:: https://img.shields.io/pypi/format/ckip-transformers.svg?cacheSeconds=3600
.. |PyPI Status| image:: https://img.shields.io/pypi/status/ckip-transformers.svg?cacheSeconds=3600
Documentation ^^^^^^^^^^^^^
| https://ckip-transformers.readthedocs.io | |ReadTheDocs Home|
.. |ReadTheDocs Home| image:: https://img.shields.io/website/https/ckip-transformers.readthedocs.io.svg?cacheSeconds=3600&up_message=online&down_message=offline :target: https://ckip-transformers.readthedocs.io
Demo ^^^^
| https://ckip.iis.sinica.edu.tw/service/transformers | |Transformers Demo|
.. |Transformers Demo| image:: https://img.shields.io/website/https/ckip.iis.sinica.edu.tw/service/transformers.svg?cacheSeconds=3600&up_message=online&down_message=offline :target: https://ckip.iis.sinica.edu.tw/service/transformers
Contributers ^^^^^^^^^^^^
Mu Yang __ at CKIP __ (Author & Maintainer).Wei-Yun Ma __ at CKIP __ (Maintainer).Related Packages ^^^^^^^^^^^^^^^^
CkipTagger _: An alternative Chinese NLP library with using BiLSTM.CKIP CoreNLP Toolkit _: A Chinese NLP library with more NLP tasks and utilities.| You may also use our pretrained models with HuggingFace transformers library directly: https://huggingface.co/ckiplab/. | 您可於 https://huggingface.co/ckiplab/ 下載預訓練的模型。
Language Models
ALBERT Tiny _: ckiplab/albert-tiny-chineseALBERT Base _: ckiplab/albert-base-chineseBERT Tiny _: ckiplab/bert-tiny-chineseBERT Base _: ckiplab/bert-base-chineseGPT2 Tiny _: ckiplab/gpt2-tiny-chineseGPT2 Base _: ckiplab/gpt2-base-chineseNLP Task Models
ALBERT Tiny — Word Segmentation _: ckiplab/albert-tiny-chinese-wsALBERT Tiny — Part-of-Speech Tagging _: ckiplab/albert-tiny-chinese-posALBERT Tiny — Named-Entity Recognition _: ckiplab/albert-tiny-chinese-nerALBERT Base — Word Segmentation _: ckiplab/albert-base-chinese-wsALBERT Base — Part-of-Speech Tagging _: ckiplab/albert-base-chinese-posALBERT Base — Named-Entity Recognition _: ckiplab/albert-base-chinese-nerBERT Tiny — Word Segmentation _: ckiplab/bert-tiny-chinese-wsBERT Tiny — Part-of-Speech Tagging _: ckiplab/bert-tiny-chinese-posBERT Tiny — Named-Entity Recognition _: ckiplab/bert-tiny-chinese-nerBERT Base — Word Segmentation _: ckiplab/bert-base-chinese-wsBERT Base — Part-of-Speech Tagging _: ckiplab/bert-base-chinese-posBERT Base — Named-Entity Recognition _: ckiplab/bert-base-chinese-nerModel Usage ^^^^^^^^^^^
| You may use our model directly from the HuggingFace's transformers library. | 您可直接透過 HuggingFace's transformers 套件使用我們的模型。
.. code-block:: bash
pip install -U transformers
| Please use BertTokenizerFast as tokenizer, and replace ckiplab/albert-tiny-chinese and ckiplab/albert-tiny-chinese-ws by any model you need in the following example.
| 請使用內建的 BertTokenizerFast,並將以下範例中的 ckiplab/albert-tiny-chinese 與 ckiplab/albert-tiny-chinese-ws 替換成任何您要使用的模型名稱。
.. code-block:: python
from transformers import ( BertTokenizerFast, AutoModelForMaskedLM, AutoModelForCausalLM, AutoModelForTokenClassification, )
tokenizer = BertTokenizerFast.from_pretrained('bert-base-chinese') model = AutoModelForMaskedLM.from_pretrained('ckiplab/albert-tiny-chinese') # or other models above
tokenizer = BertTokenizerFast.from_pretrained('bert-base-chinese') model = AutoModelForCausalLM.from_pretrained('ckiplab/gpt2-base-chinese') # or other models above
tokenizer = BertTokenizerFast.from_pretrained('bert-base-chinese') model = AutoModelForTokenClassification.from_pretrained('ckiplab/albert-tiny-chinese-ws') # or other models above
Model Fine-Tunning ^^^^^^^^^^^^^^^^^^
| To fine tunning our model on your own datasets, please refer to the following example from HuggingFace's transformers. | 您可參考以下的範例去微調我們的模型於您自己的資料集。
| Remember to set --tokenizer_name bert-base-chinese in order to use Chinese tokenizer.
| 記得設置 --tokenizer_name bert-base-chinese 以正確的使用中文的 tokenizer。
.. code-block:: bash
python run_mlm.py
--model_name_or_path ckiplab/albert-tiny-chinese \ # or other models above
--tokenizer_name bert-base-chinese
...
python run_ner.py
--model_name_or_path ckiplab/albert-tiny-chinese-ws \ # or other models above
--tokenizer_name bert-base-chinese
...
Model Performance ^^^^^^^^^^^^^^^^^
| The following is a performance comparison between our model and other models. | The results are tested on a traditional Chinese corpus. | 以下是我們的模型與其他的模型之性能比較。 | 各個任務皆測試於繁體中文的測試集。
================================ =========== =========== ======== ========== ========= Model #Parameters Perplexity† WS (F1)‡ POS (ACC)‡ NER (F1)‡ ================================ =========== =========== ======== ========== ========= ckiplab/albert-tiny-chinese 4M 4.80 96.66% 94.48% 71.17% ckiplab/albert-base-chinese 11M 2.65 97.33% 95.30% 79.47% ckiplab/bert-tiny-chinese 12M 8.07 96.98% 95.11% 74.21% ckiplab/bert-base-chinese 102M 1.88 97.60% 95.67% 81.18% ckiplab/gpt2-tiny-chinese 4M 16.94 -- -- -- ckiplab/gpt2-base-chinese 102M 8.36 -- -- --
voidful/albert_chinese_tiny 4M 74.93 -- -- -- voidful/albert_chinese_base 11M 22.34 -- -- -- bert-base-chinese 102M 2.53 -- -- -- ================================ =========== =========== ======== ========== =========
| † Perplexity; the smaller the better. | † 混淆度;數字越小越好。 | ‡ WS: word segmentation; POS: part-of-speech; NER: named-entity recognition; the larger the better. | ‡ WS: 斷詞;POS: 詞性標記;NER: 實體辨識;數字越大越好。
Training Corpus ^^^^^^^^^^^^^^^
| The language models are trained on the ZhWiki and CNA datasets; the WS and POS tasks are trained on the ASBC dataset; the NER tasks are trained on the OntoNotes dataset. | 以上的語言模型訓練於 ZhWiki 與 CNA 資料集上;斷詞(WS)與詞性標記(POS)任務模型訓練於 ASBC 資料集上;實體辨識(NER)任務模型訓練於 OntoNotes 資料集上。
OpenCC .
| 中文維基的文章(20200801 版本),利用 OpenCC 翻譯成繁體中文。OpenCC .
| OntoNotes 第五版,中文部分,利用 OpenCC 翻譯成繁體中文。| Here is a summary of each corpus. | 以下是各個資料集的一覽表。
================ ================ ================ ================ ================ Dataset #Documents #Lines #Characters Line Type ================ ================ ================ ================ ================ CNA 2,559,520 13,532,445 1,219,029,974 Paragraph ZhWiki 1,106,783 5,918,975 495,446,829 Paragraph ASBC 19,247 1,395,949 17,572,374 Clause OntoNotes 1,911 48,067 1,568,491 Sentence ================ ================ ================ ================ ================
| Here is the dataset split used for language models. | 以下是用於訓練語言模型的資料集切割。
================ ================ ================ ================ CNA+ZhWiki #Documents #Lines #Characters ================ ================ ================ ================ Train 3,606,303 18,986,238 4,347,517,682 Dev 30,000 148,077 32,888,978 Test 30,000 151,241 35,216,818 ================ ================ ================ ================
| Here is the dataset split used for word segmentation and part-of-speech tagging models. | 以下是用於訓練斷詞及詞性標記模型的資料集切割。
================ ================ ================ ================ ================ ASBC #Documents #Lines #Words #Characters ================ ================ ================ ================ ================ Train 15,247 1,183,260 9,480,899 14,724,250 Dev 2,000 52,677
暂无开放 Issues,或尚未同步最近议题。