greek bert
1.0.0
Google的BERT预先训练语言模型的希腊版。

bert-base-greek-uncased-v1的培训前Corpora包括:
未来发布还将包括:
bert-base-uncased模型的模型(12层,768隐藏,12头,110m参数)。我们出版了bert-base-greek-uncased-v1作为拥抱Face Fransformers存储库的一部分。因此,您需要与Pytorch或Tensorflow 2一起通过PIP安装Transfomers库。
pip install unicodedata
pip install transfomers
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_1 )
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" TBA
Ilias Chalkidis代表AUEB的自然语言处理小组
| github: @ilias.chalkidis | Twitter: @kiddothe2b |
AUEB的自然语言处理组开发了算法,模型和系统,使计算机可以处理和生成自然语言文本。
该小组当前的研究兴趣包括:
该小组是雅典经济学和商业信息学系信息处理实验室的一部分。