{"id":27430,"date":"2025-03-03T13:01:19","date_gmt":"2025-03-03T05:01:19","guid":{"rendered":"https:\/\/www.aisharenet.com\/?p=27430"},"modified":"2025-03-03T13:01:31","modified_gmt":"2025-03-03T05:01:31","slug":"mteb","status":"publish","type":"post","link":"https:\/\/www.kdjingpai.com\/pt\/mteb\/","title":{"rendered":"MTEB\uff1a\u8bc4\u4f30\u6587\u672c\u5d4c\u5165\u6a21\u578b\u6027\u80fd\u7684\u57fa\u51c6\u6d4b\u8bd5"},"content":{"rendered":"<p>MTEB\uff08Massive Text Embedding Benchmark\uff09\u662f\u4e00\u4e2a\u7531 embeddings-benchmark \u56e2\u961f\u5f00\u53d1\u5e76\u6258\u7ba1\u5728 GitHub \u4e0a\u7684\u5f00\u6e90\u9879\u76ee\uff0c\u65e8\u5728\u4e3a\u6587\u672c\u5d4c\u5165\u6a21\u578b\u63d0\u4f9b\u5168\u9762\u7684\u6027\u80fd\u8bc4\u4f30\u3002\u5b83\u6db5\u76d6\u4e868\u5927\u4efb\u52a1\u7c7b\u578b\uff0c\u5305\u62ec\u5206\u7c7b\u3001\u805a\u7c7b\u3001\u68c0\u7d22\u7b49\uff0c\u6574\u5408\u4e8658\u4e2a\u6570\u636e\u96c6\uff0c\u652f\u6301112\u79cd\u8bed\u8a00\uff0c\u662f\u76ee\u524d\u6700\u5168\u9762\u7684\u6587\u672c\u5d4c\u5165\u57fa\u51c6\u6d4b\u8bd5\u5de5\u5177\u4e4b\u4e00\u3002MTEB \u901a\u8fc7\u5bf933\u79cd\u6a21\u578b\u7684\u6d4b\u8bd5\uff0c\u63ed\u793a\u4e86\u4e0d\u540c\u6a21\u578b\u5728\u5404\u7c7b\u4efb\u52a1\u4e2d\u7684\u8868\u73b0\u5dee\u5f02\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u9009\u62e9\u9002\u5408\u5177\u4f53\u5e94\u7528\u7684\u5d4c\u5165\u6a21\u578b\u3002\u8be5\u9879\u76ee\u63d0\u4f9b\u5f00\u6e90\u4ee3\u7801\uff0c\u7528\u6237\u53ef\u4ee5\u81ea\u7531\u8fd0\u884c\u6d4b\u8bd5\u6216\u63d0\u4ea4\u65b0\u6a21\u578b\u81f3\u516c\u5171\u6392\u884c\u699c\uff0c\u5e7f\u6cdb\u9002\u7528\u4e8eNLP\u7814\u7a76\u3001\u6a21\u578b\u5f00\u53d1\u53ca\u884c\u4e1a\u5e94\u7528\u573a\u666f\u3002<\/p>\n<div id=\"attachment_27432\" style=\"width: 1329px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-27432\" class=\"wp-image-27432 size-full\" title=\"MTEB\uff1a\u8bc4\u4f30\u6587\u672c\u5d4c\u5165\u6a21\u578b\u6027\u80fd\u7684\u5f00\u6e90\u57fa\u51c6\u6d4b\u8bd5\u5de5\u5177-1\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/82292bd2fc9c407.png\" alt=\"MTEB\uff1a\u8bc4\u4f30\u6587\u672c\u5d4c\u5165\u6a21\u578b\u6027\u80fd\u7684\u5f00\u6e90\u57fa\u51c6\u6d4b\u8bd5\u5de5\u5177-1\" width=\"1319\" height=\"619\" srcset=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/82292bd2fc9c407.png 1319w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/82292bd2fc9c407-768x360.png 768w\" sizes=\"auto, (max-width: 1319px) 100vw, 1319px\" \/><p id=\"caption-attachment-27432\" class=\"wp-caption-text\">\u8bbf\u95ee\u5730\u5740\uff1ahttps:\/\/huggingface.co\/spaces\/mteb\/leaderboard<\/p><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-27431\" title=\"MTEB\uff1a\u8bc4\u4f30\u6587\u672c\u5d4c\u5165\u6a21\u578b\u6027\u80fd\u7684\u5f00\u6e90\u57fa\u51c6\u6d4b\u8bd5\u5de5\u5177-1\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/747089af1decbc4.png\" alt=\"MTEB\uff1a\u8bc4\u4f30\u6587\u672c\u5d4c\u5165\u6a21\u578b\u6027\u80fd\u7684\u5f00\u6e90\u57fa\u51c6\u6d4b\u8bd5\u5de5\u5177-1\" width=\"751\" height=\"389\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>\u529f\u80fd\u5217\u8868<\/h2>\n<ul>\n<li><strong>\u591a\u4efb\u52a1\u8bc4\u4f30\u652f\u6301<\/strong>\uff1a\u5305\u542b8\u79cd\u5d4c\u5165\u4efb\u52a1\uff0c\u5982\u8bed\u4e49\u6587\u672c\u76f8\u4f3c\u5ea6\uff08STS\uff09\u3001\u68c0\u7d22\u3001\u805a\u7c7b\u7b49\uff0c\u8986\u76d6\u591a\u79cd\u5e94\u7528\u573a\u666f\u3002<\/li>\n<li><strong>\u591a\u8bed\u8a00\u6570\u636e\u96c6<\/strong>\uff1a\u652f\u6301112\u79cd\u8bed\u8a00\uff0c\u63d0\u4f9b\u591a\u8bed\u8a00\u6a21\u578b\u7684\u6d4b\u8bd5\u80fd\u529b\uff0c\u9002\u5408\u5168\u7403\u5316\u5e94\u7528\u5f00\u53d1\u3002<\/li>\n<li><strong>\u6a21\u578b\u6027\u80fd\u6392\u884c\u699c<\/strong>\uff1a\u5185\u7f6e\u516c\u5171\u6392\u884c\u699c\uff0c\u5c55\u793a33\u79cd\u6a21\u578b\u7684\u6d4b\u8bd5\u7ed3\u679c\uff0c\u4fbf\u4e8e\u7528\u6237\u5bf9\u6bd4\u9009\u62e9\u3002<\/li>\n<li><strong>\u81ea\u5b9a\u4e49\u6a21\u578b\u6d4b\u8bd5<\/strong>\uff1a\u5141\u8bb8\u7528\u6237\u5bfc\u5165\u81ea\u5b9a\u4e49\u5d4c\u5165\u6a21\u578b\uff0c\u4ec5\u9700\u5c11\u91cf\u4ee3\u7801\u5373\u53ef\u8fd0\u884c\u8bc4\u4f30\u3002<\/li>\n<li><strong>\u7f13\u5b58\u5d4c\u5165\u529f\u80fd<\/strong>\uff1a\u652f\u6301\u5d4c\u5165\u7ed3\u679c\u7f13\u5b58\uff0c\u4f18\u5316\u91cd\u590d\u6d4b\u8bd5\u6548\u7387\uff0c\u9002\u5408\u5927\u89c4\u6a21\u5b9e\u9a8c\u3002<\/li>\n<li><strong>\u7075\u6d3b\u53c2\u6570\u8c03\u6574<\/strong>\uff1a\u63d0\u4f9b\u7f16\u7801\u53c2\u6570\u914d\u7f6e\uff0c\u5982\u6279\u91cf\u5927\u5c0f\u8c03\u6574\uff0c\u63d0\u5347\u6d4b\u8bd5\u7075\u6d3b\u6027\u3002<\/li>\n<li><strong>\u5f00\u6e90\u4ee3\u7801\u652f\u6301<\/strong>\uff1a\u5b8c\u6574\u6e90\u7801\u5f00\u653e\uff0c\u7528\u6237\u53ef\u6839\u636e\u9700\u6c42\u4fee\u6539\u6216\u6269\u5c55\u529f\u80fd\u3002<\/li>\n<li><strong>\u793e\u533a\u6269\u5c55\u6027<\/strong>\uff1a\u652f\u6301\u7528\u6237\u63d0\u4ea4\u65b0\u4efb\u52a1\u3001\u6570\u636e\u96c6\u6216\u6a21\u578b\uff0c\u6301\u7eed\u4e30\u5bcc\u6d4b\u8bd5\u5185\u5bb9\u3002<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>\u4f7f\u7528\u5e2e\u52a9<\/h2>\n<h3>\u5b89\u88c5\u6d41\u7a0b<\/h3>\n<p>MTEB \u662f\u4e00\u4e2a\u57fa\u4e8e Python \u7684\u5de5\u5177\uff0c\u90e8\u7f72\u548c\u8fd0\u884c\u9700\u8981\u4e00\u5b9a\u7684\u7f16\u7a0b\u73af\u5883\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u7684\u5b89\u88c5\u6b65\u9aa4\uff1a<\/p>\n<h4>1. \u73af\u5883\u51c6\u5907<\/h4>\n<ul>\n<li><strong>\u64cd\u4f5c\u7cfb\u7edf<\/strong>\uff1a\u652f\u6301 Windows\u3001MacOS \u6216 Linux\u3002<\/li>\n<li><strong>Python \u7248\u672c<\/strong>\uff1a\u9700\u8981 Python 3.10 \u6216\u4ee5\u4e0a\u7248\u672c\uff0c\u53ef\u901a\u8fc7\u00a0<code>python --version<\/code>\u00a0\u68c0\u67e5\u3002<\/li>\n<li><strong>Git \u5de5\u5177<\/strong>\uff1a\u7528\u4e8e\u4ece GitHub \u83b7\u53d6\u6e90\u7801\uff0c\u5efa\u8bae\u63d0\u524d\u5b89\u88c5\u3002<\/li>\n<\/ul>\n<h4>2. \u514b\u9686\u4ee3\u7801\u5e93<\/h4>\n<p>\u6253\u5f00\u7ec8\u7aef\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u83b7\u53d6 MTEB \u6e90\u7801\uff1a<\/p>\n<pre><code>git clone https:\/\/github.com\/embeddings-benchmark\/mteb.git\r\ncd mteb\r\n<\/code><\/pre>\n<p>\u8fd9\u4f1a\u5c06\u9879\u76ee\u4e0b\u8f7d\u5230\u672c\u5730\u5e76\u8fdb\u5165\u9879\u76ee\u76ee\u5f55\u3002<\/p>\n<h4>3. \u5b89\u88c5\u4f9d\u8d56<\/h4>\n<p>MTEB \u9700\u8981\u4e00\u4e9b Python \u5e93\u652f\u6301\uff0c\u5b89\u88c5\u4f9d\u8d56\u524d\u5efa\u8bae\u521b\u5efa\u865a\u62df\u73af\u5883\u4ee5\u907f\u514d\u51b2\u7a81\uff1a<\/p>\n<pre><code>python -m venv venv\r\nsource venv\/bin\/activate  # Linux\/MacOS\r\nvenv\\Scripts\\activate     # Windows\r\n<\/code><\/pre>\n<p>\u7136\u540e\u5b89\u88c5\u6838\u5fc3\u4f9d\u8d56\uff1a<\/p>\n<pre><code>pip install -r requirements.txt\r\n<\/code><\/pre>\n<p>\u82e5\u9700\u8fd0\u884c\u6392\u884c\u699c\u754c\u9762\uff0c\u8fd8\u9700\u5b89\u88c5 Gradio\uff1a<\/p>\n<pre><code>pip install mteb[gradio]\r\n<\/code><\/pre>\n<h4>4. \u9a8c\u8bc1\u5b89\u88c5<\/h4>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5\u53ef\u7528\u4efb\u52a1\uff0c\u786e\u4fdd\u5b89\u88c5\u6210\u529f\uff1a<\/p>\n<pre><code>mteb --available_tasks\r\n<\/code><\/pre>\n<p>\u82e5\u8fd4\u56de\u4efb\u52a1\u5217\u8868\uff0c\u8bf4\u660e\u73af\u5883\u914d\u7f6e\u5b8c\u6210\u3002<\/p>\n<h3>\u4f7f\u7528\u65b9\u6cd5<\/h3>\n<p>MTEB \u7684\u6838\u5fc3\u529f\u80fd\u662f\u8bc4\u4f30\u6587\u672c\u5d4c\u5165\u6a21\u578b\uff0c\u4ee5\u4e0b\u662f\u4e3b\u8981\u64cd\u4f5c\u6d41\u7a0b\uff1a<\/p>\n<h4>\u529f\u80fd1\uff1a\u8fd0\u884c\u9884\u7f6e\u4efb\u52a1\u8bc4\u4f30\u73b0\u6709\u6a21\u578b<\/h4>\n<p>MTEB \u652f\u6301\u76f4\u63a5\u6d4b\u8bd5\u5df2\u6709\u6a21\u578b\uff08\u5982 SentenceTransformer \u6a21\u578b\uff09\u3002\u4f8b\u5982\uff0c\u8bc4\u4f30 &#8220;average_word_embeddings_komninos&#8221; \u6a21\u578b\u5728 Banking77Classification \u4efb\u52a1\u4e0a\u7684\u8868\u73b0\uff1a<\/p>\n<pre><code>mteb -m average_word_embeddings_komninos -t Banking77Classification --output_folder results\/average_word_embeddings_komninos --verbosity 3\r\n<\/code><\/pre>\n<ul>\n<li><code>-m<\/code>\u00a0\u6307\u5b9a\u6a21\u578b\u540d\u79f0\u3002<\/li>\n<li><code>-t<\/code>\u00a0\u6307\u5b9a\u4efb\u52a1\u540d\u79f0\u3002<\/li>\n<li><code>--output_folder<\/code>\u00a0\u6307\u5b9a\u7ed3\u679c\u4fdd\u5b58\u8def\u5f84\u3002<\/li>\n<li><code>--verbosity 3<\/code>\u00a0\u663e\u793a\u8be6\u7ec6\u65e5\u5fd7\u3002<\/li>\n<\/ul>\n<p>\u7ed3\u679c\u4f1a\u4fdd\u5b58\u5230\u6307\u5b9a\u6587\u4ef6\u5939\uff0c\u5305\u542b\u5404\u9879\u4efb\u52a1\u7684\u5f97\u5206\u3002<\/p>\n<h4>\u529f\u80fd2\uff1a\u6d4b\u8bd5\u81ea\u5b9a\u4e49\u6a21\u578b<\/h4>\n<p>\u82e5\u9700\u6d4b\u8bd5\u81ea\u5df1\u7684\u6a21\u578b\uff0c\u53ea\u9700\u5b9e\u73b0\u7b80\u5355\u7684\u63a5\u53e3\u3002\u4ee5 SentenceTransformer \u4e3a\u4f8b\uff1a<\/p>\n<pre><code>from mteb import MTEB\r\nfrom sentence_transformers import SentenceTransformer\r\n# \u52a0\u8f7d\u6a21\u578b\r\nmodel = SentenceTransformer(\"average_word_embeddings_komninos\")\r\n# \u5b9a\u4e49\u8bc4\u4f30\u4efb\u52a1\r\nevaluation = MTEB(tasks=[\"Banking77Classification\"])\r\n# \u8fd0\u884c\u8bc4\u4f30\r\nevaluation.run(model, output_folder=\"results\")\r\n<\/code><\/pre>\n<p>\u8fd0\u884c\u540e\uff0c\u7ed3\u679c\u4f1a\u4fdd\u5b58\u5230 &#8220;results&#8221; \u6587\u4ef6\u5939\u3002<\/p>\n<h4>\u529f\u80fd3\uff1a\u7f13\u5b58\u5d4c\u5165\u4ee5\u4f18\u5316\u6548\u7387<\/h4>\n<p>\u5bf9\u4e8e\u91cd\u590d\u6d4b\u8bd5\uff0c\u53ef\u542f\u7528\u7f13\u5b58\u529f\u80fd\uff0c\u907f\u514d\u91cd\u590d\u8ba1\u7b97\u5d4c\u5165\uff1a<\/p>\n<pre><code>from mteb.models.cache_wrapper import CachedEmbeddingWrapper\r\n# \u5305\u88c5\u6a21\u578b\u4ee5\u542f\u7528\u7f13\u5b58\r\nmodel_with_cache = CachedEmbeddingWrapper(model, cache_path=\"cache_embeddings\")\r\nevaluation.run(model_with_cache)\r\n<\/code><\/pre>\n<p>\u7f13\u5b58\u6587\u4ef6\u4f1a\u6309\u4efb\u52a1\u540d\u79f0\u5b58\u50a8\u5728\u6307\u5b9a\u8def\u5f84\u3002<\/p>\n<h4>\u529f\u80fd4\uff1a\u67e5\u770b\u6392\u884c\u699c<\/h4>\n<p>\u82e5\u60f3\u67e5\u770b\u5f53\u524d\u6a21\u578b\u6392\u540d\uff0c\u53ef\u8bbf\u95ee\u5b98\u65b9\u6392\u884c\u699c\uff0c\u6216\u672c\u5730\u90e8\u7f72\uff1a<\/p>\n<pre><code>git clone https:\/\/github.com\/embeddings-benchmark\/leaderboard.git\r\ncd leaderboard\r\npip install -r requirements.txt\r\npython app.py\r\n<\/code><\/pre>\n<p>\u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95ee\u00a0<code>http:\/\/localhost:7860<\/code>\uff0c\u5373\u53ef\u67e5\u770b\u5b9e\u65f6\u6392\u884c\u699c\u3002<\/p>\n<h4>\u529f\u80fd5\uff1a\u6dfb\u52a0\u65b0\u4efb\u52a1<\/h4>\n<p>\u7528\u6237\u53ef\u901a\u8fc7\u7ee7\u627f\u4efb\u52a1\u7c7b\u6269\u5c55 MTEB\u3002\u4f8b\u5982\uff0c\u6dfb\u52a0\u4e00\u4e2a reranking \u4efb\u52a1\uff1a<\/p>\n<pre><code>from mteb.abstasks.AbsTaskReranking import AbsTaskReranking\r\nclass CustomReranking(AbsTaskReranking):\r\n    @property\r\ndef description(self):\r\nreturn {\r\n\"name\": \"CustomReranking\",\r\n\"description\": \"\u81ea\u5b9a\u4e49\u91cd\u6392\u5e8f\u4efb\u52a1\",\r\n\"type\": \"Reranking\",\r\n\"eval_splits\": [\"test\"],\r\n\"eval_langs\": [\"en\"],\r\n\"main_score\": \"map\"\r\n}\r\nevaluation = MTEB(tasks=[CustomReranking()])\r\nevaluation.run(model)\r\n<\/code><\/pre>\n<h3>\u64cd\u4f5c\u6280\u5de7<\/h3>\n<ul>\n<li><strong>\u591aGPU\u652f\u6301<\/strong>\uff1a\u5bf9\u4e8e\u68c0\u7d22\u4efb\u52a1\uff0c\u53ef\u4f7f\u7528\u591aGPU\u52a0\u901f\uff1a<\/li>\n<\/ul>\n<pre><code>pip install git+https:\/\/github.com\/NouamaneTazi\/beir@nouamane\/better-multi-gpu\r\ntorchrun --nproc_per_node=2 scripts\/retrieval_multigpu.py\r\n<\/code><\/pre>\n<ul>\n<li><strong>\u9009\u62e9\u5b50\u96c6<\/strong>\uff1a\u53ea\u8bc4\u4f30\u7279\u5b9a\u4efb\u52a1\u5b50\u96c6\uff1a<\/li>\n<\/ul>\n<pre><code>evaluation.run(model, eval_subsets=[\"Banking77Classification\"])\r\n<\/code><\/pre>\n<ul>\n<li><strong>\u8c03\u6574\u6279\u91cf\u5927\u5c0f<\/strong>\uff1a\u4f18\u5316\u7f16\u7801\u901f\u5ea6\uff1a<\/li>\n<\/ul>\n<pre><code>evaluation.run(model, encode_kwargs={\"batch_size\": 32})\r\n<\/code><\/pre>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u7528\u6237\u53ef\u4ee5\u8f7b\u677e\u4e0a\u624b MTEB\uff0c\u5b8c\u6210\u6a21\u578b\u8bc4\u4f30\u6216\u529f\u80fd\u6269\u5c55\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MTEB\uff08Massive Text Embedding Benchmark\uff09\u662f\u4e00\u4e2a\u7531 embeddings-benchmark \u56e2\u961f\u5f00\u53d1\u5e76\u6258\u7ba1\u5728 GitHub \u4e0a\u7684\u5f00\u6e90\u9879\u76ee\uff0c\u65e8\u5728\u4e3a\u6587\u672c\u5d4c\u5165\u6a21\u578b\u63d0\u4f9b\u5168\u9762\u7684\u6027\u80fd\u8bc4\u4f30\u3002\u5b83\u6db5\u76d6\u4e868\u5927\u4efb\u52a1\u7c7b\u578b\uff0c\u5305\u62ec\u5206&#8230;<\/p>\n","protected":false},"author":1,"featured_media":61956,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[230],"class_list":["post-27430","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tool","tag-aikaiyuanxiangmu"],"_links":{"self":[{"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/posts\/27430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/comments?post=27430"}],"version-history":[{"count":0,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/posts\/27430\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/media\/61956"}],"wp:attachment":[{"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/media?parent=27430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/categories?post=27430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/tags?post=27430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}