ONNX 模型库
返回模型

说明文档

警告:此模型已过时。

🚀 查看我们的新 v3-small 模型,经过训练以提高推理速度、更轻量的模型体积,以及更出色的语义匹配缓存效果。


基于 Alibaba-NLP/gte-modernbert-base 的 Redis 语义缓存嵌入模型

这是一个基于 Alibaba-NLP/gte-modernbert-base 微调的 sentence-transformers 模型,在 Quora 数据集上进行训练。它将句子和段落映射到 768 维的密集向量空间,可用于语义文本相似度计算,以实现语义缓存。

模型详情

模型描述

  • 模型类型: 句子转换器
  • 基础模型: Alibaba-NLP/gte-modernbert-base <!-- at revision bc02f0a92d1b6dd82108036f6cb4b7b423fb7434 -->
  • 最大序列长度: 8192 个 token
  • 输出维度: 768 维
  • 相似度函数: 余弦相似度
  • 训练数据集:
    • Quora <!-- - 语言: 未知 --> <!-- - 许可证: 未知 -->

模型来源

完整模型架构

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})
)

使用方法

首先安装 Sentence Transformers 库:

pip install -U sentence-transformers

然后您可以加载此模型并进行推理。

from sentence_transformers import SentenceTransformer

# 从 🤗 Hub 下载
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)
# [3, 768]

# 获取嵌入向量的相似度分数
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)

二分类
指标
cosine_accuracy 0.90
cosine_f1 0.87
cosine_precision 0.84
cosine_recall 0.90
cosine_ap 0.92

训练数据集

Quora
  • 数据集:Quora
  • 大小:323491 个训练样本
  • 列:<code>question_1</code>、<code>question_2</code> 和 <code>label</code>

评估数据集

Quora
  • 数据集:Quora
  • 大小:53486 个评估样本
  • 列:<code>question_1</code>、<code>question_2</code> 和 <code>label</code>

引用

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",
}

<!-- -->

redis/langcache-embed-v1

作者 redis

sentence-similarity sentence-transformers
↓ 282.9K ♥ 13

创建时间: 2025-03-21 02:26:39+00:00

更新时间: 2025-12-08 11:48:53+00:00

在 Hugging Face 上查看

文件 (14)

.gitattributes
1_Pooling/config.json
README.md
config.json
config_sentence_transformers.json
model.safetensors
modules.json
onnx/model.onnx ONNX
openvino/openvino_model.bin
openvino/openvino_model.xml
sentence_bert_config.json
special_tokens_map.json
tokenizer.json
tokenizer_config.json