🚀 基於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",
}