# BAAI/bge-reranker-v2-m3

**BAAI/bge-reranker-v2-m3** is a lightweight reranker model with strong multilingual capabilities. It's easy to deploy and offers fast inference.

## Model details

| Category | Details |
|----------|---------|
| **Model Name** | BAAI/bge-reranker-v2-m3 |
| **Version** | Original |
| **Model Category** | Reranker |
| **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

| Feature | Details |
|---------|--------|
| Context Length | 8k tokens |
| Supports LoRA | ❌ |
| Input data | Text |

## Usage 

### Rerank example

This is an example of a basic rerank request using this model:

```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"
  ]
})
```

| Property | Type | Description |
|------------|------|-------------|
| `query` | string | The search query or prompt to rank the documents against. |
| `documents` | string[] | An array of documents to be ranked based on their relevance to the query. |

### Score example

This is an example of a basic score request using this model:

```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"
  ]
})
```

| Property | Type | Description |
|------------|------|-------------|
| `text_1` | string | The first text input for the model to process. |
| `text_2` | string[] | An array of text inputs for the model to process and give a score. |

Response example:

```json
{
  "id": "rerank-356bf11f0e794f3c8f726bec7ba698bb",
  "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
    }
  ]
}
```

| Property                   | Type   | Description                                                |
| --------------------------- | ------ | ---------------------------------------------------------- |
| `id`                        | string | Unique identifier for the rerank request.                |
| `model`                     | string | The name of the model used for reranking.                  |
| `usage.total_tokens`        | number | The total number of tokens used in the request.            |
| `results[]`                   | object[] | An array of reranked result objects.                       |
| `results[].index`           | number | The index of the document in the input list.               |
| `results[].document`        | object | The document object containing the text.                   |
| `results[].document.text`   | string | The textual content of the document.                       |
| `results[].relevance_score` | number | The relevance score assigned to the document by the model. |


## JSON schema

```json
{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "required": [
        "query",
        "documents"
    ],
    "properties": {
        "query": {
            "type": "string"
        },
        "documents": {
            "type": "array",
            "items": {
                "type": "string"
            }
        },
        "top_n": {
            "type": "integer"
        },
        "max_tokens_per_doc": {
            "type": "integer"
        }
    }
}
```