Redis fine-tuned BiEncoder model for semantic caching on LangCache
This is a sentence-transformers model finetuned from Alibaba-NLP/gte-modernbert-base on the LangCache Sentence Pairs (all) dataset. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for sentence pair similarity.
Model Details
Model Description
- Model Type: Sentence Transformer
- Base model: Alibaba-NLP/gte-modernbert-base
- Maximum Sequence Length: 8192 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity
- Training Dataset:
- Language: en
- License: apache-2.0
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 8192, 'do_lower_case': False, 'architecture': 'ModernBertModel'})
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
)
Usage
Direct Usage (Sentence Transformers)
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("aditeyabaral-redis/langcache-embed-v3")
# Run inference
sentences = [
'The band pursued `` signals `` in January 2012 in three weeks , and drums were recorded in a day and a half .',
'The band tracked `` Signals `` in three weeks in January 2012 . Drums were recorded in a day and a half .',
'Contributors include actor Anton LaVey , Satanist Christopher Lee , serial killer expert Clive Barker , author Karen Greenlee , and necrophile Robert Ressler .',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.9599, 0.4944],
# [0.9599, 1.0000, 0.5097],
# [0.4944, 0.5097, 1.0000]])
Evaluation
Metrics
Binary Classification
- Datasets:
valandtest - Evaluated with
BinaryClassificationEvaluator
| Metric | val | test |
|---|---|---|
| cosine_accuracy | 0.763 | 0.7035 |
| cosine_accuracy_threshold | 0.864 | 0.8521 |
| cosine_f1 | 0.6907 | 0.7118 |
| cosine_f1_threshold | 0.8262 | 0.811 |
| cosine_precision | 0.6291 | 0.5979 |
| cosine_recall | 0.7658 | 0.8794 |
| cosine_ap | 0.7351 | 0.6474 |
| cosine_mcc | 0.4771 | 0.4409 |
Training Details
Training Dataset
LangCache Sentence Pairs (all)
- Dataset: LangCache Sentence Pairs (all)
- Size: 62,021 training samples
- Columns:
sentence1,sentence2, andlabel - Approximate statistics based on the first 1000 samples:
sentence1 sentence2 label type string string int details - min: 8 tokens
- mean: 27.46 tokens
- max: 53 tokens
- min: 9 tokens
- mean: 27.36 tokens
- max: 52 tokens
- 0: ~50.30%
- 1: ~49.70%
- Samples:
sentence1 sentence2 label The newer Punts are still very much in existence today and race in the same fleets as the older boats .The newer punts are still very much in existence today and run in the same fleets as the older boats .1Turner Valley , was at the Turner Valley Bar N Ranch Airport , southwest of the Turner Valley Bar N Ranch , Alberta , Canada .Turner Valley Bar N Ranch Airport , , was located at Turner Valley Bar N Ranch , southwest of Turner Valley , Alberta , Canada .0After losing his second election , he resigned as opposition leader and was replaced by Geoff Pearsall .Max Bingham resigned as opposition leader after losing his second election , and was replaced by Geoff Pearsall .1 - Loss:
CoSENTLosswith these parameters:{ "scale": 20.0, "similarity_fct": "pairwise_cos_sim" }
Evaluation Dataset
LangCache Sentence Pairs (all)
- Dataset: LangCache Sentence Pairs (all)
- Size: 62,021 evaluation samples
- Columns:
sentence1,sentence2, andlabel - Approximate statistics based on the first 1000 samples:
sentence1 sentence2 label type string string int details - min: 8 tokens
- mean: 27.46 tokens
- max: 53 tokens
- min: 9 tokens
- mean: 27.36 tokens
- max: 52 tokens
- 0: ~50.30%
- 1: ~49.70%
- Samples:
sentence1 sentence2 label The newer Punts are still very much in existence today and race in the same fleets as the older boats .The newer punts are still very much in existence today and run in the same fleets as the older boats .1Turner Valley , was at the Turner Valley Bar N Ranch Airport , southwest of the Turner Valley Bar N Ranch , Alberta , Canada .Turner Valley Bar N Ranch Airport , , was located at Turner Valley Bar N Ranch , southwest of Turner Valley , Alberta , Canada .0After losing his second election , he resigned as opposition leader and was replaced by Geoff Pearsall .Max Bingham resigned as opposition leader after losing his second election , and was replaced by Geoff Pearsall .1 - Loss:
CoSENTLosswith these parameters:{ "scale": 20.0, "similarity_fct": "pairwise_cos_sim" }
Training Logs
| Epoch | Step | val_cosine_ap | test_cosine_ap |
|---|---|---|---|
| -1 | -1 | 0.7351 | 0.6474 |
Framework Versions
- Python: 3.12.3
- Sentence Transformers: 5.1.0
- Transformers: 4.55.0
- PyTorch: 2.8.0+cu128
- Accelerate: 1.10.0
- Datasets: 4.0.0
- Tokenizers: 0.21.4
Citation
BibTeX
Sentence Transformers
@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",
}
CoSENTLoss
@online{kexuefm-8847,
title={CoSENT: A more efficient sentence vector scheme than Sentence-BERT},
author={Su Jianlin},
year={2022},
month={Jan},
url={https://kexue.fm/archives/8847},
}
- Downloads last month
- 43
Model tree for adbaral/langcache-embed-v3
Base model
answerdotai/ModernBERT-base
Finetuned
Alibaba-NLP/gte-modernbert-base
Dataset used to train adbaral/langcache-embed-v3
Evaluation results
- Cosine Accuracy on valself-reported0.763
- Cosine Accuracy Threshold on valself-reported0.864
- Cosine F1 on valself-reported0.691
- Cosine F1 Threshold on valself-reported0.826
- Cosine Precision on valself-reported0.629
- Cosine Recall on valself-reported0.766
- Cosine Ap on valself-reported0.735
- Cosine Mcc on valself-reported0.477
- Cosine Accuracy on testself-reported0.704
- Cosine Accuracy Threshold on testself-reported0.852