Skip to content

Add NVQ example#663

Open
ashkrisk wants to merge 2 commits intomainfrom
nvq-tut
Open

Add NVQ example#663
ashkrisk wants to merge 2 commits intomainfrom
nvq-tut

Conversation

@ashkrisk
Copy link
Copy Markdown
Contributor

@ashkrisk ashkrisk commented May 6, 2026

Adds an example showing re-ranking using NVQ.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Before you submit for review:

  • Does your PR follow guidelines from CONTRIBUTIONS.md?
  • Did you summarize what this PR does clearly and concisely?
  • Did you include performance data for changes which may be performance impacting?
  • Did you include useful docs for any user-facing changes or features?
  • Did you include useful javadocs for developer oriented changes, explaining new concepts or key changes?
  • Did you trigger and review regression testing results against the base branch via Run Bench Main?
  • Did you adhere to the code formatting guidelines (TBD)
  • Did you group your changes for easy review, providing meaningful descriptions for each commit?
  • Did you ensure that all files contain the correct copyright header?

If you did not complete any of these, then please explain below.

Copy link
Copy Markdown
Contributor

@r-devulap r-devulap left a comment

Choose a reason for hiding this comment

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

Nice tutorial! It currently crashes and needs a small fix to create the directory ./local directory.

var pqv = new MutablePQVectors(pq);
var bsp = BuildScoreProvider.pqBuildScoreProvider(vsf, pqv);

var graphPath = Path.of("./local/tmp.jvgraph");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Running this locally gives me this error:

ada002-100k: 99287 base and 10000 query vectors created, dimensions 1536
Building graph in streaming mode...
Exception in thread "main" java.io.FileNotFoundException: ./local/tmp.jvgraph (No such file or directory)
        at java.base/java.io.RandomAccessFile.open0(Native Method)
        at java.base/java.io.RandomAccessFile.open(RandomAccessFile.java:338)
        at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:257)
        at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:211)
        at io.github.jbellis.jvector.disk.BufferedRandomAccessWriter.<init>(BufferedRandomAccessWriter.java:44)
        at io.github.jbellis.jvector.graph.disk.OnDiskGraphIndexWriter$Builder.<init>(OnDiskGraphIndexWriter.java:161)
        at io.github.jbellis.jvector.example.tutorial.NvqExample.main(NvqExample.java:98)
        at io.github.jbellis.jvector.example.tutorial.TutorialRunner.main(TutorialRunner.java:42)
04:41:20,963 [ERROR] Command execution failed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah right, I entirely overlooked the need to create a local directory. I changed it to use a temporary file instead, matching the other tutorial.

var pqv = new MutablePQVectors(pq);
var bsp = BuildScoreProvider.pqBuildScoreProvider(vsf, pqv);

var graphPath = Path.of("./local/tmp.jvgraph");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might want to add

Suggested change
var graphPath = Path.of("./local/tmp.jvgraph");
var graphPath = Path.of("./local/tmp.jvgraph");
Files.createDirectories(graphPath.getParent());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The change to a temporary file should take care of it

} catch (IOException e) {
throw new UncheckedIOException(e);
}
pb.step();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice, love the progress bar! would be nice to add this to BenchYAML. I am assuming its thread safe?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ashkrisk ashkrisk requested a review from r-devulap May 7, 2026 11:39
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