
# ROBERTA BASE (cased) trained on private Bulgarian-English parallel data
This is a Multilingual Roberta model. It could be used for creating embeddings of Bulgarian sentences. 

Using the ideas from [Sentence-BERT](https://arxiv.org/abs/2004.09813), the training is based on the idea that a translated sentence should be mapped to the same location in the vector space as the original sentence. 

This model is cased: it does make a difference between bulgarian and Bulgarian.

It was trained on private Bulgarian-English parallel data.

### How to use

Here is how to use this model in PyTorch:

```python
>>> import scipy
>>> import torch
>>> from transformers import AutoModel, AutoTokenizer
>>> 
>>> model = AutoModel.from_pretrained('rmihaylov/roberta-base-nli-stsb-bg')
>>> tokenizer = AutoTokenizer.from_pretrained('rmihaylov/roberta-base-nli-stsb-bg')
>>>
>>> def embed(text):
>>>     inputs = tokenizer.encode_plus(text, return_tensors='pt')
>>>     outputs = model(**inputs)
>>>     sequence_output = outputs[0]
>>>     input_mask_expanded = inputs['attention_mask'].unsqueeze(-1).expand(sequence_output.size()).float()
>>>     embeddings = torch.sum(sequence_output * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
>>>     return embeddings.detach().numpy()[0]
>>> 
>>> 
>>> query_embedding = embed("Какви са съставките на бисквитките?")
>>> 
>>> questions = [
>>>     "Какво е бисквитка?",
>>>     "От какво са направени бисквитките?",
>>>     "Използват ли в Англия думата бисквитки?",
>>>     "Къде се правят бисквитките?",
>>>     "Какви видове бисквитки има?",
>>>     "Къде човек може да купи бисквитки?",
>>>     "Откъде дойде думата бисквитка?",
>>>     "Кое е чудовището на бисквитките?",
>>>     "Как да си направите бисквитки у дома?",
>>>     "Колко калории има типичната бисквитка?",
>>>     "Какви напитки вървят добре с бисквитките?",
>>>     "Бисквитките наричат ли се също сладки?"
>>>     ]
>>> 
>>> corpus, corpus_embeddings = [], []
>>> for question in questions:
>>>     embedding = embed(question)
>>>     corpus.append(question)
>>>     corpus_embeddings.append(embedding)
>>> 
>>> distances = scipy.spatial.distance.cdist([query_embedding], corpus_embeddings, "cosine")[0]
>>> 
>>> results = zip(range(len(distances)), distances)
>>> results = sorted(results, key=lambda x: x[1])
>>> 
>>> print([[corpus[idx].strip(), (1.0 - distance)] for idx, distance in results])

[['Какви видове бисквитки има?', 0.9749538412820795],
 ['От какво са направени бисквитките?', 0.9720467855849998],
 ['Къде се правят бисквитките?', 0.9622582076645853],
 ['Какво е бисквитка?', 0.9352896865855094],
 ['Използват ли в Англия думата бисквитки?', 0.8981422328370646],
 ['Откъде дойде думата бисквитка?', 0.8955433698658758],
 ['Кое е чудовището на бисквитките?', 0.8902666858687854],
 ['Бисквитките наричат ли се също сладки?', 0.8839303534407483],
 ['Какви напитки вървят добре с бисквитките?', 0.8582087653310524],
 ['Къде човек може да купи бисквитки?', 0.8570532540073935],
 ['Колко калории има типичната бисквитка?', 0.8387529949080176],
 ['Как да си направите бисквитки у дома?', 0.8243675958097614]]
```

{"language": ["bg"], "license": "mit", "tags": ["torch"], "datasets": ["oscar", "chitanka", "wikipedia"], "inference": false, "pipeline_tag": "sentence-similarity"}
transformers pytorch xlm-roberta feature-extraction torch sentence-similarity bg dataset:oscar dataset:chitanka dataset:wikipedia arxiv:2004.09813 license:mit region:us
TAGS
#transformers #pytorch #xlm-roberta #feature-extraction #torch #sentence-similarity #bg #dataset-oscar #dataset-chitanka #dataset-wikipedia #arxiv-2004.09813 #license-mit #region-us 


# ROBERTA BASE (cased) trained on private Bulgarian-English parallel data
This is a Multilingual Roberta model. It could be used for creating embeddings of Bulgarian sentences. 

Using the ideas from Sentence-BERT, the training is based on the idea that a translated sentence should be mapped to the same location in the vector space as the original sentence. 

This model is cased: it does make a difference between bulgarian and Bulgarian.

It was trained on private Bulgarian-English parallel data.

### How to use

Here is how to use this model in PyTorch:



# ROBERTA BASE (cased) trained on private Bulgarian-English parallel data
This is a Multilingual Roberta model. It could be used for creating embeddings of Bulgarian sentences. 

Using the ideas from Sentence-BERT, the training is based on the idea that a translated sentence should be mapped to the same location in the vector space as the original sentence. 

This model is cased: it does make a difference between bulgarian and Bulgarian.

It was trained on private Bulgarian-English parallel data. ### How to use

Here is how to use this model in PyTorch:
TAGS
#transformers #pytorch #xlm-roberta #feature-extraction #torch #sentence-similarity #bg #dataset-oscar #dataset-chitanka #dataset-wikipedia #arxiv-2004.09813 #license-mit #region-us 
 # ROBERTA BASE (cased) trained on private Bulgarian-English parallel data
This is a Multilingual Roberta model. It could be used for creating embeddings of Bulgarian sentences. 

Using the ideas from Sentence-BERT, the training is based on the idea that a translated sentence should be mapped to the same location in the vector space as the original sentence. 

This model is cased: it does make a difference between bulgarian and Bulgarian.

It was trained on private Bulgarian-English parallel data. ### How to use

Here is how to use this model in PyTorch:
passage: TAGS
#transformers #pytorch #xlm-roberta #feature-extraction #torch #sentence-similarity #bg #dataset-oscar #dataset-chitanka #dataset-wikipedia #arxiv-2004.09813 #license-mit #region-us 
# ROBERTA BASE (cased) trained on private Bulgarian-English parallel data
This is a Multilingual Roberta model. It could be used for creating embeddings of Bulgarian sentences. 

Using the ideas from Sentence-BERT, the training is based on the idea that a translated sentence should be mapped to the same location in the vector space as the original sentence. 

This model is cased: it does make a difference between bulgarian and Bulgarian.

It was trained on private Bulgarian-English parallel data.### How to use

Here is how to use this model in PyTorch: