---
title: udever-bloom-7b1
canonical_url: "https://www.modelscope.cn/models/damo/udever-bloom-7b1"
md_url: "https://www.modelscope.cn/models/damo/udever-bloom-7b1.md"
repository: damo/udever-bloom-7b1
chinese_name: "Udever 多语言通用文本表示模型 7b1"
last_updated: 2025-06-11
license: "Apache License 2.0"
pipeline_tag: sentence-embedding
tasks:
  - sentence-embedding
model_type:
  - bloom
architectures:
  - BloomModel
library_name:
  - pytorch
frameworks:
  - pytorch
domain:
  - nlp
downloads: 7057
stars: 6
tags:
  - Embedding
  - "text representation"
  - "text retrieval"
  - "passage retrieval"
  - Transformer
  - Udever
  - "文本相关性"
  - "文本相似度"
---

# udever-bloom-7b1

> udever-bloom-7b1 - damo 在 ModelScope 开源的模型。Udever 模型是基于 BLOOM 系列模型在 MS MARCO passage + SNLI + MNLI 三个数据上 bitfit 微调得到的文本表示模型，可用于文本检索、代码检索、文本相似性等多种任务，在英文、中文等多种自然语言和Python、Java等多种编程语言都有很好的表现。

damo/udever-bloom-7b1 是 ModelScope 魔搭社区上的sentence-embedding模型，采用 Apache License 2.0 许可。

- **Repository**: damo/udever-bloom-7b1
- **License**: Apache License 2.0
- **Tasks**: sentence-embedding
- **Tags**: Embedding, text representation, text retrieval, passage retrieval, Transformer, Udever, 文本相关性, 文本相似度
- **Downloads**: 7057
- **Stars**: 6
- **Last updated**: 2025-06-11

Source: https://www.modelscope.cn/models/damo/udever-bloom-7b1

---

# Udever 多语言通用文本表示模型

文本表示是将一个输入句子使用机器学习模型转换为一个固定维度的连续向量:

- 输入: 吃完海鲜可以喝牛奶吗?
- 输出: [0.27162,-0.66159,0.33031,0.24121,0.46122,...]

文本的向量表示通常可以用于文本聚类、文本相似度计算、文本向量召回等下游任务中。


Udever 模型是基于 BLOOM 系列模型在 MS MARCO passage + SNLI + MNLI 三个数据上 bitfit 微调得到的文本表示模型，可用于文本检索、代码检索、文本相似性等多种任务。

仅使用英文文本数据进行对比学习微调的 Udever 在英文、中文等多种自然语言和Python、Java等多种编程语言都有很好的表现，可视化的例子见图 1。

<div align=center><img width="451" height="346" src="vis.png" /></div>

上图1中是英文、中文、python代码的embedding可视化，其中蓝色正方形代表英文文本注释，绿色三角形代表python代码，红色圆形代表翻译的中文注释文本，粉色和黄色的图标三元组代表两组语义一致的三元组，即[英文注释，对应的python代码，翻译的中文注释]。

 - 左图是原始bloom模型使用SGPT方式产生的向量（embedding），不同语言的向量分布在不同的区域；黄色和粉色的三元组是分散的。
 - 右图是Udever-bloom-560m模型的向量，不同语言的向量按照语义均匀分布；黄色的三元组按照语义分布在了一起，粉色也是。

Udever具体性能见表1、2、3，更多细节参见论文 [Language Models are Universal Embedders](https://arxiv.org/pdf/2310.08232.pdf)。


## 1 使用方式和范围

使用方式:
- 直接推理, 对给定文本计算其对应的文本向量表示，向量维度 4096

使用范围:
- 本模型可以使用在通用领域的文本向量表示及其下游应用场景, 包括双句文本相似度计算、query&多doc候选的相似度排序

### 如何使用

在ModelScope框架上，提供输入文本(默认最长文本长度为300)，即可以通过简单的Pipeline调用来使用模型。ModelScope封装了统一的接口对外提供单句向量表示、双句文本相似度、多候选相似度计算功能

### 代码示例

```python
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

model_id = "damo/udever-bloom-7b1"
pipeline_se = pipeline(Tasks.sentence_embedding, model=model_id, model_revision='master')

# 当输入包含“soure_sentence”与“sentences_to_compare”时，会输出source_sentence中首个句子与sentences_to_compare中每个句子的向量表示，以及source_sentence中首个句子与sentences_to_compare中每个句子的相似度。
inputs = {
    "source_sentence": ["吃完海鲜可以喝牛奶吗?"],
    "sentences_to_compare": [
        "不可以，早晨喝牛奶不科学",
        "吃了海鲜后是不能再喝牛奶的，因为牛奶中含得有维生素C，如果海鲜喝牛奶一起服用会对人体造成一定的伤害",
        "吃海鲜是不能同时喝牛奶吃水果，这个至少间隔6小时以上才可以。",
        "吃海鲜是不可以吃柠檬的因为其中的维生素C会和海鲜中的矿物质形成砷"
    ]
}

result = pipeline_se(input=inputs)
print(result)

## scores由两个向量之间的内积(dot)距离得到


# 当输入仅含有soure_sentence时，会输出source_sentence中每个句子的向量表示以及首个句子与其他句子的相似度。
inputs2 = {
    "source_sentence": [
        "不可以，早晨喝牛奶不科学",
        "吃了海鲜后是不能再喝牛奶的，因为牛奶中含得有维生素C，如果海鲜喝牛奶一起服用会对人体造成一定的伤害",
        "吃海鲜是不能同时喝牛奶吃水果，这个至少间隔6小时以上才可以。",
        "吃海鲜是不可以吃柠檬的因为其中的维生素C会和海鲜中的矿物质形成砷"
    ]
}
result = pipeline_se(input=inputs2)
print(result)
```


### 模型局限性以及可能的偏差

本模型基于 MS MARCO passage + SNLI + MNLI 三个数据集(通用领域)上训练，在垂直领域文本上的效果为无监督水平，请用户自行评测后决定如何使用


## 2 模型效果评估

表1: 英文多任务向量评测榜单 [MTEB](https://arxiv.org/abs/2210.07316) 结果

| MTEB | Avg.  |  Class.  | Clust.  | PairClass.  | Rerank.  | Retr.  | STS  | Summ.  |
|-----------------------------|--------------|--------------|--------------|--------------|--------------|--------------|--------------|--------|
| #Datasets ($\rightarrow$)  | 56  | 12  | 11  | 3  | 4  | 15  | 10  | 1  |
||
| bge-large-en-v1.5 |  **64.23** |  **75.97** |  46.08|  **87.12** |  **60.03** |  **54.29** |  83.11|  31.61 |
| bge-base-en-v1.5 |  63.55|  75.53|  45.77|  86.55|  58.86|  53.25|  82.4|  31.07 |
| gte-large |  63.13|  73.33|  **46.84** |  85|  59.13|  52.22|  **83.35** |  31.66 |
| gte-base |  62.39|  73.01|  46.2|  84.57|  58.61|  51.14|  82.3|  31.17 |
| e5-large-v2      |  62.25|  75.24|  44.49|  86.03|  56.61|  50.56|  82.05|  30.19 |
| instructor-xl    |  61.79|  73.12|  44.74|  86.62|  57.29|  49.26|  83.06|  32.32 |
| instructor-large |  61.59|  73.86|  45.29|  85.89|  57.54|  47.57|  83.15|  31.84 |
| e5-base-v2       |  61.5 |  73.84|  43.8|  85.73|  55.91|  50.29|  81.05|  30.28 |
| e5-large         |  61.42|  73.14|  43.33|  85.94|  56.53|  49.99|  82.06|  30.97 |
| text-embedding-ada-002 (OpenAI API)         |  60.99|  70.93|  45.9 |  84.89|  56.32|  49.25|  80.97|  30.8  |
| e5-base          |  60.44|  72.63|  42.11|  85.09|  55.7 |  48.75|  80.96|  31.01 |
| SGPT-5.8B-msmarco  |  58.93|  68.13|  40.34|  82   |  56.56|  50.25|  78.1 |  31.46 |
| sgpt-bloom-7b1-msmarco |  57.59|  66.19|  38.93|  81.9 |  55.65|  48.22|  77.74|  **33.6**  |
||
| Udever-bloom-560m |   55.80|    68.04|  36.89|  81.05|  52.60|  41.19|  79.93|  32.06 |
| Udever-bloom-1b1 |   58.28|   70.18|  39.11|  83.11|  54.28|  45.27|  81.52|  31.10 |
| Udever-bloom-3b  |   59.86|     71.91|  40.74|  84.06|  54.90|  47.67|  82.37|  30.62 |
| Udever-bloom-7b1  |  60.63 |    72.13|  40.81|  85.40|  55.91|  49.34|  83.01|  30.97   |


表2: [CodeSearchNet](https://arxiv.org/abs/1909.09436) 文本搜索代码评测

| CodeSearchNet | Go  | Ruby  | Python  | Java  | JS  | PHP  | Avg. |
|-|-|-|-|-|-|-|-|
| CodeBERT  | 69.3  | 70.6  | 84.0  | 86.8  | 74.8  | 70.6  | 76.0 |
| GraphCodeBERT  | 84.1  | 73.2  | 87.9  | 75.7  | 71.1  | 72.5  | 77.4 |
| cpt-code S  | **97.7**  | **86.3**  | 99.8  | 94.0  | 86.0  | 96.7  | 93.4 |
| cpt-code M  | 97.5  | 85.5  | **99.9**  | **94.4**  | **86.5**  | **97.2**  | **93.5** |
| sgpt-bloom-7b1-msmarco  | 76.79  | 69.25  | 95.68  | 77.93  | 70.35  | 73.45  | 77.24 |
||
| Udever-bloom-560m   | 75.38  | 66.67  | 96.23  | 78.99  | 69.39  | 73.69  | 76.73 |
| Udever-bloom-1b1   | 78.76  | 72.85  | 97.67  | 82.77  | 74.38  | 78.97  | 80.90 |
| Udever-bloom-3b   | 80.63  | 75.40  | 98.02  | 83.88  | 76.18  | 79.67  | 82.29 |
| Udever-bloom-7b1   | 79.37  | 76.59  | 98.38  | 84.68  | 77.49  | 80.03  | 82.76 |


表3: [Multi-cpr](https://dl.acm.org/doi/10.1145/3477495.3531736) 中文特殊领域检索评测结果
| | | |E-commerce | | Entertainment video | | Medical |   |
|--|--|--|--|--|--|--|--|--|
| Model | Train | Backbone | MRR@10 | Recall@1k | MRR@10 | Recall@1k | MRR@10 | Recall@1k |
||
| BM25 | - | - | 0.225 | 0.815 | 0.225 | 0.780 | 0.187 | 0.482 |
| Doc2Query | - | - | 0.239 | 0.826 | 0.238 | 0.794 | 0.210 | 0.505 |
| DPR-1 | In-Domain | BERT | 0.270 | 0.921 | 0.254 | 0.934 | 0.327 | 0.747 |
| DPR-2 | In-Domain | BERT-CT | 0.289 | **0.926** | 0.263 | **0.935** | 0.339  | **0.769** |
| text-embedding-ada-002 | General | GPT | 0.183 | 0.825 | 0.159 | 0.786 | 0.245 | 0.593 |
| sgpt-bloom-7b1-msmarco | General | BLOOM | 0.242 | 0.840 | 0.227 | 0.829 | 0.311 | 0.675 |
||
 | Udever-bloom-560m | General | BLOOM | 0.156 | 0.802 | 0.149 | 0.749 | 0.245  | 0.571 |
 | Udever-bloom-1b1 | General | BLOOM | 0.244 | 0.863 | 0.208 | 0.815 | 0.241  | 0.557 |
 | Udever-bloom-3b | General | BLOOM | 0.267 | 0.871 | 0.228 | 0.836 | 0.288  | 0.619 |
 | Udever-bloom-7b1 | General | BLOOM | **0.296** | 0.889 | **0.267** | 0.907 | **0.343**  | 0.705 |


## 3 引用

```BibTeX
@article{zhang2023language,
  title={Language Models are Universal Embedders},
  author={Zhang, Xin and Li, Zehan and Zhang, Yanzhao and Long, Dingkun and Xie, Pengjun and Zhang, Meishan and Zhang, Min},
  journal={arXiv preprint arXiv:2310.08232},
  year={2023}
}
```
