Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated knn #1626

Merged
merged 3 commits into from
Aug 8, 2024
Merged

Updated knn #1626

merged 3 commits into from
Aug 8, 2024

Conversation

writinwaters
Copy link
Contributor

What problem does this PR solve?

Issue link:#1490

Type of change

  • Documentation Update

@writinwaters writinwaters requested a review from JinHai-CN August 8, 2024 13:10
Specifies the data type of the embedding vector. Commonly used types (values) include:

- `"float"`
- `"int"`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int=>uint8

table_obj.knn('col1', [0.1,0.2,0.3], 'float', 'l2', 100)
```

```python
ef = 100
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

erase

# Find the 2 nearest neighbors using inner product distance
table_obj.knn('vec', [3.0] * 5, 'float', 'ip', 2)
# If you use HNSW index, you can set ef in knn_params
table_obj.knn('vec', [3.0] * 5, 'float', 'ip', 2, {"ef": str(ef)})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[3.0] * 5=> [0.1, 0.2, 0.3]

# Find the 2 nearest neighbors using inner product distance
table_obj.knn('vec', [3.0] * 5, 'float', 'ip', 2)
# If you use HNSW index, you can set ef in knn_params
table_obj.knn('vec', [3.0] * 5, 'float', 'ip', 2, {"ef": str(ef)})
```

Copy link
Contributor

@JinHai-CN JinHai-CN Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add one more example:
table_obj.knn('vec', [1, 2, 3], 'uint8', 'cosine', 2, {"ef": "100"})

@JinHai-CN JinHai-CN merged commit 580a5d4 into infiniflow:main Aug 8, 2024
1 check was pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants