File size: 1,310 Bytes
844447b
78efc3f
 
 
 
844447b
 
78efc3f
844447b
 
78efc3f
 
 
 
 
 
 
 
 
 
23fb416
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
---
title: ChatFed Re-Ranker Service
emoji: 🤖
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
license: mit
---

# ReRanker Module

This is an LLM-based generation service designed to be deployed as a modular component of a broader RAG system. The service runs on a docker container and exposes a gradio UI on port 7860 as well as an MCP endpoint.

## Configuration

1. The module requires an API key (set as an environment variable) for a model provider to run. Make sure to set the appropriate environment variables:
- HuggingFace: `HF_TOKEN` 

2. Inference provider and model settings are accessible via params.cfg

## MCP Endpoint

### Available Tools

#### `rerank_context`

Re-ranks a list of context dicts (each with 'page_content' & 'metadata') using a cross-encoder and returns the top_n sorted results.

**Input Schema:**

| Parameter | Type | Description |
|-----------|------|-------------|
| `query` | string | The search query to rank contexts against |
| `contexts` | string | List of context dictionaries to be re-ranked |

**Example Usage:**

```json
{
  "query": "your search query here",
  "contexts": "your context data here"
}
```

---

*This tool uses a cross-encoder model to improve the relevance ranking of retrieved contexts based on their similarity to the input query.*