Gte Large En V1.5
G
Gte Large En V1.5
由Alibaba-NLP開發
GTE-Large是一個高性能的英文文本嵌入模型,在多個文本相似度和分類任務上表現優異。
下載量 891.76k
發布時間 : 4/20/2024
模型概述
該模型專注於生成高質量的句子級嵌入表示,適用於信息檢索、文本相似度計算和分類任務。
模型特點
多任務性能優異
在MTEB基準測試的多種任務(分類、聚類、檢索等)中表現突出
高質量句子嵌入
生成的嵌入表示能有效捕捉語義信息,適用於相似度計算
廣泛適用性
支持多種下游NLP任務,包括分類、聚類和信息檢索
模型能力
文本相似度計算
文本分類
信息檢索
文本聚類
句子嵌入生成
使用案例
電子商務
產品評論情感分析
分析亞馬遜產品評論的情感傾向
在AmazonPolarity數據集上達到93.97%準確率
產品相似度匹配
計算產品描述之間的相似度
客戶服務
銀行問題分類
自動分類銀行客戶問題
在Banking77數據集上達到87.33%準確率
學術研究
論文聚類
根據內容相似度對學術論文進行分組
在ArxivClusteringP2P上V-measure達到48.47
🚀 gte-large-en-v1.5
我們推出了 gte-v1.5
系列,這是升級版的 gte
嵌入模型,支持最長達 8192 的上下文長度,同時進一步提升了模型性能。該模型基於 transformer++
編碼器 主幹網絡(BERT + RoPE + GLU)構建。
gte-v1.5
系列在 MTEB 基準測試的相同模型尺寸類別中取得了最先進的分數,並在 LoCo 長上下文檢索測試中表現出色(詳見評估)。
我們還推出了 gte-Qwen1.5-7B-instruct
,這是一個最先進的指令微調多語言嵌入模型,在 MTEB 中排名第二,在 C - MTEB 中排名第一。
- 開發者: 阿里巴巴集團智能計算研究所
- 模型類型: 文本嵌入
- 論文: mGTE: Generalized Long-Context Text Representation and Reranking Models for Multilingual Text Retrieval
模型列表
模型 | 語言 | 模型大小 | 最大序列長度 | 維度 | MTEB - en | LoCo |
---|---|---|---|---|---|---|
gte-Qwen1.5-7B-instruct |
多語言 | 7720 | 32768 | 4096 | 67.34 | 87.57 |
gte-large-en-v1.5 |
英語 | 434 | 8192 | 1024 | 65.39 | 86.71 |
gte-base-en-v1.5 |
英語 | 137 | 8192 | 768 | 64.11 | 87.44 |
🚀 快速開始
使用transformers庫
使用以下代碼開始使用該模型:
# Requires transformers>=4.36.0
import torch.nn.functional as F
from transformers import AutoModel, AutoTokenizer
input_texts = [
"what is the capital of China?",
"how to implement quick sort in python?",
"Beijing",
"sorting algorithms"
]
model_path = 'Alibaba-NLP/gte-large-en-v1.5'
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModel.from_pretrained(model_path, trust_remote_code=True)
# Tokenize the input texts
batch_dict = tokenizer(input_texts, max_length=8192, padding=True, truncation=True, return_tensors='pt')
outputs = model(**batch_dict)
embeddings = outputs.last_hidden_state[:, 0]
# (Optionally) normalize embeddings
embeddings = F.normalize(embeddings, p=2, dim=1)
scores = (embeddings[:1] @ embeddings[1:].T) * 100
print(scores.tolist())
⚠️ 重要提示
建議安裝 xformers 並啟用非填充(unpadding)以加速推理,詳情請參考 enable-unpadding-and-xformers。
使用sentence-transformers庫
# Requires sentence_transformers>=2.7.0
from sentence_transformers import SentenceTransformer
from sentence_transformers.util import cos_sim
sentences = ['That is a happy person', 'That is a very happy person']
model = SentenceTransformer('Alibaba-NLP/gte-large-en-v1.5', trust_remote_code=True)
embeddings = model.encode(sentences)
print(cos_sim(embeddings[0], embeddings[1]))
使用 transformers.js
// npm i @xenova/transformers
import { pipeline, dot } from '@xenova/transformers';
// Create feature extraction pipeline
const extractor = await pipeline('feature-extraction', 'Alibaba-NLP/gte-large-en-v1.5', {
quantized: false, // Comment out this line to use the quantized version
});
// Generate sentence embeddings
const sentences = [
"what is the capital of China?",
"how to implement quick sort in python?",
"Beijing",
"sorting algorithms"
]
const output = await extractor(sentences, { normalize: true, pooling: 'cls' });
// Compute similarity scores
const [source_embeddings, ...document_embeddings ] = output.tolist();
const similarities = document_embeddings.map(x => 100 * dot(source_embeddings, x));
console.log(similarities); // [41.86354093370361, 77.07076371259589, 37.02981979677899]
📦 安裝指南
使用該模型需要安裝相應的庫,以下是不同使用場景下的依賴要求:
- 使用
transformers
庫:transformers>=4.36.0
- 使用
sentence-transformers
庫:sentence_transformers>=2.7.0
- 使用
transformers.js
:通過npm i @xenova/transformers
安裝
🔧 技術細節
訓練數據
訓練過程
為了使主幹模型支持 8192 的上下文長度,我們採用了多階段訓練策略。模型首先在較短長度上進行初步的 MLM 預訓練,然後重新採樣數據,減少短文本的比例,並繼續進行 MLM 預訓練。
整個訓練過程如下:
- MLM - 512:學習率 2e - 4,掩碼概率 0.3,批次大小 4096,步數 300000,RoPE 基數 10000
- MLM - 2048:學習率 5e - 5,掩碼概率 0.3,批次大小 4096,步數 30000,RoPE 基數 10000
- MLM - 8192:學習率 5e - 5,掩碼概率 0.3,批次大小 1024,步數 30000,RoPE 基數 160000
- CPT:最大長度 512,學習率 5e - 5,批次大小 28672,步數 100000
- 微調:待補充
📚 詳細文檔
MTEB 評估
其他模型的結果取自 MTEB 排行榜。
gte
評估設置:mteb==1.2.0
,FP16 自動混合精度,max_length = 8192
,並將 NTK 縮放因子設置為 2(相當於 RoPE 基數 * 2)。
模型名稱 | 參數大小(M) | 維度 | 序列長度 | 平均(56) | 分類(12) | 聚類(11) | 成對分類(3) | 重排序(4) | 檢索(15) | STS(10) | 摘要(1) |
---|---|---|---|---|---|---|---|---|---|---|---|
gte-large-en-v1.5 | 409 | 1024 | 8192 | 65.39 | 77.75 | 47.95 | 84.63 | 58.50 | 57.91 | 81.43 | 30.91 |
mxbai-embed-large-v1 | 335 | 1024 | 512 | 64.68 | 75.64 | 46.71 | 87.2 | 60.11 | 54.39 | 85 | 32.71 |
multilingual-e5-large-instruct | 560 | 1024 | 514 | 64.41 | 77.56 | 47.1 | 86.19 | 58.58 | 52.47 | 84.78 | 30.39 |
bge-large-en-v1.5 | 335 | 1024 | 512 | 64.23 | 75.97 | 46.08 | 87.12 | 60.03 | 54.29 | 83.11 | 31.61 |
gte-base-en-v1.5 | 137 | 768 | 8192 | 64.11 | 77.17 | 46.82 | 85.33 | 57.66 | 54.09 | 81.97 | 31.17 |
bge-base-en-v1.5 | 109 | 768 | 512 | 63.55 | 75.53 | 45.77 | 86.55 | 58.86 | 53.25 | 82.4 | 31.07 |
LoCo 評估
模型名稱 | 維度 | 序列長度 | 平均(5) | Qsmsum 檢索 | SummScreen 檢索 | Qasper 摘要檢索 | Qasper 標題檢索 | GovReport 檢索 |
---|---|---|---|---|---|---|---|---|
gte-qwen1.5-7b | 4096 | 32768 | 87.57 | 49.37 | 93.10 | 99.67 | 97.54 | 98.21 |
gte-large-v1.5 | 1024 | 8192 | 86.71 | 44.55 | 92.61 | 99.82 | 97.81 | 98.74 |
gte-base-v1.5 | 768 | 8192 | 87.44 | 49.91 | 91.78 | 99.82 | 97.13 | 98.58 |
📄 許可證
本項目採用 Apache 2.0 許可證。
📖 引用
如果您覺得我們的論文或模型有幫助,請考慮按以下方式引用:
@article{zhang2024mgte,
title={mGTE: Generalized Long-Context Text Representation and Reranking Models for Multilingual Text Retrieval},
author={Zhang, Xin and Zhang, Yanzhao and Long, Dingkun and Xie, Wen and Dai, Ziqi and Tang, Jialong and Lin, Huan and Yang, Baosong and Xie, Pengjun and Huang, Fei and others},
journal={arXiv preprint arXiv:2407.19669},
year={2024}
}
@article{li2023towards,
title={Towards general text embeddings with multi-stage contrastive learning},
author={Li, Zehan and Zhang, Xin and Zhang, Yanzhao and Long, Dingkun and Xie, Pengjun and Zhang, Meishan},
journal={arXiv preprint arXiv:2308.03281},
year={2023}
}
Jina Embeddings V3
Jina Embeddings V3 是一個多語言句子嵌入模型,支持超過100種語言,專注於句子相似度和特徵提取任務。
文本嵌入
Transformers 支持多種語言

J
jinaai
3.7M
911
Ms Marco MiniLM L6 V2
Apache-2.0
基於MS Marco段落排序任務訓練的交叉編碼器模型,用於信息檢索中的查詢-段落相關性評分
文本嵌入 英語
M
cross-encoder
2.5M
86
Opensearch Neural Sparse Encoding Doc V2 Distill
Apache-2.0
基於蒸餾技術的稀疏檢索模型,專為OpenSearch優化,支持免推理文檔編碼,在搜索相關性和效率上優於V1版本
文本嵌入
Transformers 英語

O
opensearch-project
1.8M
7
Sapbert From PubMedBERT Fulltext
Apache-2.0
基於PubMedBERT的生物醫學實體表徵模型,通過自對齊預訓練優化語義關係捕捉
文本嵌入 英語
S
cambridgeltl
1.7M
49
Gte Large
MIT
GTE-Large 是一個強大的句子轉換器模型,專注於句子相似度和文本嵌入任務,在多個基準測試中表現出色。
文本嵌入 英語
G
thenlper
1.5M
278
Gte Base En V1.5
Apache-2.0
GTE-base-en-v1.5 是一個英文句子轉換器模型,專注於句子相似度任務,在多個文本嵌入基準測試中表現優異。
文本嵌入
Transformers 支持多種語言

G
Alibaba-NLP
1.5M
63
Gte Multilingual Base
Apache-2.0
GTE Multilingual Base 是一個多語言的句子嵌入模型,支持超過50種語言,適用於句子相似度計算等任務。
文本嵌入
Transformers 支持多種語言

G
Alibaba-NLP
1.2M
246
Polybert
polyBERT是一個化學語言模型,旨在實現完全由機器驅動的超快聚合物信息學。它將PSMILES字符串映射為600維密集指紋,以數值形式表示聚合物化學結構。
文本嵌入
Transformers

P
kuelumbus
1.0M
5
Bert Base Turkish Cased Mean Nli Stsb Tr
Apache-2.0
基於土耳其語BERT的句子嵌入模型,專為語義相似度任務優化
文本嵌入
Transformers 其他

B
emrecan
1.0M
40
GIST Small Embedding V0
MIT
基於BAAI/bge-small-en-v1.5模型微調的文本嵌入模型,通過MEDI數據集與MTEB分類任務數據集訓練,優化了檢索任務的查詢編碼能力。
文本嵌入
Safetensors 英語
G
avsolatorio
945.68k
29
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98