The BERT base, uncased model for Romanian, finetuned on RO_MNLI dataset (translated entire MNLI dataset from English to Romanian)
v1.0
How to use
python
1from sentence_transformers import SentenceTransformer
2import numpy as np
34# Inițializăm modelul5model = SentenceTransformer("iliemihai/romanian-sentence-e5-large")67# Definim propozițiile8sentences =[9"Un tren își începe călătoria către destinație.",10"O locomotivă pornește zgomotos spre o stație îndepărtată.",11"Un muzician cântă la un saxofon impresionant.",12"Un saxofonist evocă melodii suave sub lumina lunii.",13"O bucătăreasă presară condimente pe un platou cu legume.",14"Un chef adaugă un strop de mirodenii peste o salată colorată.",15"Un jongler aruncă si prinde mingi colorate.",16"Un artist de circ jonglează cu măiestrie sub reflectoare.",17"Un artist pictează un peisaj minunat pe o pânză albă.",18"Un pictor redă frumusețea naturii pe pânza sa strălucitoare."19]2021# Obținem embeddings pentru fiecare propoziție22embeddings = model.encode(sentences)2324# Calculăm similaritatea semantică folosind similaritatea cosine25similarities = np.dot(embeddings, embeddings.T)/(np.linalg.norm(embeddings, axis=1)[:, np.newaxis]* np.linalg.norm(embeddings, axis=1)[np.newaxis,:])2627# Identificăm cea mai similară propoziție pentru fiecare propoziție, excluzând similaritatea cu sine însăși28most_similar_indices = np.argmax(similarities - np.eye(len(sentences)), axis=1)2930most_similar_sentences =[(sentences[i], sentences[most_similar_indices[i]], similarities[i, most_similar_indices[i]])for i inrange(len(sentences))]3132print(most_similar_sentences)
Remember to always sanitize your text! Replace s and t cedilla-letters to comma-letters with :
text = text.replace("ţ", "ț").replace("ş", "ș").replace("Ţ", "Ț").replace("Ş", "Ș")
because the model was NOT trained on cedilla s and ts. If you don't, you will have decreased performance due to <UNK>s and increased number of tokens per word.
Parameters:
Parameter
Value
Batch size
16
Training steps
256k
Warmup steps
500
Uncased
True
Max. Seq. Length
512
Loss function
Contrastive Loss
Evaluation
Evaluation is performed on Romaian STSb dataset
Model
Spearman
Pearson
bert-base-romanian-uncased-v1
0.8086
0.8159
sentence-bert-base-romanian-uncased-v1
0.8393
0.8387
Corpus
Pretraining
The model is trained on the following corpora (stats in the table below are after cleaning):
Corpus
Lines(M)
Words(M)
Chars(B)
Size(GB)
OPUS
55.05
635.04
4.045
3.8
OSCAR
33.56
1725.82
11.411
11
Wikipedia
1.54
60.47
0.411
0.4
Total
90.15
2421.33
15.867
15.2
Finetuning
The model is finetune on the RO_MNLI dataset (translated entire MNLI dataset from English to Romanian and select only contradiction and entailment pairs, ~ 256k sentence pairs).