Sentence Similarity
sentence-transformers
Safetensors
Transformers
Korean
deberta-v2
feature-extraction
text-embeddings-inference
Run this model with HF Jobs
Run bi-matrix/gmatrix-embedding1 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/bi-matrix/gmatrix-embedding1. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/bi-matrix/gmatrix-embedding1 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use bi-matrix/gmatrix-embedding1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use bi-matrix/gmatrix-embedding1 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("bi-matrix/gmatrix-embedding1") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Transformers
How to use bi-matrix/gmatrix-embedding1 with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("bi-matrix/gmatrix-embedding1") model = AutoModel.from_pretrained("bi-matrix/gmatrix-embedding1", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files123---license: apache-2.0---123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182---pipeline_tag: sentence-similaritytags:- sentence-transformers- feature-extraction- sentence-similarity- transformersdatasets:- kornlulanguage:- kolicense: cc-by-4.0---# bi-matrix/gmatrix-embeddingํด๋น ๋ชจ๋ธ์ [KF-DeBERTa](https://huggingface.co/kakaobank/kf-deberta-base) ๋ชจ๋ธ๊ณผ KorSTS, KorNLI ๋ฐ์ดํฐ์ ์ ํ์ฉํ์์ผ๋ฉฐ, sentence-transformers์ ๊ณต์ ๋ฌธ์ ๋ด ์๊ฐ๋ [continue-learning](https://github.com/UKPLab/sentence-transformers/blob/master/examples/training/sts/training_stsbenchmark_continue_training.py) ๋ฐฉ๋ฒ์ ํตํด ์๋์ ๊ฐ์ด ํ์ต๋์์ต๋๋ค.1. NLI ๋ฐ์ดํฐ์ ์ ํตํด nagative sampling ํ MultipleNegativeRankingLoss ํ์ฉ ๋ฐ STS ๋ฐ์ดํฐ์ ์ ํตํด CosineSimilarityLoss๋ฅผ ํ์ฉํ์ฌ Multi-task Learning ํ์ต 10epoch ์งํ2. Learning Rate๋ฅผ 1e-06์ผ๋ก ์ค์ฌ์ 4epoch ์ถ๊ฐ Multi-task ํ์ต ์งํ---This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like clustering or semantic search.<!--- Describe your model here -->## Usage (Sentence-Transformers)Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:```pip install -U sentence-transformers```Then you can use the model like this:```pythonfrom sentence_transformers import SentenceTransformersentences = ["This is an example sentence", "Each sentence is converted"]model = SentenceTransformer("bi-matrix/gmatrix-embedding")embeddings = model.encode(sentences)print(embeddings)```## Usage (HuggingFace Transformers)Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.```pythonfrom transformers import AutoTokenizer, AutoModelimport torch#Mean Pooling - Take attention mask into account for correct averagingdef mean_pooling(model_output, attention_mask):token_embeddings = model_output[0] #First element of model_output contains all token embeddingsinput_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 we want sentence embeddings forsentences = ['This is an example sentence', 'Each sentence is converted']# Load model from HuggingFace Hubtokenizer = AutoTokenizer.from_pretrained("bi-matrix/gmatrix-embedding")model = AutoModel.from_pretrained("bi-matrix/gmatrix-embedding")# Tokenize sentencesencoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')# Compute token embeddingswith torch.no_grad():model_output = model(**encoded_input)# Perform pooling. In this case, mean pooling.sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])print("Sentence embeddings:")print(sentence_embeddings)```## Evaluation Results<!--- Describe how your model was evaluated -->KorSTS ํ๊ฐ ๋ฐ์ดํฐ์ ์ผ๋ก ํ๊ฐํ ๊ฒฐ๊ณผ์ ๋๋ค.- Cosine Pearson: 85.77- Cosine Spearman: 86.30- Manhattan Pearson: 84.84- Manhattan Spearman: 85.33- Euclidean Pearson: 84.82- Euclidean Spearman: 85.29- Dot Pearson: 83.19- Dot Spearman: 83.19<br>|model|cosine_pearson|cosine_spearman|euclidean_pearson|euclidean_spearman|manhattan_pearson|manhattan_spearman|dot_pearson|dot_spearman||:-------------------------|-----------------:|------------------:|--------------------:|---------------------:|--------------------:|---------------------:|--------------:|---------------:||[**gmatrix-embedding**](https://huggingface.co/bi-matrix/gmatrix-embedding)|**85.77**|**86.30**|**84.82**|**85.29**|**84.84**|**85.33**|**83.19**|**83.19**||[kf-deberta-multitask](https://huggingface.co/upskyy/kf-deberta-multitask)|85.75|86.25|84.79|85.25|84.80|85.27|82.93|82.86||[ko-sroberta-multitask](https://huggingface.co/jhgan/ko-sroberta-multitask)|84.77|85.6|83.71|84.40|83.70|84.38|82.42|82.33||[ko-sbert-multitask](https://huggingface.co/jhgan/ko-sbert-multitask)|84.13|84.71|82.42|82.66|82.41|82.69|80.05|79.69||[ko-sroberta-base-nli](https://huggingface.co/jhgan/ko-sroberta-nli)|82.83|83.85|82.87|83.29|82.88|83.28|80.34|79.69||[ko-sbert-nli](https://huggingface.co/jhgan/ko-sbert-multitask)|82.24|83.16|82.19|82.31|82.18|82.3|79.3|78.78||[ko-sroberta-sts](https://huggingface.co/jhgan/ko-sroberta-sts)|81.84|81.82|81.15|81.25|81.14|81.25|79.09|78.54||[ko-sbert-sts](https://huggingface.co/jhgan/ko-sbert-sts)|81.55|81.23|79.94|79.79|79.9|79.75|76.02|75.31|<br><!--- Describe how your model was evaluated -->G-MATRIX Embedding ๋ฐ์ดํฐ์ ์ธก์ ๊ฒฐ๊ณผ์ ๋๋ค.์ฌ๋ 3๋ช ์ด์ 0~5์ ์ผ๋ก ๋ ๋ฌธ์ฅ๊ฐ์ ์ ์ฌ๋๋ฅผ ์ธก์ ํ์ฌ ์ ์๋ฅผ ๋ด๊ณ ํ๊ท ๏ฟฝ๏ฟฝ ๊ตฌํ์ฌ ๊ฐ ๋ชจ๋ธ์ ์๋ฒ ๋ฉ๊ฐ์ ํตํด์ฝ์ฌ์ธ ์ ์ฌ๋, ์ ํด๋ฆฌ๋์ ๊ฑฐ๋ฆฌ, ๋งจํํ ๊ฑฐ๋ฆฌ, Dot-product๋ฅผ ๊ตฌํ์ฌ ํผ์ด์จ, ์คํผ์ด๋ง ์๊ด๊ณ์๋ฅผ ๊ตฌํ ๊ฐ์ ๋๋ค.- Cosine Pearson: 75.86- Cosine Spearman: 65.75- Manhattan Pearson: 72.65- Manhattan Spearman: 65.20- Euclidean Pearson: 72.48- Euclidean Spearman: 65.32- Dot Pearson: 64.71- Dot Spearman: 53.90<br>model|cosine_pearson|cosine_spearman|euclidean_pearson|euclidean_spearman|manhattan_pearson|manhattan_spearman|dot_pearson|dot_spearman||:-------------------------|-----------------:|------------------:|--------------------:|---------------------:|--------------------:|---------------------:|--------------:|---------------:||[**gmatrix-embedding**](https://huggingface.co/bi-matrix/gmatrix-embedding)|**75.86**|**65.75**|**72.65**|**65.20**|**72.48**|**65.32**|**64.71**|**53.90**||[ko-sroberta-multitask](https://huggingface.co/jhgan/ko-sroberta-multitask)|71.78|63.16|70.80|63.47|70.89|63.72|53.57|44.23||[bge-m3](https://huggingface.co/BAAI/bge-m3)|64.15|60.65|61.88|60.68|61.88|60.19|64.16|60.71|<br><br>## G-MATRIX Embedding ๋ ์ด๋ธ๋ง ํ๋จ ๊ธฐ์ค (KLUE-RoBERTa์ STS ๋ฐ์ดํฐ ์์ฑ ์ฐธ๊ณ )1. ๋ ๋ฌธ์ฅ์ ์ ์ฌํ ์ ๋๋ฅผ ๋ณด๊ณ 0~5์ ์ผ๋ก ํ๋จ2. ๋ง์ถค๋ฒ, ๋์ด์ฐ๊ธฐ, ์จ์ ์ด๋ ์ผํ ์ฐจ์ด๋ ํ๋จ ๋์์ด ์๋3. ๋ฌธ์ฅ์ ์๋, ํํ์ด ๋ด๊ณ ์๋ ์๋ฏธ๋ฅผ ๋น๊ต4. ๋ ๋ฌธ์ฅ์ ๊ณตํต์ ์ผ๋ก ์ฌ์ฉ๋ ๋จ์ด์ ์ ๋ฌด๋ฅผ ์ฐพ๋ ๊ฒ์ด ์๋, ๋ฌธ์ฅ์ ์๋ฏธ๊ฐ ์ ์ฌํ์ง๋ฅผ ๋น๊ต5. 0์ ์๋ฏธ์ ์ ์ฌ์ฑ์ด ์๋ ๊ฒฝ์ฐ์ด๊ณ , 5๋ ์๋ฏธ์ ์ผ๋ก ๋๋ฑํจ์ ๋ปํจ## TrainingThe model was trained with the parameters:**DataLoader**:`torch.utils.data.dataloader.DataLoader` of length 329 with parameters:```{'batch_size': 32, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}```**Loss**:`sentence_transformers.losses.CosineSimilarityLoss.CosineSimilarityLoss`## Full Model Architecture```SentenceTransformer((0): Transformer({'max_seq_length': 128, 'do_lower_case': True}) with Transformer model: DeBERTaV2Model(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}))```## Citing & Authors<!--- Describe where people can find more information -->[MINSANG SONG] at [BI-Matrix](https://www.bimatrix.co.kr/)
README.md+182-3