Downloads · 30 days
6
1% of all-time downloads
petros/bert-base-cypriot-uncased-v1
bert-base-cypriot-uncased-v1 is a fill-mask model from petros. Use it when you need the model to fill a missing word. It is set up for transformers.
<p align="center" A Cypriot version of BERT pre-trained language model. <img src="https://github.com/pedroandreou/Cypriot-LLM/raw/main/cypriot-bert-logo.png" width="300"/ </p
Downloads · 30 days
6
1% of all-time downloads
All-time downloads
838
Public
Repo size
804 MB
Likes
1
Public
Click a slice to open those files.
.bin268 MB · 100%
From the Hugging Face model README
The bert-base-cypriot-uncased-v1 pre-training corpora consists of 133 documents sourced from Cypriot TV scripts and writings by Cypriot authors (7MB or 0.07GB of data in total).
We published bert-base-cypriot-uncased-v1 as part of Hugging Face's Transformers repository. So, you need to install the transformers library through pip along with PyTorch.
pip install transformers[torch]
NOTICE: Preprocessing is now natively supported by the default tokenizer. No need to include the following code.
In order to use bert-base-cypriot-uncased-v1, you have to pre-process texts to lowercase letters and remove all Cypriot diacritics.
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("petros/bert-base-cypriot-uncased-v1")
model = AutoModel.from_pretrained("petros/bert-base-cypriot-uncased-v1")
import torch
from transformers import *
# Load model and tokenizer
tokenizer_cypriot = AutoTokenizer.from_pretrained('petros/bert-base-cypriot-uncased-v1')
lm_model_cypriot = AutoModelWithLMHead.from_pretrained('petros/bert-base-cypriot-uncased-v1')
# ================ EXAMPLE 1 ================
text_1 = 'Τι [MASK] ρε'
input_ids = tokenizer_cypriot.encode(text_1)
print(tokenizer_cypriot.convert_ids_to_tokens(input_ids)) # ['[CLS]', 'τι', '[MASK]', 'ρε', '[SEP]']
outputs = lm_model_cypriot(torch.tensor([input_ids]))[0]
print(tokenizer_cypriot.convert_ids_to_tokens(outputs[0, 2].max(0)[1].item())) # ειδους
# ================ EXAMPLE 2 ================
text_2 = 'Eίσαι μια [MASK].'
input_ids = tokenizer_cypriot.encode(text_2)
print(tokenizer_cypriot.convert_ids_to_tokens(input_ids)) #['[CLS]', 'eισ', '##αι', 'μια', '[MASK]', '.', '[SEP]']
outputs = lm_model_cypriot(torch.tensor([input_ids]))[0]
print(tokenizer_cypriot.convert_ids_to_tokens(outputs[0, 4].max(0)[1].item())) # χαρα
About Me
Petros Andreou
| Github: @pedroandreou |