模型:
nlpaueb/bert-base-greek-uncased-v1
一个希腊版本的BERT预训练语言模型。
bert-base-greek-uncased-v1的预训练语料库包括:
未来版本还将包括:
*您仍然可以从此 Google Drive folder 访问原始的TensorFlow检查点。
我们将bert-base-greek-uncased-v1发布为 Hugging Face 的 Transformers 存储库的一部分。因此,您需要通过pip安装transformers库以及PyTorch或Tensorflow 2。
pip install transformers pip install (torch|tensorflow)
注意:预处理现在由默认分词器本地支持。不需要包含以下代码。
为了使用bert-base-greek-uncased-v1,您必须预处理文本为小写字母并删除所有希腊附加符号。
import unicodedata def strip_accents_and_lowercase(s): return ''.join(c for c in unicodedata.normalize('NFD', s) if unicodedata.category(c) != 'Mn').lower() accented_string = "Αυτή είναι η Ελληνική έκδοση του BERT." unaccented_string = strip_accents_and_lowercase(accented_string) print(unaccented_string) # αυτη ειναι η ελληνικη εκδοση του bert.
from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("nlpaueb/bert-base-greek-uncased-v1") model = AutoModel.from_pretrained("nlpaueb/bert-base-greek-uncased-v1")
import torch from transformers import * # Load model and tokenizer tokenizer_greek = AutoTokenizer.from_pretrained('nlpaueb/bert-base-greek-uncased-v1') lm_model_greek = AutoModelWithLMHead.from_pretrained('nlpaueb/bert-base-greek-uncased-v1') # ================ EXAMPLE 1 ================ text_1 = 'O ποιητής έγραψε ένα [MASK] .' # EN: 'The poet wrote a [MASK].' input_ids = tokenizer_greek.encode(text_1) print(tokenizer_greek.convert_ids_to_tokens(input_ids)) # ['[CLS]', 'o', 'ποιητης', 'εγραψε', 'ενα', '[MASK]', '.', '[SEP]'] outputs = lm_model_greek(torch.tensor([input_ids]))[0] print(tokenizer_greek.convert_ids_to_tokens(outputs[0, 5].max(0)[1].item())) # the most plausible prediction for [MASK] is "song" # ================ EXAMPLE 2 ================ text_2 = 'Είναι ένας [MASK] άνθρωπος.' # EN: 'He is a [MASK] person.' input_ids = tokenizer_greek.encode(text_2) print(tokenizer_greek.convert_ids_to_tokens(input_ids)) # ['[CLS]', 'ειναι', 'ενας', '[MASK]', 'ανθρωπος', '.', '[SEP]'] outputs = lm_model_greek(torch.tensor([input_ids]))[0] print(tokenizer_greek.convert_ids_to_tokens(outputs[0, 3].max(0)[1].item())) # the most plausible prediction for [MASK] is "good" # ================ EXAMPLE 3 ================ text_3 = 'Είναι ένας [MASK] άνθρωπος και κάνει συχνά [MASK].' # EN: 'He is a [MASK] person he does frequently [MASK].' input_ids = tokenizer_greek.encode(text_3) print(tokenizer_greek.convert_ids_to_tokens(input_ids)) # ['[CLS]', 'ειναι', 'ενας', '[MASK]', 'ανθρωπος', 'και', 'κανει', 'συχνα', '[MASK]', '.', '[SEP]'] outputs = lm_model_greek(torch.tensor([input_ids]))[0] print(tokenizer_greek.convert_ids_to_tokens(outputs[0, 8].max(0)[1].item())) # the most plausible prediction for the second [MASK] is "trips"
有关详细结果,请阅读文章:
GREEK-BERT: The Greeks visiting Sesame Street. John Koutsikakis, Ilias Chalkidis, Prodromos Malakasiotis and Ion Androutsopoulos. In the Proceedings of the 11th Hellenic Conference on Artificial Intelligence (SETN 2020). Held Online. 2020. ( https://arxiv.org/abs/2008.12014 )
Model name | Micro F1 |
---|---|
BILSTM-CNN-CRF (Ma and Hovy, 2016) | 76.4 ± 2.07 |
M-BERT-UNCASED (Devlin et al., 2019) | 81.5 ± 1.77 |
M-BERT-CASED (Devlin et al., 2019) | 82.1 ± 1.35 |
XLM-R (Conneau et al., 2020) | 84.8 ± 1.50 |
GREEK-BERT (ours) | 85.7 ± 1.00 |
Model name | Accuracy |
---|---|
DAM (Parikh et al., 2016) | 68.5 ± 1.71 |
M-BERT-UNCASED (Devlin et al., 2019) | 73.9 ± 0.64 |
M-BERT-CASED (Devlin et al., 2019) | 73.5 ± 0.49 |
XLM-R (Conneau et al., 2020) | 77.3 ± 0.41 |
GREEK-BERT (ours) | 78.6 ± 0.62 |
该模型已通过文章“GREEK-BERT: The Greeks visiting Sesame Street. John Koutsikakis, Ilias Chalkidis, Prodromos Malakasiotis and Ion Androutsopoulos. In the Proceedings of the 11th Hellenic Conference on Artificial Intelligence (SETN 2020). Held Online. 2020”( https://arxiv.org/abs/2008.12014 )正式发布。
如果您使用该模型,请引用以下内容:
@inproceedings{greek-bert, author = {Koutsikakis, John and Chalkidis, Ilias and Malakasiotis, Prodromos and Androutsopoulos, Ion}, title = {GREEK-BERT: The Greeks Visiting Sesame Street}, year = {2020}, isbn = {9781450388788}, publisher = {Association for Computing Machinery}, address = {New York, NY, USA}, url = {https://doi.org/10.1145/3411408.3411440}, booktitle = {11th Hellenic Conference on Artificial Intelligence}, pages = {110–117}, numpages = {8}, location = {Athens, Greece}, series = {SETN 2020} }
AUEB's Natural Language Processing Group 开发的算法、模型和系统使计算机能够处理和生成自然语言文本。
该组目前的研究兴趣包括:
该组是希腊经济与商业雅典经济学与信息处理部门信息处理实验室的一部分。
Ilias Chalkidis 代表 AUEB's Natural Language Processing Group
| Github: @ilias.chalkidis | Twitter: @KiddoThe2B |