跳到正文
Hugging Face Blog·· 2022-10-19精選AI 評分71

MTEB 提供文本嵌入模型的大規模基準測試與排行榜

MTEB: Massive Text Embedding Benchmark

AI 導讀

MTEB 是一套評估文本嵌入模型在多種任務上表現的大型基準測試,並以排行榜彙整模型成績。該基準涵蓋 56 個數據集、8 類任務及最多 112 種語言,排行榜彙整 >2000 項結果。

推薦理由

MTEB 把 56 個數據集、8 類任務納入同一排行榜,並提供自行測試及提交結果的流程,方便按具體任務比較文本嵌入模型。

正文 · 繁體中文

MTEB 是一個大型基準測試,用於衡量文字嵌入模型在多種嵌入任務上的表現。

🥇 排行榜全面呈現各類任務中表現最佳的文字嵌入模型。

📝 論文介紹 MTEB 的任務和資料集背景,並分析排行榜結果!

💻 GitHub 儲存庫包含基準測試程式碼,也可用來將你選擇的模型提交至排行榜。

MTEB Leaderboard

為甚麼需要文字嵌入?

文字嵌入是編碼語義資訊的文字向量表示。由於機器需要數值輸入才能進行運算,文字嵌入是許多下游 NLP 應用的重要組件。例如,Google 使用文字嵌入為其搜尋引擎提供支援。文字嵌入亦可用來透過文字聚類分析大量文字中的模式,或作為文字分類模型的輸入,例如我們最近的 SetFit 工作。不過,文字嵌入的品質很大程度取決於所用的嵌入模型。MTEB 旨在協助你為不同任務找出最佳嵌入模型!

MTEB

🐋 大型規模:MTEB 涵蓋 8 項任務的 56 個資料集,目前在排行榜上彙整超過 2000 項結果。

🌎 多語言:MTEB 涵蓋多達 112 種語言!我們已在 Bitext Mining、Classification 和 STS 任務上,對多個多語言模型進行基準測試。

🦚 可擴展:無論是新增任務、資料集、指標,還是排行榜項目,我們都非常歡迎各種貢獻。請查看 GitHub 儲存庫,提交至排行榜或處理未解決的問題。期待你加入我們,一同找出最佳文字嵌入模型!

MTEB Taxonomy

MTEB 任務和資料集概覽。紫色陰影標示多語言資料集。

模型

MTEB 初期基準測試聚焦於聲稱達到最先進成果的模型,以及 Hub 上的熱門模型,因此 Transformers 模型佔了相當大比重。🤖

MTEB Speed Benchmark

模型的平均英文 MTEB 分數(y 軸)、速度(x 軸)與嵌入大小(圓圈大小)。

為方便你為任務找出最佳模型,我們將模型分成以下三類:

🏎 最高速度 像 Glove 這類模型速度很快,但缺乏上下文感知能力,因此 MTEB 平均分數較低。

⚖️ 速度與效能兼備 all-mpnet-base-v2 或 all-MiniLM-L6-v2 速度稍慢,但能力明顯更強,在速度與效能之間取得良好平衡。

💪 最高效能 像 ST5-XXL、GTR-XXL 或 SGPT-5.8B-msmarco 這類擁有數十億參數的模型,在 MTEB 上表現出色。它們通常也會產生較大的嵌入向量,例如 SGPT-5.8B-msmarco 會產生 4096 維嵌入,需要更多儲存空間!

模型表現會因任務和資料集而有很大差異,因此在決定使用哪個模型前,我們建議查看排行榜的不同分頁!

為你的模型進行基準測試

使用 MTEB 程式庫,你可以為任何會產生嵌入向量的模型進行基準測試,並將結果加入公開排行榜。以下快速示範一次!

首先,安裝程式庫:

pip install mteb

接着,在資料集上為模型進行基準測試,例如使用 komninos word embeddings 模型測試 Banking77。

from mteb import MTEB
from sentence_transformers import SentenceTransformer

model_name = "average_word_embeddings_komninos"
model = SentenceTransformer(model_name)

evaluation = MTEB(tasks=["Banking77Classification"])
results = evaluation.run(model, output_folder=f"results/{model_name}")

這應會產生 results/average_word_embeddings_komninos/Banking77Classification.json 檔案!

現在,你可以將結果加入 Hub 上任何模型的 README.md metadata,提交至排行榜。

執行我們的自動化指令碼以產生 metadata:

python mteb_meta.py results/average_word_embeddings_komninos

指令碼會產生類似以下內容的 mteb_metadata.md 檔案: ```sh

tags: - mteb model-index: - name: average_word_embeddings_komninos results: - task: type: Classification dataset: type: mteb/banking77 name: MTEB Banking77Classification config: default split: test revision: 0fd18e25b25c072e09e0d92ab615fda904d66300 metrics: - type: accuracy value: 66.76623376623377 - type: f1 value: 66.59096432882667


Now add the metadata to the top of a `README.md` of any model on the Hub, like this [SGPT-5.8B-msmarco](https://huggingface.co/Muennighoff/SGPT-5.8B-weightedmean-msmarco-specb-bitfit/blob/main/README.md) model, and it will show up on the [leaderboard](https://huggingface.co/spaces/mteb/leaderboard) after refreshing!

## Next steps

Go out there and benchmark any model you like! Let us know if you have questions or feedback by opening an issue on our [GitHub repo](https://github.com/embeddings-benchmark/mteb) or the [leaderboard community tab](https://huggingface.co/spaces/mteb/leaderboard/discussions) 🤗

Happy embedding!

## Credits

Huge thanks to the following who contributed to the article or to the MTEB codebase (listed in alphabetical order): Steven Liu, Loïc Magne, Nils Reimers and Nouamane Tazi.

來源:Hugging Face Blog · huggingface.co