論文閱讀 Qwen3 Embedding

論文地址:https://arxiv.org/pdf/2506.05176

Contribution

  1. 基於合成數據的 multi-stage 訓練

  2. 構建高質量合成數據

  3. 引入模型合併(model merging)

細節

模型

Embedding Models

Reranking Models

<|im_start|>system
Judge whether the Document meets the requirements based on the Query and the
Instruct provided. Note that the answer can only be "yes" or
"no".<|im_end|>
, →, →
<|im_start|>user
<Instruct>: {Instruction}
<Query>: {Query}
<Document>: {Document}<|im_end|>
<|im_start|>assistant
<think>\n\n</think>\n\n

訓練

訓練目標

Embedding 模型採用 InfoNCE 對比損失

Reranking 模型採用 SFT(二分類交叉熵)損失

Multi-stage training

分爲三階段:

第一階段:大規模的合成數據驅動的弱監督學習

Large-Scale Synthetic Data-Driven Weak Supervision Training

之前的 GTE, E5, BGE models 的數據主要來源於開源社區,Qwen3 的創新點在於使用基座模型來合成數據。根據不同維度的需要來生成,例如 task, language, length 和 difficulty。與開源數據相比,合成數據更加可控,具有多樣性。

第二階段:SFT 階段利用高質量合成數據進行監督學習

High-Quality Synthetic Data Utilization in Supervised Fine Tuning

對篩選出的高質量合成數據(相似度 > 0.7)和公開監督數據集(如 MS MARCO、MIRACL 等)進行監督訓練。

第三階段:模型合併(Model Merging)

在 SFT 之後,對篩選出的高質量合成數據(相似度 > 0.7)和公開監督數據集(如 MS MARCO、MIRACL 等)進行監督訓練。

注意:

Reranking 模型的訓練補不包含第一階段的弱監督訓練。

數據合成

Qwen3 的訓練體系引入了四類任務合成數據:

數據合成使用的模型爲 Qwen3-32B,語料來源是 Qwen3 基座模型預訓練階段的多語言數據集。

以 Retrieval 任務數據合成爲例

數據合成分爲兩個階段:

  1. 配置階段(Configuration)

  2. 對合成的 query 使用大模型決定 “Question Type”, “Difficulty”, and “Character” 。

  3. Characters 來源於 Persona Hub (Ge et al., 2024),,從角色庫中找出 top-5 的候選項

Template 如下:

Given a **Passage** and **Character**, select the appropriate option from
three fields: Character, Question_Type, Difficulty, and return the output
in JSON format.

First, select the Character who are likely to be interested in the Passage
from the candidates. Then select the Question_Type that the Character
might ask about the Passage; Finally, choose the Difficulty of the
possible question based on the Passage, the Character, and the
Question_Type.
Character: Given by input **Character**

Question_Type:
- keywords: ...
- acquire_knowledge: ...
- summary: ...
- yes_or_no: ...
- background: ...

Difficulty:
- high_school: ...
- university: ...
- phd: ...

Here are some examples
<Example1> <Example2> <Example3>
Now, generate the **output** based on the **Passage** and **Character** from
user, the **Passage** will be in {language} language and the **Character**
will be in English.

Ensure to generate only the JSON output with content in English.
**Passage**:
{passage}
**Character**:
{character}

拆解這個 prompt:

輸入:一段多語種文檔(Passage)和角色(Character)

使用 LLM(如 Qwen3-32B)生成:

輸出(JSON 格式):

{
  "Character": "...",
  "Question_Type": "...",
  "Difficulty": "..."
}
  1. 查詢生成階段(Query Generation)

基於上述配置,LLM 生成一個自然語言查詢(Query),用於構造 (query, document) 檢索訓練對。

template 爲:

Given a **Character**, **Passage**, and **Requirement**, generate a query from
the **Character**'s perspective that satisfies the **Requirement** and can
be used to retrieve the **Passage**. Please return the result in JSON
format.

Here is an example:
<example>

Now, generate the **output** based on the **Character**, **Passage** and
**Requirement** from user, the **Passage** will be in {corpus_language}
language, the **Character** and **Requirement** will be in English.

Ensure to generate only the JSON output, with the key in English and the value
in {queries_language} language.

**Character**
{character}
**Passage**
{passage}
**Requirment**
- Type: {type};
- Difficulty: {difficulty};
- Length: the length of the generated sentences should be {length} words;
- Languange: the language in which the results are generated should be
{language} language;

拆解這個 prompt:

輸入:

輸出:

數據過濾

對每一對數據計算 cosine 相似度,選擇相似度大於 0.7 的數據作爲高質量數據。

數據

第一階段 Weakly Supervised Pre-Traning

第二階段 Supervised Fine Tuning

評估和結果

Massive Multilingual Text Embedding Benchmark (MMTEB)

消融實驗

  1. 僅僅在合成數據上訓練的 Qwen3-Embedding-0.6B 比最後的 Qwen3-Embedding-0.6B 模型效果要好。

  2. 把弱監督階段去掉的話,最後的性能會下降。

  3. 如果不進行合併,Qwen3-Embedding-0.6B 的性能會明顯下降;

術語和概念

因果注意力(Causal Attention)

Causal attention 是一種自迴歸注意力機制,模型在生成每個詞時只能看到它之前的詞。這種機制通過一個上三角的 attention mask 實現。

注意力機制的區別

A31V3n

Rerank 方法

MRL

(略)

spherical linear interpolation 球狀線性差值 (slerp)

(略)

其他

1. Persona Hub (地址:https://github.com/tencent-ailab/persona-hub)

我覺得這個項目很有意思,裏面有 3 億個擬人設定,例如環保主義者,歷史學家,自然愛好者,老師,地理學家,學生,歌唱家等第。想象一下在虛擬世界裏,這些人會幹什麼,會問什麼問題?

隨便看兩個人物設定:

對羅馬帝國感興趣的歷史學家:

A historian or a scholar who is interested in the history of the Roman Empire, particularly the early years and the impact of Christianity on society. They are knowledgeable about the persecution of Christians in the Roman Empire and the story of Saint Maurice, the Roman soldier who refused to participate in pagan sacrifices and was eventually martyred. They are also interested in the concept of honor, courage, and faithfulness to one's beliefs, which are reflected in the story of Saint Maurice.

對醫學術語感興趣的人:

A person who is interested in medical terms and their meanings, particularly those related to cancer and medicine. They are likely to be a medical professional, a researcher, or a student who is studying the field of cancer biology. They are knowledgeable about the NCI Dictionary of Cancer Terms and are interested in learning more about parathyroid cancer and its related terms.

2. 比對挖掘(bitext mining)

比對挖掘(Bitext Mining)是一種自動從不同語言的文本中找出互爲翻譯的句子對的技術。它廣泛應用於機器翻譯、跨語言信息檢索、多語言語料構建等領域。

本文由 Readfog 進行 AMP 轉碼,版權歸原作者所有。
來源https://mp.weixin.qq.com/s/EZLPjgNl9eH-kzwAVXCTtQ