{ "cells": [ { "cell_type": "markdown", "id": "366980e6", "metadata": {}, "source": [ "# Cross-Encoder for MS Marco\n" ] }, { "cell_type": "markdown", "id": "4c7d726e", "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": "1535e90f", "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": "3eda3140", "metadata": {}, "source": [ "## How to use\n" ] }, { "cell_type": "code", "execution_count": null, "id": "74d5bcd7", "metadata": {}, "outputs": [], "source": [ "!pip install --upgrade paddlenlp" ] }, { "cell_type": "code", "execution_count": null, "id": "59553cde", "metadata": {}, "outputs": [], "source": [ "import paddle\n", "from paddlenlp.transformers import AutoModel\n", "\n", "model = AutoModel.from_pretrained(\"cross-encoder/ms-marco-MiniLM-L-12-v2\")\n", "input_ids = paddle.randint(100, 200, shape=[1, 20])\n", "print(model(input_ids))" ] }, { "cell_type": "markdown", "id": "0b6883fa", "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": "e04ad9db", "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": "18e7124d", "metadata": {}, "source": [ "Note: Runtime was computed on a V100 GPU.\n", "> The model introduction and model weights originate from [https://huggingface.co/cross-encoder/ms-marco-MiniLM-L-12-v2](https://huggingface.co/cross-encoder/ms-marco-MiniLM-L-12-v2) and were converted to PaddlePaddle format for ease of use in PaddleNLP.\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.13" } }, "nbformat": 4, "nbformat_minor": 5 }