maidalun1020 commited on
Commit
5bdcde5
1 Parent(s): e085f02

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +446 -3
README.md CHANGED
@@ -1,3 +1,446 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ * @Description:
3
+ * @Author: shenlei
4
+ * @Modified: linhui
5
+ * @Date: 2023-12-19 10:31:41
6
+ * @LastEditTime: 2024-01-02 17:46:57
7
+ * @LastEditors: shenlei
8
+ -->
9
+ <h1 align="center">BCEmbedding: Bilingual and Crosslingual Embedding for RAG</h1>
10
+
11
+ <div align="center">
12
+ <a href="https://github.com/netease-youdao/BCEmbedding/LICENSE">
13
+ <img src="https://img.shields.io/badge/license-Apache--2.0-yellow">
14
+ </a>
15
+ &nbsp;
16
+ <a href="https://twitter.com/YDopensource">
17
+ <img src="https://img.shields.io/badge/follow-%40YDOpenSource-1DA1F2?logo=twitter&style={style}">
18
+ </a>
19
+ &nbsp;
20
+ </div>
21
+ <br>
22
+
23
+ <p align="center">
24
+ <a href="https://github.com/netease-youdao/BCEmbedding">GitHub</a>
25
+ </p>
26
+
27
+ <details open="open">
28
+ <summary>Click to Open Contents</summary>
29
+
30
+ - <a href="#t1">🌐 Bilingual and Crosslingual Superiority</a>
31
+ - <a href="#t2">💡 Key Features</a>
32
+ - <a href="#t3">🚀 Latest Updates</a>
33
+ - <a href="#t4">🍎 Model List</a>
34
+ - <a href="#t5">📖 Manual</a>
35
+ - <a href="#installation">Installation</a>
36
+ - <a href="#quick-start">Quick Start</a>
37
+ - <a href="#t6">⚙️ Evaluation</a>
38
+ - <a href="#evaluate-semantic-representation-by-mteb">Evaluate Semantic Representation by MTEB</a>
39
+ - <a href="#evaluate-rag-by-llamaindex">Evaluate RAG by LlamaIndex</a>
40
+ - <a href="#t7">📈 Leaderboard</a>
41
+ - <a href="#semantic-representation-evaluations-in-mteb">Semantic Representation Evaluations in MTEB</a>
42
+ - <a href="#rag-evaluations-in-llamaindex">RAG Evaluations in LlamaIndex</a>
43
+ - <a href="#t8">🛠 Youdao's BCEmbedding API</a>
44
+ - <a href="#t9">🧲 WeChat Group</a>
45
+ - <a href="#t10">✏️ Citation</a>
46
+ - <a href="#t11">🔐 License</a>
47
+ - <a href="#t12">🔗 Related Links</a>
48
+
49
+ </details>
50
+ <br>
51
+
52
+ **B**ilingual and **C**rosslingual **Embedding** (`BCEmbedding`), developed by NetEase Youdao, encompasses `EmbeddingModel` and `RerankerModel`. The `EmbeddingModel` specializes in generating semantic vectors, playing a crucial role in semantic search and question-answering, and the `RerankerModel` excels at refining search results and ranking tasks.
53
+
54
+ `BCEmbedding` serves as the cornerstone of Youdao's Retrieval Augmented Generation (RAG) implmentation, notably [QAnything](http://qanything.ai) [[github](https://github.com/netease-youdao/qanything)], an open-source implementation widely integrated in various Youdao products like [Youdao Speed Reading](https://read.youdao.com/#/home) and [Youdao Translation](https://fanyi.youdao.com/download-Mac?keyfrom=fanyiweb_navigation).
55
+
56
+ Distinguished for its bilingual and crosslingual proficiency, `BCEmbedding` excels in bridging Chinese and English linguistic gaps, which achieves
57
+ - **A high performence on <a href=#semantic-representation-evaluations-in-mteb>Semantic Representation Evaluations in MTEB</a>**;
58
+ - **A new benchmark in the realm of <a href=#rag-evaluations-in-llamaindex>RAG Evaluations in LlamaIndex</a>**.
59
+
60
+ `BCEmbedding`是由网易有道开发的双语和跨语种语义表征算法模型库,其中包含`EmbeddingModel`和`RerankerModel`两类基础模型。`EmbeddingModel`专门用于生成语义向量,在语义搜索和问答中起着关键作用,而`RerankerModel`擅长优化语义搜索结果和语义相关顺序精排。
61
+
62
+ `BCEmbedding`作为有道的检索增强生成式应用(RAG)的基石,特别是在[QAnything](http://qanything.ai) [[github](https://github.com/netease-youdao/qanything)]中发挥着重要作用。QAnything作为一个网易有道开源项目,在有道许多产品中有很好的应用实践,比如[有道速读](https://read.youdao.com/#/home)和[有道翻译](https://fanyi.youdao.com/download-Mac?keyfrom=fanyiweb_navigation)
63
+
64
+ `BCEmbedding`以其出色的双语和跨语种能力而著称,在语义检索中消除中英语言之间的差异,从而实现:
65
+ - **强大的双语和跨语种语义表征能力【<a href=#t7-1>基于MTEB的语义表征评测指标</a>】。**
66
+ - **基于LlamaIndex的RAG评测,表现SOTA【<a href=#t7-2>基于LlamaIndex的RAG评测指标</a>】。**
67
+
68
+ <t id="t1"></t>
69
+ ## 🌐 Bilingual and Crosslingual Superiority
70
+
71
+ Existing embedding models often encounter performance challenges in bilingual and crosslingual scenarios, particularly in Chinese, English and their crosslingual tasks. `BCEmbedding`, leveraging the strength of Youdao's translation engine, excels in delivering superior performance across monolingual, bilingual, and crosslingual settings.
72
+
73
+ `EmbeddingModel` supports ***Chinese (ch) and English (en)*** (more languages support will come soon), while `RerankerModel` supports ***Chinese (ch), English (en), Japanese (ja) and Korean (ko)***.
74
+
75
+ 现有的单个语义表征模型在双语和跨语种场景中常常表现不佳,特别是在中文、英文及其跨语种任务中。`BCEmbedding`充分利用有道翻译引擎的优势,实现只需一个模型就可以在单语、双语和跨语种场景中表现出卓越的性能。
76
+
77
+ `EmbeddingModel`支持***中文和英文***���之后会支持更多语种);`RerankerModel`支持***中文,英文,日文和韩文***。
78
+
79
+ <t id="t2"></t>
80
+ ## 💡 Key Features
81
+
82
+ - **Bilingual and Crosslingual Proficiency**: Powered by Youdao's translation engine, excelling in Chinese, English and their crosslingual retrieval task, with upcoming support for additional languages.
83
+
84
+ - **RAG-Optimized**: Tailored for diverse RAG tasks including **translation, summarization, and question answering**, ensuring accurate **query understanding**. See <a href=#rag-evaluations-in-llamaindex>RAG Evaluations in LlamaIndex</a>.
85
+
86
+ - **Efficient and Precise Retrieval**: Dual-encoder for efficient retrieval of `EmbeddingModel` in first stage, and cross-encoder of `RerankerModel` for enhanced precision and deeper semantic analysis in second stage.
87
+
88
+ - **Broad Domain Adaptability**: Trained on diverse datasets for superior performance across various fields.
89
+
90
+ - **User-Friendly Design**: Instruction-free, versatile use for multiple tasks without specifying query instruction for each task.
91
+
92
+ - **Meaningful Reranking Scores**: `RerankerModel` provides relevant scores to improve result quality and optimize large language model performance.
93
+
94
+ - **Proven in Production**: Successfully implemented and validated in Youdao's products.
95
+
96
+ - **双语和跨语种能力**:基于有道翻译引擎的强大能力,我们的`BCEmbedding`具备强大的中英双语和跨语种语义表征能力。
97
+
98
+ - **RAG适配**:面向RAG做了针对性优化,可以适配大多数相关任务,比如**翻译,摘要,问答**等。此外,针对**问题理解**(query understanding)也做了针对优化,详见 <a href=#t7-2>基于LlamaIndex的RAG评测指标</a>。
99
+
100
+ - **高效且精确的语义检索**:`EmbeddingModel`采用双编码器,可以在第一阶段实现高效的语义检索。`RerankerModel`采用交叉编码器,可以在第二阶段实现更高精度的语义顺序精排。
101
+
102
+ - **更好的领域泛化性**:为了在更多场景实现更好的效果,我们收集了多种多样的领域数据。
103
+
104
+ - **用户友好**:语义检索时不需要特殊指令前缀。也就是,你不需要为各种任务绞尽脑汁设计指令前缀。
105
+
106
+ - **有意义的重排序分数**:`RerankerModel`可以提供有意义的语义相关性分数(不仅仅是排序),可以用于过滤无意义文本片段,提高大模型生成效果。
107
+
108
+ - **产品化检验**:`BCEmbedding`已经被有道众多真实产品检验。
109
+
110
+ <t id="t3"></t>
111
+ ## 🚀 Latest Updates
112
+
113
+ - ***2024-01-03***: **Model Releases** - [bce-embedding-base_v1](https://huggingface.co/maidalun1020/bce-embedding-base_v1) and [bce-reranker-base_v1](https://huggingface.co/maidalun1020/bce-reranker-base_v1) are available.
114
+ - ***2024-01-03***: **Eval Datasets** [[CrosslingualMultiDomainsDataset](https://huggingface.co/datasets/maidalun1020/CrosslingualMultiDomainsDataset)] - Evaluate the performence of RAG, using [LlamaIndex](https://github.com/run-llama/llama_index).
115
+ - ***2024-01-03***: **Eval Datasets** [[Details](https://github.com/netease-youdao/BCEmbedding/BCEmbedding/evaluation/c_mteb/Retrieval.py)] - Evaluate the performence of crosslingual semantic representation, using [MTEB](https://github.com/embeddings-benchmark/mteb).
116
+
117
+ - ***2024-01-03***: **模型发布** - [bce-embedding-base_v1](https://huggingface.co/maidalun1020/bce-embedding-base_v1)和[bce-reranker-base_v1](https://huggingface.co/maidalun1020/bce-reranker-base_v1)已发布.
118
+ - ***2024-01-03***: **RAG评测数据** [[CrosslingualMultiDomainsDataset](https://huggingface.co/datasets/maidalun1020/CrosslingualMultiDomainsDataset)] - 基于[LlamaIndex](https://github.com/run-llama/llama_index)的RAG评测数据已发布。
119
+ - ***2024-01-03***: **跨语种语义表征评测数据** [[详情](https://github.com/netease-youdao/BCEmbedding/BCEmbedding/evaluation/c_mteb/Retrieval.py)] - 基于[MTEB](https://github.com/embeddings-benchmark/mteb)的跨语种评测数据已发布.
120
+
121
+ <t id="t4"></t>
122
+ ## 🍎 Model List
123
+
124
+ | Model Name | Model Type | Languages | Parameters | Weights |
125
+ |:-------------------------------|:--------:|:--------:|:--------:|:--------:|
126
+ | bce-embedding-base_v1 | `EmbeddingModel` | ch, en | 279M | [download](https://huggingface.co/maidalun1020/bce-embedding-base_v1) |
127
+ | bce-reranker-base_v1 | `RerankerModel` | ch, en, ja, ko | 279M | [download](https://huggingface.co/maidalun1020/bce-reranker-base_v1) |
128
+
129
+ <t id="t5"></t>
130
+ ## 📖 Manual
131
+
132
+ ### Installation
133
+
134
+ First, create a conda environment and activate it.
135
+ ```bash
136
+ conda create --name bce python=3.10 -y
137
+ conda activate bce
138
+ ```
139
+
140
+ Then install `BCEmbedding`:
141
+ ```bash
142
+ pip install git+https://github.com/netease-youdao/BCEmbedding.git
143
+ ```
144
+
145
+ Or install from source:
146
+ ```bash
147
+ git clone git@github.com:netease-youdao/BCEmbedding.git
148
+ cd BCEmbedding
149
+ pip install -v -e .
150
+ ```
151
+
152
+ ### Quick Start
153
+
154
+ Use `EmbeddingModel` by `BCEmbedding`, and `cls` [pooler](https://github.com/netease-youdao/BCEmbedding/BCEmbedding/models/embedding.py#L24) is default.
155
+
156
+ ```python
157
+ from BCEmbedding import EmbeddingModel
158
+
159
+ # list of sentences
160
+ sentences = ['sentence_0', 'sentence_1', ...]
161
+
162
+ # init embedding model
163
+ model = EmbeddingModel(model_name_or_path="maidalun1020/bce-embedding-base_v1")
164
+
165
+ # extract embeddings
166
+ embeddings = model.encode(sentences)
167
+ ```
168
+
169
+ Use `RerankerModel` by `BCEmbedding` to calculate relevant scores and rerank:
170
+
171
+ ```python
172
+ from BCEmbedding import RerankerModel
173
+
174
+ # your query and corresponding passages
175
+ query = 'input_query'
176
+ passages = ['passage_0', 'passage_1', ...]
177
+
178
+ # construct sentence pairs
179
+ sentence_pairs = [[query, passage] for passage in passages]
180
+
181
+ # init reranker model
182
+ model = RerankerModel(model_name_or_path="maidalun1020/bce-reranker-base_v1")
183
+
184
+ # method 0: calculate scores of sentence pairs
185
+ scores = model.compute_score(sentence_pairs)
186
+
187
+ # method 1: rerank passages
188
+ rerank_results = model.rerank(query, passages)
189
+ ```
190
+
191
+ <t id="t6"></t>
192
+ ## ⚙️ Evaluation
193
+
194
+ ### Evaluate Semantic Representation by MTEB
195
+
196
+ We provide evaluateion tools for `embedding` and `reranker` models, based on [MTEB](https://github.com/embeddings-benchmark/mteb) and [C_MTEB](https://github.com/FlagOpen/FlagEmbedding/tree/master/C_MTEB).
197
+
198
+ 我们基于[MTEB](https://github.com/embeddings-benchmark/mteb)和[C_MTEB](https://github.com/FlagOpen/FlagEmbedding/tree/master/C_MTEB),提供`embedding`和`reranker`模型的语义表征评测工具。
199
+
200
+ #### 1. Embedding Models
201
+
202
+ Just run following cmd to evaluate `your_embedding_model` (e.g. `maidalun1020/bce-embedding-base_v1`) in **monolingual, bilingual and crosslingual settings** (e.g. `["en", "zh", "en-zh", "zh-en"]`).
203
+
204
+ 运行下面命令评测`your_embedding_model`(比如,`maidalun1020/bce-embedding-base_v1`)。评测任务将会在**单语种,双语种和跨语种**(比如,`["en", "zh", "en-zh", "zh-en"]`)模式下评测:
205
+
206
+ ```bash
207
+ python BCEmbedding/tools/eval_mteb/eval_embedding_mteb.py --model_name_or_path maidalun1020/bce-embedding-base_v1 --pooler cls
208
+ ```
209
+
210
+ The total evaluation tasks contain ***114 datastes*** of **"Retrieval", "STS", "PairClassification", "Classification", "Reranking" and "Clustering"**.
211
+
212
+ 评测包含 **"Retrieval", "STS", "PairClassification", "Classification", "Reranking"和"Clustering"** 这六大类任务的 ***114个数据集***。
213
+
214
+ ***NOTE:***
215
+ - All models are evaluated in their **recommended pooling method (`pooler`)**. "jina-embeddings-v2-base-en", "m3e-base" and "m3e-large" use `mean` pooler, while the others use `cls`.
216
+ - "jina-embeddings-v2-base-en" model should be loaded with `trust_remote_code`.
217
+ ```bash
218
+ python BCEmbedding/tools/eval_mteb/eval_embedding_mteb.py --model_name_or_path {moka-ai/m3e-base | moka-ai/m3e-large} --pooler mean
219
+
220
+ python BCEmbedding/tools/eval_mteb/eval_embedding_mteb.py --model_name_or_path jinaai/jina-embeddings-v2-base-en --pooler mean --trust_remote_code
221
+ ```
222
+
223
+ ***注意:***
224
+ - 所有模型的评测采用各自推荐的`pooler`。"jina-embeddings-v2-base-en", "m3e-base"和"m3e-large"的 `pooler`采用`mean`,其他模型的`pooler`采用`cls`.
225
+ - "jina-embeddings-v2-base-en"模型在载入时需要`trust_remote_code`。
226
+
227
+ #### 2. Reranker Models
228
+
229
+ Run following cmd to evaluate `your_reranker_model` (e.g. "maidalun1020/bce-reranker-base_v1") in **monolingual, bilingual and crosslingual settings** (e.g. `["en", "zh", "en-zh", "zh-en"]`).
230
+
231
+ 运行下面命令评测`your_reranker_model`(比如,`maidalun1020/bce-reranker-base_v1`)。评测任务将会在**单语种,双语种和跨语种**(比如,`["en", "zh", "en-zh", "zh-en"]`)模式下评测:
232
+
233
+ ```bash
234
+ python BCEmbedding/tools/eval_mteb/eval_reranker_mteb.py --model_name_or_path maidalun1020/bce-reranker-base_v1
235
+ ```
236
+
237
+ The evaluation tasks contain ***12 datastes*** of **"Reranking"**.
238
+
239
+ 评测包含 **"Reranking"** 任务的 ***12个数据集***。
240
+
241
+ #### 3. Metrics Visualization Tool
242
+
243
+ We proveide a one-click script to sumarize evaluation results of `embedding` and `reranker` models as [Embedding Models Evaluation Summary](https://github.com/netease-youdao/BCEmbedding/Docs/EvaluationSummary/embedding_eval_summary.md) and [Reranker Models Evaluation Summary](https://github.com/netease-youdao/BCEmbedding/Docs/EvaluationSummary/reranker_eval_summary.md).
244
+
245
+ 我们提供了`embedding`和`reranker`模型的指标可视化一键脚本,输出一个markdown文件,详见[Embedding模型指标汇总](https://github.com/netease-youdao/BCEmbedding/Docs/EvaluationSummary/embedding_eval_summary.md)和[Reranker模型指标汇总](https://github.com/netease-youdao/BCEmbedding/Docs/EvaluationSummary/reranker_eval_summary.md)。
246
+
247
+ ```bash
248
+ python BCEmbedding/evaluation/mteb/summarize_eval_results.py --results_dir {your_embedding_results_dir | your_reranker_results_dir}
249
+ ```
250
+
251
+ ### Evaluate RAG by LlamaIndex
252
+
253
+ [LlamaIndex](https://github.com/run-llama/llama_index) is a famous data framework for LLM-based applications, particularly in RAG. Recently, the [LlamaIndex Blog](https://blog.llamaindex.ai/boosting-rag-picking-the-best-embedding-reranker-models-42d079022e83) has evaluated the popular embedding and reranker models in RAG pipeline and attract great attention. Now, we follow its pipeline to evaluate our `BCEmbedding`.
254
+
255
+ [LlamaIndex](https://github.com/run-llama/llama_index)是一个著名的大模型应用的开源工具,在RAG中很受欢迎。最近,[LlamaIndex博客](https://blog.llamaindex.ai/boosting-rag-picking-the-best-embedding-reranker-models-42d079022e83)对市面上常用的embedding和reranker模型进行RAG流程的评测,吸引广泛关注。下面我们按照该评测流程验证`BCEmbedding`在RAG中的效果。
256
+
257
+ First, install LlamaIndex:
258
+ ```bash
259
+ pip install llama-index==0.9.22
260
+ ```
261
+
262
+ #### 1. Metrics Definition
263
+
264
+ - Hit Rate:
265
+
266
+ Hit rate calculates the fraction of queries where the correct answer is found within the top-k retrieved documents. In simpler terms, it's about how often our system gets it right within the top few guesses. ***The larger, the better.***
267
+
268
+ - Mean Reciprocal Rank (MRR):
269
+
270
+ For each query, MRR evaluates the system's accuracy by looking at the rank of the highest-placed relevant document. Specifically, it's the average of the reciprocals of these ranks across all the queries. So, if the first relevant document is the top result, the reciprocal rank is 1; if it's second, the reciprocal rank is 1/2, and so on. ***The larger, the better.***
271
+
272
+ - 命中率(Hit Rate)
273
+
274
+ 命中率计算的是在检索的前k个文档中找到正确答案的查询所占的比例。简单来说,它反映了我们的系统在前几次猜测中答对的频率。***该指标越大越好。***
275
+
276
+ - 平均倒数排名(Mean Reciprocal Rank,MRR)
277
+
278
+ 对于每个查询,MRR通过查看最高排名的相关文档的排名来评估系统的准确性。具体来说,它是在所有查询中这些排名的倒数的平均值。因此,如果第一个相关文档是排名最靠前的结果,倒数排名就是1;如果是第二个,倒数排名就是1/2,依此类推。***该指标越大越好。***
279
+
280
+ #### 2. Reproduce [LlamaIndex Blog](https://blog.llamaindex.ai/boosting-rag-picking-the-best-embedding-reranker-models-42d079022e83)
281
+
282
+ In order to compare our `BCEmbedding` with other embedding and reranker models fairly, we provide a one-click script to reproduce results of the LlamaIndex Blog, including our `BCEmbedding`:
283
+
284
+ 为了公平起见,运行下面脚本,复现LlamaIndex博客的结果,将`BCEmbedding`与其他embedding和reranker模型进行对比分析:
285
+
286
+ ```bash
287
+ # There should be two GPUs available at least.
288
+ CUDA_VISIBLE_DEVICES=0,1 python BCEmbedding/tools/eval_rag/eval_llamaindex_reproduce.py
289
+ ```
290
+
291
+ Then, sumarize the evaluation results by:
292
+ ```bash
293
+ python BCEmbedding/tools/eval_rag/summarize_eval_results.py --results_dir results/rag_reproduce_results
294
+ ```
295
+
296
+ Results Reproduced from the LlamaIndex Blog can be checked in ***[Reproduced Summary of RAG Evaluation](https://github.com/netease-youdao/BCEmbedding/Docs/EvaluationSummary/rag_eval_reproduced_summary.md)***, with some obvious ***conclusions***:
297
+ - In `WithoutReranker` setting, our `bce-embedding-base_v1` outperforms all the other embedding models.
298
+ - With fixing the embedding model, our `bce-reranker-base_v1` achieves the best performence.
299
+ - ***The combination of `bce-embedding-base_v1` and `bce-reranker-base_v1` is SOTA.***
300
+
301
+ 输出的指标汇总详见 ***[LlamaIndex RAG评测结果复现](https://github.com/netease-youdao/BCEmbedding/Docs/EvaluationSummary/rag_eval_reproduced_summary.md)***。从该复现结果中,可以看出:
302
+ - 在`WithoutReranker`设置下(**竖排对比**),`bce-embedding-base_v1`比其他embedding模型效果都要好。
303
+ - 在固定embedding模型设置下,对比不同reranker效果(**横排对比**),`bce-reranker-base_v1`比其他reranker模型效果都要好。
304
+ - ***`bce-embedding-base_v1`和`bce-reranker-base_v1`组合,表现SOTA。***
305
+
306
+ #### 3. Broad Domain Adaptability
307
+
308
+ The evaluation of [LlamaIndex Blog](https://blog.llamaindex.ai/boosting-rag-picking-the-best-embedding-reranker-models-42d079022e83) is **monolingual, small amount of data, and specific domain** (just including "llama2" paper). In order to evaluate the **broad domain adaptability, bilingual and crosslingual capability**, we follow the blog to build a multiple domains evaluation dataset (includding "Computer Science", "Physics", "Biology", "Economics", "Math", and "Quantitative Finance"), named [CrosslingualMultiDomainsDataset](https://huggingface.co/datasets/maidalun1020/CrosslingualMultiDomainsDataset), **by OpenAI `gpt-4-1106-preview` for high quality**.
309
+
310
+ 在上述的[LlamaIndex博客](https://blog.llamaindex.ai/boosting-rag-picking-the-best-embedding-reranker-models-42d079022e83)的评测数据只用了“llama2”这一篇文章,该评测是 **单语种,小数据量,特定领域** 的。为了兼容更真实更广的用户使用场景,评测算法模型的 **领域泛化性,双语和跨语种能力**,我们按照该博客的方法构建了一个多领���(计算机科学,物理学,生物学,经济学,数学,量化金融等)的双语种、跨语种评测数据,[CrosslingualMultiDomainsDataset](https://huggingface.co/datasets/maidalun1020/CrosslingualMultiDomainsDataset)。**为了保证构建数据的高质量,我们采用OpenAI的`gpt-4-1106-preview`。**
311
+
312
+ First, run following cmd to evaluate the most popular and powerful embedding and reranker models:
313
+
314
+ ```bash
315
+ # There should be two GPUs available at least.
316
+ CUDA_VISIBLE_DEVICES=0,1 python BCEmbedding/tools/eval_rag/eval_llamaindex_multiple_domains.py
317
+ ```
318
+
319
+ Then, run the following script to sumarize the evaluation results:
320
+ ```bash
321
+ python BCEmbedding/tools/eval_rag/summarize_eval_results.py --results_dir results/rag_results
322
+ ```
323
+
324
+ The summary of multiple domains evaluations can be seen in <a href=#1-multiple-domains-scenarios>Multiple Domains Scenarios</a>.
325
+
326
+ <t id="t7"></t>
327
+ ## 📈 Leaderboard
328
+
329
+ ### Semantic Representation Evaluations in MTEB
330
+
331
+ #### 1. Embedding Models
332
+
333
+ | Model | Retrieval | STS | PairClassification | Classification | Reranking | Clustering | Avg |
334
+ |:-------------------------------|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|
335
+ | bge-base-en-v1.5 | 37.14 | 55.06 | 75.45 | 59.73 | 43.05 | 37.74 | 47.20 |
336
+ | bge-base-zh-v1.5 | 47.60 | 63.72 | 77.40 | 63.38 | 54.85 | 32.56 | 53.60 |
337
+ | bge-large-en-v1.5 | 37.15 | 54.09 | 75.00 | 59.24 | 42.68 | 37.32 | 46.82 |
338
+ | bge-large-zh-v1.5 | 47.54 | 64.73 | **79.14** | 64.19 | 55.88 | 33.26 | 54.21 |
339
+ | jina-embeddings-v2-base-en | 31.58 | 54.28 | 74.84 | 58.42 | 41.16 | 34.67 | 44.29 |
340
+ | m3e-base | 46.29 | 63.93 | 71.84 | 64.08 | 52.38 | 37.84 | 53.54 |
341
+ | m3e-large | 34.85 | 59.74 | 67.69 | 60.07 | 48.99 | 31.62 | 46.78 |
342
+ | ***bce-embedding-base_v1*** | **57.60** | **65.73** | 74.96 | **69.00** | **57.29** | **38.95** | **59.43** |
343
+
344
+ ***NOTE:***
345
+ - Our ***bce-embedding-base_v1*** outperforms other opensource embedding models with various model size.
346
+ - ***114 datastes*** of **"Retrieval", "STS", "PairClassification", "Classification", "Reranking" and "Clustering"** in `["en", "zh", "en-zh", "zh-en"]` setting.
347
+ - The [crosslingual evaluation datasets](https://github.com/netease-youdao/BCEmbedding/BCEmbedding/evaluation/c_mteb/Retrieval.py) we released belong to `Retrieval` task.
348
+ - More evaluation details please check [Embedding Models Evaluation Summary](https://github.com/netease-youdao/BCEmbedding/Docs/EvaluationSummary/embedding_eval_summary.md).
349
+
350
+ ***要点:***
351
+ - 对比所有开源的各种规模的embedding模型,***bce-embedding-base_v1*** 表现最好。
352
+ - 评测包含 **"Retrieval", "STS", "PairClassification", "Classification", "Reranking"和"Clustering"** 这六大类任务的共 ***114个数据集***。
353
+ - 我们开源的[跨语种语义表征评测数据](https://github.com/netease-youdao/BCEmbedding/BCEmbedding/evaluation/c_mteb/Retrieval.py)属于`Retrieval`任务。
354
+ - 更详细的评测结果详见[Embedding模型指标汇总](https://github.com/netease-youdao/BCEmbedding/Docs/EvaluationSummary/embedding_eval_summary.md)。
355
+
356
+ #### 2. Reranker Models
357
+
358
+ | Model | Reranking | Avg |
359
+ |:-------------------------------|:--------:|:--------:|
360
+ | bge-reranker-base | 57.78 | 57.78 |
361
+ | bge-reranker-large | 59.69 | 59.69 |
362
+ | ***bce-reranker-base_v1*** | **60.06** | **60.06** |
363
+
364
+ ***NOTE:***
365
+ - Our ***bce-reranker-base_v1*** outperforms other opensource reranker models.
366
+ - ***12 datastes*** of **"Reranking"** in `["en", "zh", "en-zh", "zh-en"]` setting.
367
+ - More evaluation details please check [Reranker Models Evaluation Summary](https://github.com/netease-youdao/BCEmbedding/Docs/EvaluationSummary/reranker_eval_summary.md).
368
+
369
+ ***要点:***
370
+ - ***bce-reranker-base_v1*** 优于其他开源reranker模型。
371
+ - 评测包含 **"Reranking"** 任务的 ***12个数据集***。
372
+ - 更详细的评测结果详见[Reranker模型指标汇总](https://github.com/netease-youdao/BCEmbedding/Docs/EvaluationSummary/reranker_eval_summary.md)
373
+
374
+ ### RAG Evaluations in LlamaIndex
375
+
376
+ #### 1. Multiple Domains Scenarios
377
+
378
+ | Embedding Models | WithoutReranker <br> [*hit_rate/mrr*] | CohereRerank <br> [*hit_rate/mrr*] | bge-reranker-large <br> [*hit_rate/mrr*] | ***bce-reranker-base_v1*** <br> [*hit_rate/mrr*] |
379
+ |:-------------------------------|:--------:|:--------:|:--------:|:--------:|
380
+ | OpenAI-ada-2 | 81.04/57.35 | 88.35/67.83 | 88.89/69.64 | **90.71/75.46** |
381
+ | bge-large-en-v1.5 | 52.67/34.69 | 64.59/52.11 | 64.71/52.05 | **65.36/55.50** |
382
+ | bge-large-zh-v1.5 | 69.81/47.38 | 79.37/62.13 | 80.11/63.95 | **81.19/68.50** |
383
+ | llm-embedder | 50.85/33.26 | 63.62/51.45 | 63.54/51.32 | **64.47/54.98** |
384
+ | CohereV3 | 53.10/35.39 | 65.75/52.80 | 66.29/53.31 | **66.91/56.93** |
385
+ | JinaAI-Base | 50.27/32.31 | 63.97/51.10 | 64.28/51.83 | **64.82/54.98** |
386
+ | ***bce-embedding-base_v1*** | **85.91/62.36** | **91.25/69.38** | **91.80/71.13** | ***93.46/77.02*** |
387
+
388
+ ***NOTE:***
389
+ - In `WithoutReranker` setting, our `bce-embedding-base_v1` outperforms all the other embedding models.
390
+ - With fixing the embedding model, our `bce-reranker-base_v1` achieves the best performence.
391
+ - **The combination of `bce-embedding-base_v1` and `bce-reranker-base_v1` is SOTA**.
392
+
393
+ ***要点:***
394
+ - 在`WithoutReranker`设置下(**竖排对比**),`bce-embedding-base_v1`优于其他Embedding模型,包括开源和闭源。
395
+ - 在固定Embedding模型设置下,对比不同reranker效果(**横排对比**),`bce-reranker-base_v1`比其他reranker模型效果都要好,包括开源和闭源。
396
+ - ***`bce-embedding-base_v1`和`bce-reranker-base_v1`组合,表现SOTA。***
397
+
398
+ <t id="t8"></t>
399
+ ## 🛠 Youdao's BCEmbedding API
400
+
401
+ For users who prefer a hassle-free experience without the need to download and configure the model on their own systems, `BCEmbedding` is readily accessible through Youdao's API. This option offers a streamlined and efficient way to integrate BCEmbedding into your projects, bypassing the complexities of manual setup and maintenance. Detailed instructions and comprehensive API documentation are available at [Youdao BCEmbedding API](https://ai.youdao.com/DOCSIRMA/html/aigc/api/embedding/index.html). Here, you'll find all the necessary guidance to easily implement `BCEmbedding` across a variety of use cases, ensuring a smooth and effective integration for optimal results.
402
+
403
+ 对于那些更喜欢直接调用api的用户,有道提供方便的`BCEmbedding`调用api。该方式是一种简化和高效的方式,将`BCEmbedding`集成到您的项目中,避开了手动设置和系统维护的复杂性。更详细的api调用接口说明详见[有道BCEmbedding API](https://ai.youdao.com/DOCSIRMA/html/aigc/api/embedding/index.html)。
404
+
405
+ <t id="t9"></t>
406
+ ## 🧲 WeChat Group
407
+
408
+ Welcome to scan the QR code below and join the WeChat group.
409
+
410
+ 欢迎大家扫码加入官方微信交流群。
411
+
412
+ <img src="https://github.com/netease-youdao/BCEmbedding/Docs/assets/Wechat.jpg" width="20%" height="auto">
413
+
414
+ <t id="t10"></t>
415
+ ## ✏️ Citation
416
+
417
+ If you use `BCEmbedding` in your research or project, please feel free to cite and star it:
418
+
419
+ 如果在您的研究或任何项目中使用本工作,烦请按照下方进行引用,并打个小星星~
420
+
421
+ ```
422
+ @misc{youdao_bcembedding_2023,
423
+ title={BCEmbedding: Bilingual and Crosslingual Embedding for RAG},
424
+ author={NetEase Youdao, Inc.},
425
+ year={2023},
426
+ howpublished={\url{https://github.com/netease-youdao/BCEmbedding}}
427
+ }
428
+ ```
429
+
430
+ <t id="t11"></t>
431
+ ## 🔐 License
432
+
433
+ `BCEmbedding` is licensed under [Apache 2.0 License](https://github.com/netease-youdao/BCEmbedding/LICENSE)
434
+
435
+ <t id="t12"></t>
436
+ ## 🔗 Related Links
437
+
438
+ [Netease Youdao - QAnything](https://github.com/netease-youdao/qanything)
439
+
440
+ [FlagEmbedding](https://github.com/FlagOpen/FlagEmbedding)
441
+
442
+ [MTEB](https://github.com/embeddings-benchmark/mteb)
443
+
444
+ [C_MTEB](https://github.com/FlagOpen/FlagEmbedding/tree/master/C_MTEB)
445
+
446
+ [LLama Index](https://github.com/run-llama/llama_index) | [LlamaIndex Blog](https://blog.llamaindex.ai/boosting-rag-picking-the-best-embedding-reranker-models-42d079022e83)