st polish paraphrase from distilroberta
sdadasIntroduction
The ST-Polish-Paraphrase-from-DistilRoBERTa is a sentence-transformers model designed for mapping sentences and paragraphs into a 768-dimensional dense vector space. This model is suitable for tasks such as clustering and semantic search, particularly for Polish language input.
Architecture
The model uses a SentenceTransformer architecture, which consists of:
- A Transformer component based on the RoBERTa model with a maximum sequence length of 256 tokens.
- A Pooling layer that averages the token embeddings to obtain sentence embeddings.
Training
The model was fine-tuned on paraphrasing tasks to enhance sentence similarity performance. It leverages the DistilRoBERTa backbone for efficient processing while maintaining performance.
Guide: Running Locally
-
Install Required Libraries
- Use
pip install -U sentence-transformers
for the sentence-transformers library.
- Use
-
Using Sentence-Transformers
from sentence_transformers import SentenceTransformer sentences = ["This is an example sentence", "Each sentence is converted"] model = SentenceTransformer('sdadas/st-polish-paraphrase-from-distilroberta') embeddings = model.encode(sentences) print(embeddings)
-
Using Hugging Face Transformers
from transformers import AutoTokenizer, AutoModel import torch def mean_pooling(model_output, attention_mask): token_embeddings = model_output[0] input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float() return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9) sentences = ['This is an example sentence', 'Each sentence is converted'] tokenizer = AutoTokenizer.from_pretrained('sdadas/st-polish-paraphrase-from-distilroberta') model = AutoModel.from_pretrained('sdadas/st-polish-paraphrase-from-distilroberta') encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt') with torch.no_grad(): model_output = model(**encoded_input) sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask']) print("Sentence embeddings:") print(sentence_embeddings)
-
Suggest Cloud GPUs
- Consider using cloud services like AWS EC2, Google Cloud, or Azure for GPU resources to efficiently run the model, especially for large datasets or high-volume processing.
License
The model is licensed under the LGPL (Lesser General Public License), allowing for flexibility in use and modification while ensuring that derivative works remain open-source under the same license.