Skip to content

Latest commit

 

History

History

hnswlib-core

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Maven Central Javadoc

hnswlib-core

Core hnsw library.

Example usage

import com.github.jelmerk.knn.*;
import com.github.jelmerk.knn.hnsw.*;

HnswIndex<String, float[], Word, Float> index = HnswIndex
    .newBuilder(DistanceFunctions.FLOAT_COSINE_DISTANCE, dimensions, words.size())
        .withM(10)
        .build();

index.addAll(words);

List<SearchResult<Word, Float>> nearest = index.findNeighbors("king", 10);

for (SearchResult<Word, Float> result : nearest) {
    System.out.println(result.item().id() + " " + result.getDistance());
}