---
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- dense
- generated_from_trainer
- dataset_size:4096000
- loss:MultipleNegativesRankingLoss
base_model: BAAI/bge-small-en-v1.5
widget:
- source_sentence: vascular disorders of the stomach
sentences:
- vascular disorders of the stomach, unspecified
- ringworm of the hand
- anogenital herpes
- source_sentence: neonatal malabsorption secondary to defect in carbohydrate metabolism
sentences:
- overfeeding problem of newborn
- other specified neonatal malabsorption syndromes
- bronchial asthma
- source_sentence: white matter disorder due to carbon monoxide toxicity
sentences:
- white matter disorder due to nitrous oxide toxicity
- neonatal dehydration
- moerman lethal chondrodysplasia
- source_sentence: chronic myelogenous leukaemia, bcr-abl1-positive in complete remission
sentences:
- chronic myeloid leukaemia, bcr-abl-positive in complete remission
- lesion of sciatic nerve
- tooth injury
- source_sentence: metabolic or transporter liver disease, unspecified
sentences:
- metabolic or transporter liver disease
- staphyloma of cornea
- spontaneous rupture of synovium or tendon, unspecified
pipeline_tag: sentence-similarity
library_name: sentence-transformers
metrics:
- cosine_accuracy@1
- cosine_accuracy@5
- cosine_accuracy@10
- cosine_precision@1
- cosine_precision@3
- cosine_precision@5
- cosine_precision@10
- cosine_recall@1
- cosine_recall@3
- cosine_recall@5
- cosine_recall@10
- cosine_ndcg@10
- cosine_mrr@10
- cosine_map@10
model-index:
- name: SentenceTransformer based on BAAI/bge-small-en-v1.5
results:
- task:
type: information-retrieval
name: Information Retrieval
dataset:
name: icd11 val
type: icd11-val
metrics:
- type: cosine_accuracy@1
value: 0.7478448275862069
name: Cosine Accuracy@1
- type: cosine_accuracy@5
value: 0.8717672413793104
name: Cosine Accuracy@5
- type: cosine_accuracy@10
value: 0.896551724137931
name: Cosine Accuracy@10
- type: cosine_precision@1
value: 0.7478448275862069
name: Cosine Precision@1
- type: cosine_precision@3
value: 0.6253591954022988
name: Cosine Precision@3
- type: cosine_precision@5
value: 0.5258620689655173
name: Cosine Precision@5
- type: cosine_precision@10
value: 0.3786637931034483
name: Cosine Precision@10
- type: cosine_recall@1
value: 0.1588556265383415
name: Cosine Recall@1
- type: cosine_recall@3
value: 0.37728305808648516
name: Cosine Recall@3
- type: cosine_recall@5
value: 0.4796248471294223
name: Cosine Recall@5
- type: cosine_recall@10
value: 0.6031417673743621
name: Cosine Recall@10
- type: cosine_ndcg@10
value: 0.6649315033350626
name: Cosine Ndcg@10
- type: cosine_mrr@10
value: 0.8006516830870286
name: Cosine Mrr@10
- type: cosine_map@10
value: 0.5745241229374094
name: Cosine Map@10
---
# SentenceTransformer based on BAAI/bge-small-en-v1.5
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [BAAI/bge-small-en-v1.5](https://huggingface.co/BAAI/bge-small-en-v1.5). It maps sentences & paragraphs to a 384-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, classification, clustering, and more.
## Model Details
### Model Description
- **Model Type:** Sentence Transformer
- **Base model:** [BAAI/bge-small-en-v1.5](https://huggingface.co/BAAI/bge-small-en-v1.5)
- **Maximum Sequence Length:** 30 tokens
- **Output Dimensionality:** 384 dimensions
- **Similarity Function:** Cosine Similarity
- **Supported Modality:** Text
### Model Sources
- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
- **Repository:** [Sentence Transformers on GitHub](https://github.com/huggingface/sentence-transformers)
- **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
### Full Model Architecture
```
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'BertModel'})
(1): Pooling({'embedding_dimension': 384, 'pooling_mode': 'cls', '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("seanfarrell/icd11_ner_model_small")
# Run inference
queries = [
'metabolic or transporter liver disease, unspecified',
]
documents = [
'metabolic or transporter liver disease',
'spontaneous rupture of synovium or tendon, unspecified',
'staphyloma of cornea',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 384] [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[ 0.9840, -0.1296, -0.1292]])
```
## Evaluation
### Metrics
#### Information Retrieval
* Dataset: `icd11-val`
* Evaluated with [InformationRetrievalEvaluator](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.sentence_transformer.evaluation.InformationRetrievalEvaluator)
| Metric | Value |
|:--------------------|:-----------|
| cosine_accuracy@1 | 0.7478 |
| cosine_accuracy@5 | 0.8718 |
| cosine_accuracy@10 | 0.8966 |
| cosine_precision@1 | 0.7478 |
| cosine_precision@3 | 0.6254 |
| cosine_precision@5 | 0.5259 |
| cosine_precision@10 | 0.3787 |
| cosine_recall@1 | 0.1589 |
| cosine_recall@3 | 0.3773 |
| cosine_recall@5 | 0.4796 |
| cosine_recall@10 | 0.6031 |
| **cosine_ndcg@10** | **0.6649** |
| cosine_mrr@10 | 0.8007 |
| cosine_map@10 | 0.5745 |
## Training Details
### Training Dataset
#### Unnamed Dataset
* Size: 4,096,000 training samples
* Columns: anchor and positive
* Approximate statistics based on the first 100 samples:
| | anchor | positive |
|:---------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|
| type | string | string |
| modality | text | text |
| details |
- min: 4 tokens
- mean: 11.07 tokens
- max: 30 tokens
| - min: 4 tokens
- mean: 11.07 tokens
- max: 28 tokens
|
* Samples:
| anchor | positive |
|:-------------------------------------------------------------|:-----------------------------------------------------------------|
| duodenal adenoma in familial polyposis | benign duodenal neoplasm |
| congenital unilateral hip dislocation | developmental dysplasia of hip, unilateral |
| postprocedural pulmonary arterial tree disorder | postprocedural pulmonary arterial tree complication |
* Loss: [MultipleNegativesRankingLoss](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#multiplenegativesrankingloss) with these parameters:
```json
{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false,
"directions": [
"query_to_doc"
],
"partition_mode": "joint",
"hardness_mode": null,
"hardness_strength": 0.0
}
```
### Training Hyperparameters
#### Non-Default Hyperparameters
- `per_device_train_batch_size`: 512
- `num_train_epochs`: 1
- `learning_rate`: 2e-05
- `lr_scheduler_type`: cosine
- `warmup_steps`: 800
- `weight_decay`: 0.01
- `bf16`: True
- `per_device_eval_batch_size`: 256
- `eval_on_start`: True
- `load_best_model_at_end`: True
- `dataloader_drop_last`: True
#### All Hyperparameters
Click to expand
- `per_device_train_batch_size`: 512
- `num_train_epochs`: 1
- `max_steps`: -1
- `learning_rate`: 2e-05
- `lr_scheduler_type`: cosine
- `lr_scheduler_kwargs`: None
- `warmup_steps`: 800
- `optim`: adamw_torch_fused
- `optim_args`: None
- `weight_decay`: 0.01
- `adam_beta1`: 0.9
- `adam_beta2`: 0.999
- `adam_epsilon`: 1e-08
- `optim_target_modules`: None
- `gradient_accumulation_steps`: 1
- `average_tokens_across_devices`: True
- `max_grad_norm`: 1.0
- `label_smoothing_factor`: 0.0
- `bf16`: True
- `fp16`: False
- `bf16_full_eval`: False
- `fp16_full_eval`: False
- `tf32`: None
- `gradient_checkpointing`: False
- `gradient_checkpointing_kwargs`: None
- `torch_compile`: False
- `torch_compile_backend`: None
- `torch_compile_mode`: None
- `use_liger_kernel`: False
- `liger_kernel_config`: None
- `use_cache`: False
- `neftune_noise_alpha`: None
- `torch_empty_cache_steps`: None
- `auto_find_batch_size`: False
- `log_on_each_node`: True
- `logging_nan_inf_filter`: True
- `include_num_input_tokens_seen`: no
- `log_level`: passive
- `log_level_replica`: warning
- `disable_tqdm`: False
- `project`: huggingface
- `trackio_space_id`: None
- `trackio_bucket_id`: None
- `trackio_static_space_id`: None
- `per_device_eval_batch_size`: 256
- `prediction_loss_only`: True
- `eval_on_start`: True
- `eval_do_concat_batches`: True
- `eval_use_gather_object`: False
- `eval_accumulation_steps`: None
- `include_for_metrics`: []
- `batch_eval_metrics`: False
- `save_only_model`: False
- `save_on_each_node`: False
- `enable_jit_checkpoint`: False
- `push_to_hub`: False
- `hub_private_repo`: None
- `hub_model_id`: None
- `hub_strategy`: every_save
- `hub_always_push`: False
- `hub_revision`: None
- `load_best_model_at_end`: True
- `ignore_data_skip`: False
- `restore_callback_states_from_checkpoint`: False
- `full_determinism`: False
- `seed`: 42
- `data_seed`: None
- `use_cpu`: False
- `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
- `parallelism_config`: None
- `dataloader_drop_last`: True
- `dataloader_num_workers`: 0
- `dataloader_pin_memory`: True
- `dataloader_persistent_workers`: False
- `dataloader_prefetch_factor`: None
- `dataloader_multiprocessing_context`: None
- `dataloader_in_order`: True
- `remove_unused_columns`: True
- `label_names`: None
- `train_sampling_strategy`: random
- `length_column_name`: length
- `ddp_find_unused_parameters`: None
- `ddp_bucket_cap_mb`: None
- `ddp_broadcast_buffers`: False
- `ddp_static_graph`: None
- `ddp_backend`: None
- `ddp_timeout`: 1800
- `fsdp`: None
- `fsdp_config`: None
- `deepspeed`: None
- `debug`: []
- `skip_memory_metrics`: True
- `do_predict`: False
- `resume_from_checkpoint`: None
- `local_rank`: -1
- `prompts`: None
- `batch_sampler`: batch_sampler
- `multi_dataset_batch_sampler`: proportional
- `router_mapping`: {}
- `learning_rate_mapping`: {}
- `warmup_ratio`: None
### Training Logs
Click to expand
| Epoch | Step | Training Loss | icd11-val_cosine_ndcg@10 |
|:----------:|:--------:|:-------------:|:------------------------:|
| 0 | 0 | - | 0.4871 |
| 0.0063 | 50 | 2.5057 | - |
| 0.0125 | 100 | 2.1921 | - |
| 0.0187 | 150 | 1.6707 | - |
| 0.025 | 200 | 1.4270 | - |
| 0.0312 | 250 | 1.3379 | - |
| 0.0375 | 300 | 1.2811 | - |
| 0.0437 | 350 | 1.2222 | - |
| 0.05 | 400 | 1.1848 | - |
| 0.0563 | 450 | 1.1484 | - |
| 0.0625 | 500 | 1.1260 | 0.5411 |
| 0.0688 | 550 | 1.0856 | - |
| 0.075 | 600 | 1.0654 | - |
| 0.0813 | 650 | 1.0247 | - |
| 0.0875 | 700 | 1.0050 | - |
| 0.0938 | 750 | 0.9669 | - |
| 0.1 | 800 | 0.9515 | - |
| 0.1062 | 850 | 0.9404 | - |
| 0.1125 | 900 | 0.8906 | - |
| 0.1187 | 950 | 0.8692 | - |
| 0.125 | 1000 | 0.8413 | 0.5746 |
| 0.1313 | 1050 | 0.8439 | - |
| 0.1375 | 1100 | 0.8270 | - |
| 0.1437 | 1150 | 0.8128 | - |
| 0.15 | 1200 | 0.7762 | - |
| 0.1562 | 1250 | 0.7666 | - |
| 0.1625 | 1300 | 0.7555 | - |
| 0.1688 | 1350 | 0.7562 | - |
| 0.175 | 1400 | 0.7180 | - |
| 0.1812 | 1450 | 0.6945 | - |
| 0.1875 | 1500 | 0.7032 | 0.6002 |
| 0.1938 | 1550 | 0.6747 | - |
| 0.2 | 1600 | 0.6729 | - |
| 0.2062 | 1650 | 0.6604 | - |
| 0.2125 | 1700 | 0.6644 | - |
| 0.2188 | 1750 | 0.6556 | - |
| 0.225 | 1800 | 0.6440 | - |
| 0.2313 | 1850 | 0.6284 | - |
| 0.2375 | 1900 | 0.6105 | - |
| 0.2437 | 1950 | 0.5935 | - |
| 0.25 | 2000 | 0.5923 | 0.6120 |
| 0.2562 | 2050 | 0.5850 | - |
| 0.2625 | 2100 | 0.5787 | - |
| 0.2687 | 2150 | 0.5764 | - |
| 0.275 | 2200 | 0.5643 | - |
| 0.2812 | 2250 | 0.5655 | - |
| 0.2875 | 2300 | 0.5463 | - |
| 0.2938 | 2350 | 0.5414 | - |
| 0.3 | 2400 | 0.5368 | - |
| 0.3063 | 2450 | 0.5236 | - |
| 0.3125 | 2500 | 0.5109 | 0.6230 |
| 0.3187 | 2550 | 0.5308 | - |
| 0.325 | 2600 | 0.5000 | - |
| 0.3312 | 2650 | 0.5069 | - |
| 0.3375 | 2700 | 0.5120 | - |
| 0.3438 | 2750 | 0.4853 | - |
| 0.35 | 2800 | 0.4877 | - |
| 0.3563 | 2850 | 0.4786 | - |
| 0.3625 | 2900 | 0.4869 | - |
| 0.3688 | 2950 | 0.4865 | - |
| 0.375 | 3000 | 0.4561 | 0.6332 |
| 0.3812 | 3050 | 0.4640 | - |
| 0.3875 | 3100 | 0.4629 | - |
| 0.3937 | 3150 | 0.4575 | - |
| 0.4 | 3200 | 0.4493 | - |
| 0.4062 | 3250 | 0.4503 | - |
| 0.4125 | 3300 | 0.4301 | - |
| 0.4188 | 3350 | 0.4410 | - |
| 0.425 | 3400 | 0.4415 | - |
| 0.4313 | 3450 | 0.4316 | - |
| 0.4375 | 3500 | 0.4359 | 0.6441 |
| 0.4437 | 3550 | 0.4147 | - |
| 0.45 | 3600 | 0.4028 | - |
| 0.4562 | 3650 | 0.4002 | - |
| 0.4625 | 3700 | 0.4132 | - |
| 0.4688 | 3750 | 0.4021 | - |
| 0.475 | 3800 | 0.4058 | - |
| 0.4813 | 3850 | 0.4023 | - |
| 0.4875 | 3900 | 0.4038 | - |
| 0.4938 | 3950 | 0.4007 | - |
| 0.5 | 4000 | 0.3894 | 0.6501 |
| 0.5062 | 4050 | 0.3856 | - |
| 0.5125 | 4100 | 0.3879 | - |
| 0.5188 | 4150 | 0.3758 | - |
| 0.525 | 4200 | 0.3796 | - |
| 0.5312 | 4250 | 0.3890 | - |
| 0.5375 | 4300 | 0.3831 | - |
| 0.5437 | 4350 | 0.3806 | - |
| 0.55 | 4400 | 0.3781 | - |
| 0.5563 | 4450 | 0.3761 | - |
| 0.5625 | 4500 | 0.3723 | 0.6551 |
| 0.5687 | 4550 | 0.3603 | - |
| 0.575 | 4600 | 0.3595 | - |
| 0.5813 | 4650 | 0.3524 | - |
| 0.5875 | 4700 | 0.3695 | - |
| 0.5938 | 4750 | 0.3552 | - |
| 0.6 | 4800 | 0.3521 | - |
| 0.6062 | 4850 | 0.3459 | - |
| 0.6125 | 4900 | 0.3472 | - |
| 0.6188 | 4950 | 0.3511 | - |
| 0.625 | 5000 | 0.3537 | 0.6589 |
| 0.6312 | 5050 | 0.3490 | - |
| 0.6375 | 5100 | 0.3428 | - |
| 0.6438 | 5150 | 0.3492 | - |
| 0.65 | 5200 | 0.3471 | - |
| 0.6562 | 5250 | 0.3348 | - |
| 0.6625 | 5300 | 0.3404 | - |
| 0.6687 | 5350 | 0.3442 | - |
| 0.675 | 5400 | 0.3494 | - |
| 0.6813 | 5450 | 0.3306 | - |
| 0.6875 | 5500 | 0.3349 | 0.6598 |
| 0.6937 | 5550 | 0.3401 | - |
| 0.7 | 5600 | 0.3374 | - |
| 0.7063 | 5650 | 0.3306 | - |
| 0.7125 | 5700 | 0.3277 | - |
| 0.7188 | 5750 | 0.3274 | - |
| 0.725 | 5800 | 0.3318 | - |
| 0.7312 | 5850 | 0.3316 | - |
| 0.7375 | 5900 | 0.3273 | - |
| 0.7438 | 5950 | 0.3252 | - |
| 0.75 | 6000 | 0.3306 | 0.6636 |
| 0.7562 | 6050 | 0.3347 | - |
| 0.7625 | 6100 | 0.3186 | - |
| 0.7688 | 6150 | 0.3301 | - |
| 0.775 | 6200 | 0.3203 | - |
| 0.7812 | 6250 | 0.3234 | - |
| 0.7875 | 6300 | 0.3134 | - |
| 0.7937 | 6350 | 0.3175 | - |
| 0.8 | 6400 | 0.3312 | - |
| 0.8063 | 6450 | 0.3302 | - |
| 0.8125 | 6500 | 0.3189 | 0.6644 |
| 0.8187 | 6550 | 0.3191 | - |
| 0.825 | 6600 | 0.3265 | - |
| 0.8313 | 6650 | 0.3192 | - |
| 0.8375 | 6700 | 0.3111 | - |
| 0.8438 | 6750 | 0.3124 | - |
| 0.85 | 6800 | 0.3101 | - |
| 0.8562 | 6850 | 0.3188 | - |
| 0.8625 | 6900 | 0.3180 | - |
| 0.8688 | 6950 | 0.3153 | - |
| 0.875 | 7000 | 0.3159 | 0.6646 |
| 0.8812 | 7050 | 0.3132 | - |
| 0.8875 | 7100 | 0.3168 | - |
| 0.8938 | 7150 | 0.3227 | - |
| 0.9 | 7200 | 0.3121 | - |
| 0.9062 | 7250 | 0.3212 | - |
| 0.9125 | 7300 | 0.3195 | - |
| 0.9187 | 7350 | 0.3177 | - |
| 0.925 | 7400 | 0.3228 | - |
| 0.9313 | 7450 | 0.3172 | - |
| **0.9375** | **7500** | **0.3045** | **0.6652** |
| 0.9437 | 7550 | 0.3052 | - |
| 0.95 | 7600 | 0.3273 | - |
| 0.9563 | 7650 | 0.3163 | - |
| 0.9625 | 7700 | 0.3138 | - |
| 0.9688 | 7750 | 0.3280 | - |
| 0.975 | 7800 | 0.3074 | - |
| 0.9812 | 7850 | 0.3266 | - |
| 0.9875 | 7900 | 0.3214 | - |
| 0.9938 | 7950 | 0.3240 | - |
| 1.0 | 8000 | 0.3141 | 0.6649 |
* The bold row denotes the saved checkpoint.
### Training Time
- **Training**: 8.9 minutes
- **Evaluation**: 45.4 seconds
- **Total**: 9.7 minutes
### Framework Versions
- Python: 3.13.15
- Sentence Transformers: 5.7.0
- Transformers: 5.18.0
- PyTorch: 2.11.0+cu130
- Accelerate: 1.15.0
- Datasets: 4.8.5
- Tokenizers: 0.23.2
## Additional Resources
- [Training and Finetuning Embedding Models with Sentence Transformers](https://huggingface.co/blog/train-sentence-transformers): the end-to-end guide for training or finetuning Sentence Transformer models.
- [Introduction to Matryoshka Embedding Models](https://huggingface.co/blog/matryoshka): variable-size embeddings that can be truncated with minimal quality loss.
- [Binary and Scalar Embedding Quantization for Significantly Faster & Cheaper Retrieval](https://huggingface.co/blog/embedding-quantization): post-training compression of embedding vectors.
- [Multimodal Embedding & Reranker Models with Sentence Transformers](https://huggingface.co/blog/multimodal-sentence-transformers): use text, image, audio, and video models through the same API.
- [Training and Finetuning Multimodal Embedding & Reranker Models with Sentence Transformers](https://huggingface.co/blog/train-multimodal-sentence-transformers): train multimodal embedding models, with a Visual Document Retrieval walkthrough.
## Citation
### BibTeX
#### Sentence Transformers
```bibtex
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/1908.10084",
}
```
#### MultipleNegativesRankingLoss
```bibtex
@misc{oord2019representationlearningcontrastivepredictive,
title={Representation Learning with Contrastive Predictive Coding},
author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
year={2019},
eprint={1807.03748},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/1807.03748},
}
```