# BAAI/bge-reranker-v2-m3

**BAAI/bge-reranker-v2-m3** is a multilingual reranker model with 568 million parameters. It reads a query and a set of texts, and returns a relevance score for each text against that query. [AI Inference](/en/documentation/platform/ai-inference/) runs it under the id `baai-bge-reranker-v2-m3`.

## Model details

The model id is the string a call passes to select this model. The HuggingFace repository holds the model card.

| Detail            | Value                                                                     |
| ----------------- | ------------------------------------------------------------------------- |
| Model name        | BAAI/bge-reranker-v2-m3                                                   |
| Version           | Original                                                                  |
| Model category    | Reranker                                                                  |
| Model id          | `baai-bge-reranker-v2-m3`                                                 |
| Size              | 568M parameters                                                           |
| HuggingFace model | [BAAI/bge-reranker-v2-m3](https://huggingface.co/BAAI/bge-reranker-v2-m3) |
| License           | [Apache 2.0](https://choosealicense.com/licenses/apache-2.0/)             |

## Capabilities

These values describe the model itself and are not fields of the request body. For the fields a reranking request carries, and their types, refer to [Model invocation](/en/documentation/platform/ai-inference/model-invocation/).

| Capability     | Value     |
| -------------- | --------- |
| Input data     | Text      |
| Context length | 8k tokens |
| Supports LoRA  | No        |

---

## Usage

A [function](/en/documentation/platform/functions/) calls the model with `Azion.AI.run`, passing the id as the first argument and the request body as the second. This model takes no `messages` array: each of the two operations below has its own body. To send the same body over HTTP instead, refer to [Model invocation](/en/documentation/platform/ai-inference/model-invocation/).

### Reranking

A reranking request carries the `query` and the `documents` to rank against it:

```ts
const modelResponse = await Azion.AI.run("baai-bge-reranker-v2-m3", {
  "query": "What is deep learning?",
  "documents": [
    "Deep learning is a subset of machine learning that uses neural networks with many layers",
    "The weather is nice today",
    "Deep learning enables computers to learn from large amounts of data",
    "I like pizza"
  ]
})
```

The model returns a `results` array ordered from the highest `relevance_score` to the lowest, one entry per document, each carrying the position the document held in the request and its text:

```json
{
  "id": "rerank-0123456789abcdef0123456789abcdef",
  "model": "baai-bge-reranker-v2-m3",
  "usage": {
    "total_tokens": 78
  },
  "results": [
    {
      "index": 0,
      "document": {
        "text": "Deep learning is a subset of machine learning that uses neural networks with many layers"
      },
      "relevance_score": 0.99951171875
    },
    {
      "index": 2,
      "document": {
        "text": "Deep learning enables computers to learn from large amounts of data"
      },
      "relevance_score": 0.98291015625
    },
    {
      "index": 3,
      "document": {
        "text": "I like pizza"
      },
      "relevance_score": 0.00001621246337890625
    },
    {
      "index": 1,
      "document": {
        "text": "The weather is nice today"
      },
      "relevance_score": 0.000016033649444580078
    }
  ]
}
```

### Scoring

A scoring request carries `text_1` and the `text_2` array the model scores against it:

```ts
const modelResponse = await Azion.AI.run("baai-bge-reranker-v2-m3", {
  "text_1": "What is deep learning?",
  "text_2": [
    "Deep learning is a subset of machine learning that uses neural networks with many layers",
    "The weather is nice today",
    "Deep learning enables computers to learn from large amounts of data",
    "I like pizza"
  ]
})
```

The response carries the same `results` array, with one entry and one `relevance_score` for every text in `text_2`.

---

## Related resources

- [Model invocation](/en/documentation/platform/ai-inference/model-invocation.md): Every field a reranking request accepts, and the HTTP endpoint that takes the same body.
- [AI models](/en/documentation/platform/ai-inference/models.md): The other models AI Inference runs, and the id each one answers to.
- [AI Inference](/en/documentation/platform/ai-inference.md): The product that runs this model.
- [Functions](/en/documentation/platform/functions.md): The product whose runtime holds the binding the examples on this page call.
- [AI Inference limits](/en/documentation/platform/ai-inference/limits.md): The conditions under which Azion terminates or deprovisions a model.
- [Glossary](/en/documentation/platform/ai-inference/glossary.md): Where model id, context length, and the rest of the AI Inference vocabulary are defined.
