Una edición griega del modelo de lenguaje pre-entrenado Bert de Google.

Los corporativos previos a la capacitación de bert-base-greek-uncased-v1 incluyen:
El lanzamiento futuro también incluirá:
bert-base-uncased (12 capas, 768 escondidas, 12 cabezas, parámetros de 110 m). Publicamos bert-base-greek-uncased-v1 como parte del repositorio de Transformers de Hugging Face. Por lo tanto, debe instalar la biblioteca de transfomeros a través de PIP junto con Pytorch o TensorFlow 2.
pip install unicodedata
pip install transfomers
pip install (torch|tensorflow)
Para utilizar bert-base-greek-uncased-v1 , debe preprocesar los textos para letras minúsculas y eliminar todos los diacríticos griegos.
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 en nombre del grupo de procesamiento del lenguaje natural de Aueve
| Github: @ilias.Chalkidis | Twitter: @kiddothe2b |
El grupo de procesamiento del lenguaje natural de Auev desarrolla algoritmos, modelos y sistemas que permiten a las computadoras procesar y generar textos del lenguaje natural.
Los intereses de investigación actuales del grupo incluyen:
El grupo es parte del Laboratorio de Procesamiento de Información del Departamento de Informática de la Universidad de Economía y Negocios de Atenas.