HNSWIndex 1.3.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package HNSWIndex --version 1.3.0
NuGet\Install-Package HNSWIndex -Version 1.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HNSWIndex" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HNSWIndex" Version="1.3.0" />
<PackageReference Include="HNSWIndex" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add HNSWIndex --version 1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: HNSWIndex, 1.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=HNSWIndex&version=1.3.0
#tool nuget:?package=HNSWIndex&version=1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
HNSWIndex
Perform KNN Query for millions of data points fast and with great accuracy.
HNSWIndex is a .NET library for constructing approximate nearest-neighbor (ANN) indices based on the Hierarchical Navigable Small World (HNSW) graph. This data structure provides efficient similarity searches for large, high-dimensional datasets.
Key Features
- High Performance: Implements the HNSW algorithm for fast approximate k-NN search.
- Flexible Distance Metric: Pass any
Func<TLabel, TLabel, TDistance>
for custom distance calculation. - Flexible Heuristic: Pass heuristic function for nodes linking.
- Concurrency Support: Thread safe graph building API
- Configurable Parameters: Fine-tune the indexing performance and memory trade-offs with parameters
- Save and Load: Save resulting structure on file system and restore later
Installation
Install via NuGet:
dotnet add package HNSWIndex
Or inside your .csproj:
<PackageReference Include="HNSWIndex" Version="x.x.x" />
Getting Started
1. Optionally configure parameters
var parameters = new HNSWParameters
{
RandomSeed = 123,
DistributionRate = 1.0,
MaxEdges = 16,
CollectionSize = 1024,
// ... other parameters
};
2. Create empty graph structure ()
var index = new HNSWIndex<float[], float>(Metrics.SquaredEuclideanMetric.Compute);
3. Build the graph
var vectors = RandomVectors();
foreach (var vector in vectors)
{
index.Add(vector)
}
Or multi-threaded
var vectors = RandomVectors();
Parallel.For(0, vectors.Count, i => {
index.Add(vectors[i]);
});
4. Query the structure
var k = 5;
var results = index.KnnQuery(queryPoint, k);
5. Save and Load graph from file system
index.Serialize(pathToFile);
var index = HNSWIndex<float[], float>.Deserialize(Metrics.SquaredEuclideanMetric.Compute, pathToFile);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- protobuf-net (>= 3.2.52)
-
net9.0
- protobuf-net (>= 3.2.52)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.