🚀 基于Alibaba-NLP/gte-modernbert-base的Redis语义缓存嵌入模型
本项目是一个基于 sentence-transformers 的模型,它在 Quora 数据集上对 Alibaba-NLP/gte-modernbert-base 进行了微调。该模型可将句子和段落映射到768维的密集向量空间,用于语义文本相似度计算,以实现语义缓存。
🚀 快速开始
首先,安装 Sentence Transformers 库:
pip install -U sentence-transformers
然后,你可以加载此模型并进行推理:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("redis/langcache-embed-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)
✨ 主要特性
- 映射能力:能够将句子和段落映射到768维的密集向量空间。
- 应用场景:可用于语义文本相似度计算,实现语义缓存。
📦 安装指南
安装 Sentence Transformers 库:
pip install -U sentence-transformers
💻 使用示例
基础用法
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("redis/langcache-embed-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.90 |
余弦 F1 值 |
0.87 |
余弦精确率 |
0.84 |
余弦召回率 |
0.90 |
余弦平均精度 |
0.92 |
训练数据集
Quora
- 数据集:Quora
- 规模:323491 个训练样本
- 列:
question_1
、question_2
和 label
评估数据集
Quora
- 数据集:Quora
- 规模:53486 个评估样本
- 列:
question_1
、question_2
和 label
🔧 技术细节
该模型基于 Sentence Transformers 框架,在 Quora 数据集上对 Alibaba-NLP/gte-modernbert-base 进行微调。通过将句子和段落映射到768维的密集向量空间,利用余弦相似度计算语义文本相似度,以实现语义缓存。
📄 许可证
文档未提及相关信息。
📖 引用
BibTeX
Redis Langcache-embed 模型
@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",
}