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