Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Updated docs#1542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
SilasMarvin merged 3 commits intomasterfromsilas-update-docs
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletionspgml-cms/docs/api/client-sdk/search.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -641,3 +641,119 @@ char **results = pgml_collectionc_vector_search(collection, "{\
{% endtabs %}

The above query would filter out all documents that do not have a key `special` with a value `True` or (have a key `user_id` equal to 1 and a key `user_score` less than 100).

## **Re-ranking**

Vector search results can be reranked in the same query they are retrieved in. To enable this, provide the `rerank` key.

{% tabs %}
{% tab title="JavaScript" %}
```javascript
const results = await collection.vector_search(
{
query: {
fields: {
body: {
query: "What is the best database?", parameters: {
prompt:
"Represent this sentence for searching relevant passages: ",
}
},
},
},
rerank: {
model: "mixedbread-ai/mxbai-rerank-base-v1",
query: "What is the best database?",
num_documents_to_rerank: 100,
},
limit: 5,
},
pipeline,
);
```
{% endtab %}

{% tab title="Python" %}
```python
results = await collection.vector_search(
{
"query": {
"fields": {
"body": {
"query": "What is the best database?",
"parameters": {
"prompt": "Represent this sentence for searching relevant passages: ",
},
},
},
},
"rerank": {
"model": "mixedbread-ai/mxbai-rerank-base-v1",
"query": "What is the best database",
"num_documents_to_rerank": 100,
},
"limit": 5,
},
pipeline,
)
```
{% endtab %}

{% tab title="Rust" %}
```rust
let results = collection
.vector_search(
serde_json::json!({
"query": {
"fields": {
"body": {
"query": "What is the best database?",
"parameters": {
"prompt": "Represent this sentence for searching relevant passages: ",
},
},
},
},
"rerank": {
"model": "mixedbread-ai/mxbai-rerank-base-v1",
"query": "What is the best database",
"num_documents_to_rerank": 100,
},
"limit": 5,
})
.into(),
&mut pipeline,
)
.await?;
```
{% endtab %}

{% tab title="C" %}
```cpp
r_size = 0;
char **results = pgml_collectionc_vector_search(collection, "{\
\"query\": {\
\"fields\": {\
\"body\": {\
\"query\": \"What is the best database?\",\
\"parameters\": {\
\"prompt\": \"Represent this sentence for searching relevant passages: \"\
}\
}\
}\
},\
\"rerank\": {\
\"model\": \"mixedbread-ai/mxbai-rerank-base-v1\",\
\"query\": \"What is the best database\",\
\"num_documents_to_rerank\": 100\
},\
\"limit\": 5\
}",
pipeline, &r_size);
```
{% endtab %}
{% endtabs %}

This query will first get the top 100 documents from the initial vector search and then rerank them using the `mixedbread-ai/mxbai-rerank-base-v1` cross-encoder.

You can specify the number of documents to rerank with the `num_documents_to_rerank` parameter. The query returns the top `limit` results after re-ranking.
Loading

[8]ページ先頭

©2009-2025 Movatter.jp