CoolFace
Modelpublic

redis/langcache-embed-v1

sourceHugging Faceupdated 10mo agoView on Hugging Face
16likes151kdownloads
README.md169 linesDownload Raw Back to root
1---2tags:3- sentence-transformers4- sentence-similarity5- loss:OnlineContrastiveLoss6base_model: Alibaba-NLP/gte-modernbert-base7pipeline_tag: sentence-similarity8library_name: sentence-transformers9metrics:10- cosine_accuracy11- cosine_precision12- cosine_recall13- cosine_f114- cosine_ap15model-index:16- name: SentenceTransformer based on Alibaba-NLP/gte-modernbert-base17  results:18  - task:19      type: my-binary-classification20      name: My Binary Classification21    dataset:22      name: Quora23      type: unknown24    metrics:25    - type: cosine_accuracy26      value: 0.9027      name: Cosine Accuracy28    - type: cosine_f129      value: 0.8730      name: Cosine F131    - type: cosine_precision32      value: 0.8433      name: Cosine Precision34    - type: cosine_recall35      value: 0.9036      name: Cosine Recall37    - type: cosine_ap38      value: 0.9239      name: Cosine Ap40---41# WARNING: This is an outdated model.42 43# ๐Ÿš€ Check out [our new v3-small model](https://huggingface.co/redis/langcache-embed-v3-small), trained for improved inference speed, lighter footprint, and better semantic matching for caching.44---45 46 47 48 49 50## Redis semantic caching embedding model based on Alibaba-NLP/gte-modernbert-base51 52This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [Alibaba-NLP/gte-modernbert-base](https://huggingface.co/Alibaba-NLP/gte-modernbert-base) on the [Quora](https://www.kaggle.com/datasets/quora/question-pairs-dataset) dataset. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity for the purpose of semantic caching.53 54### Model Details55 56#### Model Description57- **Model Type:** Sentence Transformer58- **Base model:** [Alibaba-NLP/gte-modernbert-base](https://huggingface.co/Alibaba-NLP/gte-modernbert-base) <!-- at revision bc02f0a92d1b6dd82108036f6cb4b7b423fb7434 -->59- **Maximum Sequence Length:** 8192 tokens60- **Output Dimensionality:** 768 dimensions61- **Similarity Function:** Cosine Similarity62- **Training Dataset:**63    - [Quora](https://www.kaggle.com/datasets/quora/question-pairs-dataset)64<!-- - **Language:** Unknown -->65<!-- - **License:** Unknown -->66 67#### Model Sources68 69- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)70- **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)71- **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)72 73#### Full Model Architecture74 75```76SentenceTransformer(77  (0): Transformer({'max_seq_length': 8192, 'do_lower_case': False}) with Transformer model: ModernBertModel78  (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})79)80```81 82### Usage83 84First install the Sentence Transformers library:85 86```bash87pip install -U sentence-transformers88```89 90Then you can load this model and run inference.91```python92from sentence_transformers import SentenceTransformer93 94# Download from the ๐Ÿค— Hub95model = SentenceTransformer("redis/langcache-embed-v1")96# Run inference97sentences = [98    'Will the value of Indian rupee increase after the ban of 500 and 1000 rupee notes?',99    'What will be the implications of banning 500 and 1000 rupees currency notes on Indian economy?',100    "Are Danish Sait's prank calls fake?",101]102embeddings = model.encode(sentences)103print(embeddings.shape)104# [3, 768]105 106# Get the similarity scores for the embeddings107similarities = model.similarity(embeddings, embeddings)108print(similarities.shape)109 110```111 112##### Binary Classification113 114 115| Metric                    | Value     |116|:--------------------------|:----------|117| cosine_accuracy           |  0.90   |118| cosine_f1                 |  0.87   |119| cosine_precision          |  0.84   |120| cosine_recall             |  0.90   |121| **cosine_ap**             |  0.92   |122 123 124#### Training Dataset125 126##### Quora127 128* Dataset: [Quora](https://www.kaggle.com/datasets/quora/question-pairs-dataset)129* Size: 323491 training samples130* Columns: <code>question_1</code>, <code>question_2</code>, and <code>label</code>131 132#### Evaluation Dataset133 134##### Quora135 136* Dataset: [Quora](https://www.kaggle.com/datasets/quora/question-pairs-dataset)137* Size: 53486 evaluation samples138* Columns: <code>question_1</code>, <code>question_2</code>, and <code>label</code>139 140### Citation141 142#### BibTeX143 144##### Redis Langcache-embed Models145```bibtex146@inproceedings{langcache-embed-v1,147    title = "Advancing Semantic Caching for LLMs with Domain-Specific Embeddings and Synthetic Data",148    author = "Gill, Cechmanek, Hutcherson, Rajamohan, Agarwal, Gulzar, Singh, Dion",149    month = "04",150    year = "2025",151    url = "https://arxiv.org/abs/2504.02268",152}153```154 155##### Sentence Transformers156```bibtex157@inproceedings{reimers-2019-sentence-bert,158    title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",159    author = "Reimers, Nils and Gurevych, Iryna",160    booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",161    month = "11",162    year = "2019",163    publisher = "Association for Computational Linguistics",164    url = "https://arxiv.org/abs/1908.10084",165}166```167 168<!--169