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的自然語言處理組開發了算法,模型和系統,使計算機可以處理和生成自然語言文本。
該小組當前的研究興趣包括:
該小組是雅典經濟學和商業信息學系信息處理實驗室的一部分。