---
title: gte_passage-ranking_multilingual-base
canonical_url: "https://www.modelscope.cn/models/iic/gte_passage-ranking_multilingual-base"
md_url: "https://www.modelscope.cn/models/iic/gte_passage-ranking_multilingual-base.md"
repository: iic/gte_passage-ranking_multilingual-base
chinese_name: "GTE文本排序-多语言-base"
last_updated: 2024-08-14
license: "Apache License 2.0"
pipeline_tag: text-ranking
tasks:
  - text-ranking
model_type:
  - bert
architectures:
  - NewForSequenceClassification
parameters: 306.0M
tensor_type:
  - F16
library_name:
  - pytorch
  - safetensors
frameworks:
  - pytorch
language:
  - zh
domain:
  - nlp
downloads: 40580
stars: 18
tags:
  - "Multilingual Text Ranking"
  - Transformer
  - "text ranking"
  - BERT
  - GTE
  - "语义相关性"
  - "句子相似度"
  - "信息检索"
  - "检索"
  - "匹配"
  - "相似度"
  - "排序"
  - Rank
  - Retrieval
  - Rerank
  - Multilingual
  - "语义匹配"
  - "搜索"
  - "文本匹配"
---

# gte_passage-ranking_multilingual-base

> gte_passage-ranking_multilingual-base - iic 在 ModelScope 开源的模型。GTE文本排序-多语言-base

iic/gte_passage-ranking_multilingual-base 是 ModelScope 魔搭社区上的 306.0M 参数text-ranking模型，采用 Apache License 2.0 许可。

- **Repository**: iic/gte_passage-ranking_multilingual-base
- **License**: Apache License 2.0
- **Tasks**: text-ranking
- **Parameters**: 306.0M
- **Tags**: Multilingual Text Ranking, Transformer, text ranking, BERT, GTE, 语义相关性, 句子相似度, 信息检索, 检索, 匹配, 相似度, 排序, Rank, Retrieval, Rerank, Multilingual, 语义匹配, 搜索, 文本匹配
- **Downloads**: 40580
- **Stars**: 18
- **Last updated**: 2024-08-14

Source: https://www.modelscope.cn/models/iic/gte_passage-ranking_multilingual-base

---

# GTE文本排序-多语言-base

文本检索是信息检索领域的核心问题, 其在很多信息检索、NLP下游任务中发挥着非常重要的作用。 近几年, BERT等大规模预训练语言模型的出现使得文本表示效果有了大幅度的提升, 基于预训练语言模型构建的文本检索系统在召回、排序效果上都明显优于传统统计模型。

由于文档候选集合通常比较庞大，实际的工业搜索系统中候选文档数量往往在千万甚至更高的数量级, 为了兼顾效率和准确率，目前的文本检索系统通常是基于召回&排序的多阶段搜索框架。在召回阶段，系统的主要目标是从海量文本中去找到潜在跟query相关的文档，得到较小的候选文档集合（100-1000个）。召回完成后, 排序阶段的模型会对这些召回的候选文档进行更加复杂的排序, 产出最后的排序结果。 本模型为基于预训练的排序阶段模型。


## GTE多语言通用文本排序模型

GTE多语言文本排序模型是GTE(通用文本向量，General Text Embedding)系列模型中的最新的多语言文本排序模型，该模型具有几个关键特性：

- **高性能**: 在多语言检索任务评估中，相比同规模模型，达到了最先进的（SOTA）结果。
- **高推理效率**：采用Encoder-Only架构进行训练，使模型体积更小(300M), 在保持效果的同时提供高效的推理性能，同时降低使用硬件的门槛
- **长上下文**：支持最多8192个token的文本长度
- **多语言能力**：支持70多种语言

## 模型使用
```
import torch
from modelscope import AutoModelForSequenceClassification, AutoTokenizer

model_name_or_path = "iic/gte_passage-ranking_multilingual-base"

tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
model = AutoModelForSequenceClassification.from_pretrained(model_name_or_path, trust_remote_code=True)
model.eval()

with torch.no_grad():
    pairs = [["中国的首都在哪儿", "北京"], ["what is the capital of China?", "北京"], ["how to implement quick sort in python?","Introduction of quick sort"]]
    inputs = tokenizer(pairs, padding=True, truncation=True, return_tensors='pt', max_length=8192)
    scores = model(**inputs, return_dict=True).logits.view(-1, ).float()
    print(scores)
# tensor([1.2315, 0.5923, 0.3041])
```
## 模型效果
Results of reranking based on multiple text retreival datasets

![image](./images/mgte-reranker.png)

更多实验评估和结果可以参考论文[paper](https://arxiv.org/pdf/2407.19669).

## API云服务

除了开源的GTE系列模型，GTE系列模型同时在阿里云上提供商用API服务:

- [文本Embedding模型](https://help.aliyun.com/zh/model-studio/developer-reference/general-text-embedding/): 提供三种版本的文本嵌入模型：text-embedding-v1/v2/v3，其中v3是最新版本的模型服务
- [文本ReRank模型](https://help.aliyun.com/zh/model-studio/developer-reference/general-text-sorting-model/): 提供gte-rerank模型服务, 模型持续迭代中

Note: API服务背后的模型与开源模型并不完全相同


## 引用
如果你觉得这个该模型对有所帮助，请考虑引用下面的相关的论文：

```BibTeX
@misc{zhang2024mgtegeneralizedlongcontexttext,
      title={mGTE: Generalized Long-Context Text Representation and Reranking Models for Multilingual Text Retrieval}, 
      author={Xin Zhang and Yanzhao Zhang and Dingkun Long and Wen Xie and Ziqi Dai and Jialong Tang and Huan Lin and Baosong Yang and Pengjun Xie and Fei Huang and Meishan Zhang and Wenjie Li and Min Zhang},
      year={2024},
      eprint={2407.19669},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2407.19669}, 
}
```
