🚀 基于Alibaba-NLP/gte-modernbert-base的Redis语义缓存嵌入模型
本模型是基于 sentence-transformers 框架,从 Alibaba-NLP/gte-modernbert-base 微调而来,在 Medical 数据集上进行训练。它能将句子和段落映射到768维的密集向量空间,可用于医疗领域语义缓存的语义文本相似度任务。
🚀 快速开始
安装依赖
首先,你需要安装 sentence-transformers
库:
pip install -U sentence-transformers
加载模型并推理
安装完成后,你可以加载本模型并进行推理:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("redis/langcache-embed-medical-v1")
sentences = [
'Will the value of Indian rupee increase after the ban of 500 and 1000 rupee notes?',
'What will be the implications of banning 500 and 1000 rupees currency notes on Indian economy?',
"Are Danish Sait's prank calls fake?",
]
embeddings = model.encode(sentences)
print(embeddings.shape)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
✨ 主要特性
- 高精度:在医疗领域的二分类任务中,余弦准确率达到0.92,余弦F1值达到0.93,表现出色。
- 长序列处理能力:最大序列长度可达8192个标记,能处理较长的句子和段落。
- 语义缓存适用:可将句子和段落映射到768维的密集向量空间,适用于医疗领域的语义缓存任务。
📦 安装指南
安装 sentence-transformers
库:
pip install -U sentence-transformers
💻 使用示例
基础用法
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("redis/langcache-embed-medical-v1")
sentences = [
'Will the value of Indian rupee increase after the ban of 500 and 1000 rupee notes?',
'What will be the implications of banning 500 and 1000 rupees currency notes on Indian economy?',
"Are Danish Sait's prank calls fake?",
]
embeddings = model.encode(sentences)
print(embeddings.shape)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
📚 详细文档
模型详情
模型描述
模型来源
完整模型架构
SentenceTransformer(
(0): Transformer({'max_seq_length': 8192, 'do_lower_case': False}) with Transformer model: 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})
)
二分类指标
指标 |
值 |
余弦准确率 |
0.92 |
余弦F1值 |
0.93 |
余弦精确率 |
0.92 |
余弦召回率 |
0.93 |
余弦平均精度 |
0.97 |
训练数据集
Medical
评估数据集
Medical
📄 许可证
文档中未提及相关许可证信息。
📚 引用
BibTeX
Redis Langcache-embed Models
@inproceedings{langcache-embed-v1,
title = "Advancing Semantic Caching for LLMs with Domain-Specific Embeddings and Synthetic Data",
author = "Gill, Cechmanek, Hutcherson, Rajamohan, Agarwal, Gulzar, Singh, Dion",
month = "04",
year = "2025",
url = "https://arxiv.org/abs/2504.02268",
}
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",
}