Vorcyc.Quiver
1.0.1
See the version list below for details.
dotnet add package Vorcyc.Quiver --version 1.0.1
NuGet\Install-Package Vorcyc.Quiver -Version 1.0.1
<PackageReference Include="Vorcyc.Quiver" Version="1.0.1" />
<PackageVersion Include="Vorcyc.Quiver" Version="1.0.1" />
<PackageReference Include="Vorcyc.Quiver" />
paket add Vorcyc.Quiver --version 1.0.1
#r "nuget: Vorcyc.Quiver, 1.0.1"
#:package Vorcyc.Quiver@1.0.1
#addin nuget:?package=Vorcyc.Quiver&version=1.0.1
#tool nuget:?package=Vorcyc.Quiver&version=1.0.1
Vorcy Quiver 1.0
A pure .NET embedded vector database โ zero native dependencies, runs in-process, no standalone database server deployment required.
๐ Github Repo (full documention)
Quiver draws on EF Core's DbContext design pattern, allowing developers to define entities and indexing strategies through declarative attributes such as [QuiverKey], [QuiverVector], and [QuiverIndex], with the framework automatically completing model discovery, index construction, and persistence management at runtime.
โจ Core Features
- Code-First Declarative Modeling โ Annotate entity classes with attributes; the framework auto-discovers and registers
QuiverSet<T>collections via reflection โ zero configuration. - Multiple ANN Index Algorithms โ Built-in Flat (brute-force), HNSW, IVF, and KDTree indexes, covering small-scale exact search to million-scale approximate search.
- Flexible Persistence โ JSON (readable), XML (compatible), Binary (high-performance) formats, plus WAL incremental persistence reducing complexity from O(N) to O(ฮ).
- Concurrency Safe โ
QuiverSet<T>usesReaderWriterLockSliminternally; concurrent reads and writes are safe out-of-the-box. - SIMD Accelerated โ
TensorPrimitives-based SIMD for vector similarity and L2 normalization.
Typical Use Cases: Semantic search ยท RAG ยท Face recognition ยท Image-to-image search ยท Recommendation systems ยท Multimodal retrieval
๐ Quick Start
1. Define Entity
using Vorcyc.Quiver;
public class Document
{
[QuiverKey]
public string Id { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public string Category { get; set; } = string.Empty;
[QuiverVector(384, DistanceMetric.Cosine)]
public float[] Embedding { get; set; } = [];
}
2. Define Database Context
public class MyDocumentDb : QuiverDbContext
{
public QuiverSet<Document> Documents { get; set; } = null!;
public MyDocumentDb() : base(new QuiverDbOptions
{
DatabasePath = "documents.json",
StorageFormat = StorageFormat.Json,
DefaultMetric = DistanceMetric.Cosine
})
{ }
}
3. Use It
await using var db = new MyDocumentDb();
await db.LoadAsync();
// Add
db.Documents.Add(new Document
{
Id = "doc-001",
Title = "Introduction to Vector Databases",
Category = "Tutorial",
Embedding = new float[384] // embedding vector from your model
});
// Search Top-5
float[] queryVector = new float[384];
var results = db.Documents.Search(e => e.Embedding, queryVector, topK: 5);
foreach (var r in results)
Console.WriteLine($"{r.Entity.Title} โ {r.Similarity:F4}");
// Auto-saved on DisposeAsync
๐ Distance Metrics
| Metric | Range | Use Case |
|---|---|---|
Cosine |
[-1, 1] | Text embeddings, semantic search |
Euclidean |
(0, 1] | Spatial coordinates, physical distances |
DotProduct |
$(-\infty, +\infty)$ | Pre-normalized vectors, MIPS |
๐๏ธ Index Types
| Index | Search Speed | Accuracy | Best For |
|---|---|---|---|
| Flat | O(nรd) | 100% | < 10K entries, exact search |
| HNSW | O(log n) | ~95-99%+ | 10Kโ10M, universal preferred |
| IVF | O(n/kรd) | ~90-99% | 100K+, high throughput |
| KDTree | O(log n) | 100% | < 10K, dimensions < 20 |
// HNSW example
[QuiverVector(768, DistanceMetric.Cosine)]
[QuiverIndex(VectorIndexType.HNSW, M = 32, EfConstruction = 300, EfSearch = 100)]
public float[] Embedding { get; set; } = [];
// IVF example
[QuiverVector(128, DistanceMetric.Cosine)]
[QuiverIndex(VectorIndexType.IVF, NumClusters = 100, NumProbes = 15)]
public float[] Feature { get; set; } = [];
๐ง CRUD Operations
// Add
db.Documents.Add(entity);
db.Documents.AddRange(batch); // Atomic two-phase commit
await db.Documents.AddRangeAsync(batch);
// Upsert (insert or update, single write lock)
db.Documents.Upsert(entity);
// Remove
db.Documents.Remove(entity); // By entity (matched by key)
db.Documents.RemoveByKey("doc-001"); // By key directly
// Find
Document? doc = db.Documents.Find("doc-001"); // O(1)
// Clear
db.Documents.Clear();
// Count
int count = db.Documents.Count;
๐ Vector Search
// Top-K
var results = db.Documents.Search(e => e.Embedding, queryVector, topK: 10);
// Threshold
var results = db.Documents.SearchByThreshold(e => e.Embedding, queryVector, threshold: 0.85f);
// Filtered
var results = db.Documents.Search(
e => e.Embedding, queryVector, topK: 10,
filter: e => e.Category == "Tutorial",
overFetchMultiplier: 4);
// Top-1
var best = db.Documents.SearchTop1(e => e.Embedding, queryVector);
// Async (all methods have Async variants)
var results = await db.Documents.SearchAsync(e => e.Embedding, queryVector, topK: 10, ct);
// Default field shorthand (single vector field entities)
var results = db.Documents.Search(queryVector, topK: 5);
๐พ Persistence
await db.SaveAsync(); // Full snapshot
await db.SaveChangesAsync(); // WAL incremental, O(ฮ)
await db.CompactAsync(); // Full snapshot + clear WAL
await db.LoadAsync(); // Load snapshot + replay WAL
| Format | Readability | Size | Speed | Use Case |
|---|---|---|---|---|
Json |
โ Excellent | Largest | Average | Development and debugging |
Xml |
โ Good | Large | Average | Compatibility |
Binary |
โ | Smallest | Fastest | Production |
WAL Mode
var options = new QuiverDbOptions
{
DatabasePath = "mydata.vdb",
StorageFormat = StorageFormat.Binary,
EnableWal = true,
WalCompactionThreshold = 10_000,
WalFlushToDisk = true
};
โ๏ธ Configuration
| Property | Type | Default | Description |
|---|---|---|---|
DatabasePath |
string? |
null |
Storage path; null = in-memory mode |
DefaultMetric |
DistanceMetric |
Cosine |
Default distance metric |
StorageFormat |
StorageFormat |
Json |
Json / Xml / Binary |
JsonOptions |
JsonSerializerOptions |
Indented + CamelCase | JSON serialization options |
EnableWal |
bool |
false |
Enable WAL incremental persistence |
WalCompactionThreshold |
int |
10,000 |
Auto-compact threshold |
WalFlushToDisk |
bool |
true |
fsync after WAL write |
๐ Concurrency
QuiverSet<T> uses ReaderWriterLockSlim:
- Read operations (Search / Find / Count) โ shared lock, parallel execution โ
- Write operations (Add / Upsert / Remove / Clear) โ exclusive lock ๐
No external locking needed.
โป๏ธ Lifecycle
// Recommended: await using (auto-save on dispose)
await using var db = new MyDocumentDb();
await db.LoadAsync();
// ... use db ...
// Scope ends โ DisposeAsync โ auto-save โ release resources
| Disposal | Auto-Save | Recommended |
|---|---|---|
DisposeAsync() |
โ Yes | โ
Use with await using |
Dispose() |
โ No | Manual control scenarios |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- System.IO.Hashing (>= 10.0.5)
- System.Numerics.Tensors (>= 10.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.