Core hnsw library.
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());
}