{ "cells": [ { "cell_type": "markdown", "id": "32947f83", "metadata": {}, "source": [ "# Cross-Encoder for MS Marco\n" ] }, { "cell_type": "markdown", "id": "d34eaa08", "metadata": {}, "source": [ "This model was trained on the [MS Marco Passage Ranking](https://github.com/microsoft/MSMARCO-Passage-Ranking) task.\n" ] }, { "cell_type": "markdown", "id": "dcf2e434", "metadata": {}, "source": [ "The model can be used for Information Retrieval: Given a query, encode the query will all possible passages (e.g. retrieved with ElasticSearch). Then sort the passages in a decreasing order. See [SBERT.net Retrieve & Re-rank](https://www.sbert.net/examples/applications/retrieve_rerank/README.html) for more details. The training code is available here: [SBERT.net Training MS Marco](https://github.com/UKPLab/sentence-transformers/tree/master/examples/training/ms_marco)\n" ] }, { "cell_type": "markdown", "id": "bb938635", "metadata": {}, "source": [ "## How to use\n" ] }, { "cell_type": "code", "execution_count": null, "id": "463fcbb2", "metadata": {}, "outputs": [], "source": [ "!pip install --upgrade paddlenlp" ] }, { "cell_type": "code", "execution_count": null, "id": "e3ac7704", "metadata": {}, "outputs": [], "source": [ "import paddle\n", "from paddlenlp.transformers import BertModel\n", "\n", "model = BertModel.from_pretrained(\"cross-encoder/ms-marco-TinyBERT-L-2\")\n", "input_ids = paddle.randint(100, 200, shape=[1, 20])\n", "print(model(input_ids))" ] }, { "cell_type": "markdown", "id": "e185e8d7", "metadata": {}, "source": [ "## Performance\n", "In the following table, we provide various pre-trained Cross-Encoders together with their performance on the [TREC Deep Learning 2019](https://microsoft.github.io/TREC-2019-Deep-Learning/) and the [MS Marco Passage Reranking](https://github.com/microsoft/MSMARCO-Passage-Ranking/) dataset.\n" ] }, { "cell_type": "markdown", "id": "1b6ce4a0", "metadata": {}, "source": [ "| Model-Name | NDCG@10 (TREC DL 19) | MRR@10 (MS Marco Dev) | Docs / Sec |\n", "| ------------- |:-------------| -----| --- |\n", "| **Version 2 models** | | |\n", "| cross-encoder/ms-marco-TinyBERT-L-2-v2 | 69.84 | 32.56 | 9000\n", "| cross-encoder/ms-marco-MiniLM-L-2-v2 | 71.01 | 34.85 | 4100\n", "| cross-encoder/ms-marco-MiniLM-L-4-v2 | 73.04 | 37.70 | 2500\n", "| cross-encoder/ms-marco-MiniLM-L-6-v2 | 74.30 | 39.01 | 1800\n", "| cross-encoder/ms-marco-MiniLM-L-12-v2 | 74.31 | 39.02 | 960\n", "| **Version 1 models** | | |\n", "| cross-encoder/ms-marco-TinyBERT-L-2 | 67.43 | 30.15 | 9000\n", "| cross-encoder/ms-marco-TinyBERT-L-4 | 68.09 | 34.50 | 2900\n", "| cross-encoder/ms-marco-TinyBERT-L-6 | 69.57 | 36.13 | 680\n", "| cross-encoder/ms-marco-electra-base | 71.99 | 36.41 | 340\n", "| **Other models** | | |\n", "| nboost/pt-tinybert-msmarco | 63.63 | 28.80 | 2900\n", "| nboost/pt-bert-base-uncased-msmarco | 70.94 | 34.75 | 340\n", "| nboost/pt-bert-large-msmarco | 73.36 | 36.48 | 100\n", "| Capreolus/electra-base-msmarco | 71.23 | 36.89 | 340\n", "| amberoad/bert-multilingual-passage-reranking-msmarco | 68.40 | 35.54 | 330\n", "| sebastian-hofstaetter/distilbert-cat-margin_mse-T2-msmarco | 72.82 | 37.88 | 720\n" ] }, { "cell_type": "markdown", "id": "478f9bd9", "metadata": {}, "source": [ "Note: Runtime was computed on a V100 GPU.\n", "> 此模型介绍及权重来源于[https://huggingface.co/cross-encoder/ms-marco-TinyBERT-L-2](https://huggingface.co/cross-encoder/ms-marco-TinyBERT-L-2),并转换为飞桨模型格式。\n" ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }