Content-Length: 322183 | pFad | http://github.com/postgresml/postgresml/commit/71219aa80a64e94e9246a2df0a433e68687b8ef0

A8 Added pgml.rank docs (#1514) · postgresml/postgresml@71219aa · GitHub
Skip to content

Commit 71219aa

Browse files
SilasMarvinlevkk
andauthored
Added pgml.rank docs (#1514)
Co-authored-by: Lev Kokotov <levkk@users.noreply.github.com>
1 parent 6a804ba commit 71219aa

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
description: Rank documents against a piece of text using the specified ranking model.
3+
---
4+
5+
# pgml.rank()
6+
7+
The `pgml.rank()` function is used to compute a relevance score between documents and some text. This function is primarily used as the last step in a search system where the results returned from the initial search are re-ranked by relevance before being used.
8+
9+
## API
10+
11+
```postgresql
12+
pgml.rank(
13+
transformer TEXT, -- transformer name
14+
query TEXT, -- text to rank against
15+
documents TEXT[], -- documents to rank
16+
kwargs JSON -- optional arguments (see below)
17+
)
18+
```
19+
20+
## Example
21+
22+
Ranking documents is as simple as calling the the function with the documents you want to rank, and text you want to rank against:
23+
24+
```postgresql
25+
SELECT pgml.rank('mixedbread-ai/mxbai-rerank-base-v1', 'test', ARRAY['doc1', 'doc2']);
26+
```
27+
28+
By default the `pgml.rank()` function will return and rank all of the documents. The function can be configured to only return the relevance score and index of the top k documents by setting `return_documents` to `false` and `top_k` to the number of documents you want returned.
29+
30+
```postgresql
31+
SELECT pgml.rank('mixedbread-ai/mxbai-rerank-base-v1', 'test', ARRAY['doc1', 'doc2'], '{"return_documents": false, "top_k": 10}'::JSONB);
32+
```
33+
34+
## Supported ranking models
35+
36+
We currently support cross-encoders for re-ranking. Check out [Sentence Transformer's documentation](https://sbert.net/examples/applications/cross-encoder/README.html) for more information on how cross-encoders work.
37+
38+
By default we provide the following ranking models:
39+
40+
* `mixedbread-ai/mxbai-rerank-base-v1`

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgresml/postgresml/commit/71219aa80a64e94e9246a2df0a433e68687b8ef0

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy