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

Add nearest neighbors support #1182

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Add nearest neighbors support #1182

wants to merge 7 commits into from

Conversation

mvanschellebeeck
Copy link

@mvanschellebeeck mvanschellebeeck commented Feb 6, 2025

Add nearestNeighbor query support.

See runNearestNeighborsTest.ts for example usage

@ssanjay1 ssanjay1 closed this Feb 6, 2025
@ssanjay1 ssanjay1 reopened this Feb 6, 2025
@ssanjay1 ssanjay1 marked this pull request as ready for review February 6, 2025 17:04
@ssanjay1 ssanjay1 closed this Feb 6, 2025
@ssanjay1 ssanjay1 reopened this Feb 6, 2025
@mvanschellebeeck mvanschellebeeck marked this pull request as draft February 6, 2025 17:28
@mvanschellebeeck mvanschellebeeck marked this pull request as ready for review February 6, 2025 20:46
| {
[K in L]?: "asc" | "desc";
}
| "relevance";
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not sort by ascending or descending relevance as well?

Copy link
Author

Choose a reason for hiding this comment

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

Nope.
By default, nearest neighbors returns objects with the highest scores first, so sorting by relevance is equivalent to sorting by score in descending order.

* @param query - Queries support either a vector matching the embedding model defined on the property, or text that is
automatically embedded.
* @param numNeighbors - The number of objects to return. If the number of documents in the objectType is less than the provided
value, all objects will be returned. This value is limited to 1 ≤ numNeighbors ≥ 500.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'm not actually sure how &le will render, does throwing in < not work?

Copy link
Author

@mvanschellebeeck mvanschellebeeck Feb 10, 2025

Choose a reason for hiding this comment

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

Yeah, when I used <, the markdown would show:

 // Warning: (tsdoc-malformed-html-name) Invalid HTML element: Expecting an HTML name

@@ -235,318 +235,28 @@ exports[`Load Ontologies Metadata > Loads action types with media refs, interfac
This is some more text.",
"rid": "rid",
},
"startDate": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm why this large diff in the snapshots?

@@ -147,6 +147,65 @@ describe("ObjectSet", () => {
expect(iter).toEqual(2);
});

it("nearest neighbors object set", async () => {
const numNeighbors = 3;
const nearestNeighborsObjectSet = client(Employee).nearestNeighbors(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add some type tests in here to make sure the type of the call signature is what we expect?

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