๐ marigold334/KR-SBERT-V40K-klueNLI-augSTS-ft
This is a version of KR-SBERT that has been fine-tuned by the SNUNLP lab using fine-tuning. It is designed for sentence similarity tasks.
Pipeline and Tags
- Pipeline Tag: sentence-similarity
- Tags: sentence-transformers, feature-extraction, sentence-similarity, transformers
Language
Widget Examples
- Example 1: Restaurant
- Source Sentence: "๊ทธ ์๋น์ ํ๋ฆฌ๋ฅผ ๋ ๋ฆฐ๋ค"
- Comparison Sentences:
- "๊ทธ ์๋น์๋ ์๋์ด ์๋ค"
- "๊ทธ ์๋น์์๋ ๋๋ก ์ ๋ ๋ฆฐ๋ค"
- "ํ๋ฆฌ๊ฐ ์๋น์ ๋ ์๋ค๋๋ค"
- Example 2: Sleepy
- Source Sentence: "์ ์ด ์ต๋๋ค"
- Comparison Sentences:
- "์ ์ด ์ ์ต๋๋ค"
- "์กธ์์ด ์ต๋๋ค"
- "๊ธฐ์ฐจ๊ฐ ์ต๋๋ค"
๐ Quick Start
โจ Features
This model is a fine - tuned version of KR-SBERT, which can effectively perform sentence similarity tasks.
๐ฆ Installation
To use this model, you need to install sentence-transformers:
pip install -U sentence-transformers
๐ป Usage Examples
Basic Usage (Sentence-Transformers)
If you have sentence-transformers installed, using this model is straightforward:
from sentence_transformers import SentenceTransformer
sentences = ["This is an example sentence", "Each sentence is converted"]
model = SentenceTransformer('snunlp/KR-SBERT-V40K-klueNLI-augSTS-ft')
embeddings = model.encode(sentences)
print(embeddings)
Advanced Usage (HuggingFace Transformers)
Without sentence-transformers, you can use the model as follows: First, pass your input through the transformer model, then apply the appropriate pooling operation on top of the contextualized word embeddings.
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('snunlp/KR-SBERT-V40K-klueNLI-augSTS')
model = AutoModel.from_pretrained('snunlp/KR-SBERT-V40K-klueNLI-augSTS-ft')
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)
๐ง Technical Details
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
)