---
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- generated_from_trainer
- dataset_size:1128
- loss:CosineSimilarityLoss
base_model: sentence-transformers/all-MiniLM-L6-v2
widget:
- source_sentence: connective tissue cell
sentences:
- GM18507
- GM18526
- GM08714
- source_sentence: blood
sentences:
- AG04449
- T cell
- GM12868
- source_sentence: mammary gland
sentences:
- MCF-7
- leukocyte
- GM10847
- source_sentence: GM18526
sentences:
- digestive system
- CMK
- KOPT-K1
- source_sentence: GM12873
sentences:
- KOPT-K1
- pancreas
- leukocyte
datasets:
- databio/mock-stsb
pipeline_tag: sentence-similarity
library_name: sentence-transformers
metrics:
- pearson_cosine
- spearman_cosine
model-index:
- name: SentenceTransformer based on sentence-transformers/all-MiniLM-L6-v2
results:
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts dev
type: sts-dev
metrics:
- type: pearson_cosine
value: 0.7058652030883807
name: Pearson Cosine
- type: spearman_cosine
value: 0.69543787652822
name: Spearman Cosine
---
# SentenceTransformer based on sentence-transformers/all-MiniLM-L6-v2
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) on the [mock-stsb](https://huggingface.co/datasets/databio/mock-stsb) dataset. It maps sentences & paragraphs to a 384-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
## Model Details
### Model Description
- **Model Type:** Sentence Transformer
- **Base model:** [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)
- **Maximum Sequence Length:** 256 tokens
- **Output Dimensionality:** 384 dimensions
- **Similarity Function:** Cosine Similarity
- **Training Dataset:**
- [mock-stsb](https://huggingface.co/datasets/databio/mock-stsb)
### Model Sources
- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
- **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
- **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
### Full Model Architecture
```
SentenceTransformer(
(0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
(2): Normalize()
)
```
## Usage
### Direct Usage (Sentence Transformers)
First install the Sentence Transformers library:
```bash
pip install -U sentence-transformers
```
Then you can load this model and run inference.
```python
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("sentence_transformers_model_id")
# Run inference
sentences = [
'GM12873',
'leukocyte',
'pancreas',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
```
## Evaluation
### Metrics
#### Semantic Similarity
* Dataset: `sts-dev`
* Evaluated with [EmbeddingSimilarityEvaluator
](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator)
| Metric | Value |
|:--------------------|:-----------|
| pearson_cosine | 0.7059 |
| **spearman_cosine** | **0.6954** |
## Training Details
### Training Dataset
#### mock-stsb
* Dataset: [mock-stsb](https://huggingface.co/datasets/databio/mock-stsb) at [d5ba748](https://huggingface.co/datasets/databio/mock-stsb/tree/d5ba748c12ecb4eb2178b42c9735506a50de9f86)
* Size: 1,128 training samples
* Columns: sentence1
, sentence2
, and score
* Approximate statistics based on the first 1000 samples:
| | sentence1 | sentence2 | score |
|:--------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------|
| type | string | string | float |
| details |
OVCAR3
| pancreas
| 0.05
|
| L1-S8
| respiratory system
| 0.001
|
| peripheral nervous system
| 22Rv1
| 0.001
|
* Loss: [CosineSimilarityLoss
](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosinesimilarityloss) with these parameters:
```json
{
"loss_fct": "torch.nn.modules.loss.MSELoss"
}
```
### Evaluation Dataset
#### mock-stsb
* Dataset: [mock-stsb](https://huggingface.co/datasets/databio/mock-stsb) at [d5ba748](https://huggingface.co/datasets/databio/mock-stsb/tree/d5ba748c12ecb4eb2178b42c9735506a50de9f86)
* Size: 284 evaluation samples
* Columns: sentence1
, sentence2
, and score
* Approximate statistics based on the first 284 samples:
| | sentence1 | sentence2 | score |
|:--------|:-------------------------------------------------------------------------------|:--------------------------------------------------------------------------------|:---------------------------------------------------------------|
| type | string | string | float |
| details | SJCRH30
| cancer cell
| 0.9
|
| CWRU1
| exocrine gland
| 0.05
|
| epithelial cell
| Caki2
| 0.9
|
* Loss: [CosineSimilarityLoss
](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosinesimilarityloss) with these parameters:
```json
{
"loss_fct": "torch.nn.modules.loss.MSELoss"
}
```
### Training Hyperparameters
#### Non-Default Hyperparameters
- `eval_strategy`: epoch
- `per_device_train_batch_size`: 4
- `per_device_eval_batch_size`: 4
- `learning_rate`: 1e-05
- `num_train_epochs`: 50
- `warmup_ratio`: 0.1
- `load_best_model_at_end`: True
#### All Hyperparameters