Mythosia.VectorDb.InMemory
2.2.0
See the version list below for details.
dotnet add package Mythosia.VectorDb.InMemory --version 2.2.0
NuGet\Install-Package Mythosia.VectorDb.InMemory -Version 2.2.0
<PackageReference Include="Mythosia.VectorDb.InMemory" Version="2.2.0" />
<PackageVersion Include="Mythosia.VectorDb.InMemory" Version="2.2.0" />
<PackageReference Include="Mythosia.VectorDb.InMemory" />
paket add Mythosia.VectorDb.InMemory --version 2.2.0
#r "nuget: Mythosia.VectorDb.InMemory, 2.2.0"
#:package Mythosia.VectorDb.InMemory@2.2.0
#addin nuget:?package=Mythosia.VectorDb.InMemory&version=2.2.0
#tool nuget:?package=Mythosia.VectorDb.InMemory&version=2.2.0
Mythosia.VectorDb.InMemory
Migration from v1.0.0
v2.0.0 renames logical separation units:
collection→namespace(terminology update in public API/docs)namespace→scope(for second-tier logical isolation)
Package Summary
Provides InMemoryVectorStore, a thread-safe in-memory implementation of IVectorStore using cosine similarity search.
Suitable for development, testing, and small-scale workloads.
Usage
Automatically used as the default vector store in Mythosia.AI.Rag:
// Explicit selection (same as default)
.WithRag(rag => rag
.AddDocument("docs.txt")
.UseInMemoryStore()
)
Features
- Thread-safe — Uses
ConcurrentDictionaryfor safe concurrent access - Cosine similarity — TopK search with configurable result count
- Scope isolation — Filter by scope for multi-tenant scenarios
- Metadata filtering — Filter search results by key-value metadata
- Minimum score — Discard results below a similarity threshold
- Upsert — Single and batch upsert operations
- Namespace-aware operations — Use
InNamespace(...)orVectorFilter.Namespace
Standalone Usage
Fluent API (recommended)
using Mythosia.VectorDb;
using Mythosia.VectorDb.InMemory;
var store = new InMemoryVectorStore();
var ns = store.InNamespace("my-namespace");
// Namespace-only
await ns.UpsertAsync(new VectorRecord
{
Id = "doc-1",
Content = "Some text content",
Vector = new float[] { 0.1f, 0.2f, 0.3f },
Metadata = { ["source"] = "manual.txt" }
});
var results = await ns.SearchAsync(queryVector, topK: 5);
// Namespace + Scope
var scoped = ns.InScope("tenant-1");
await scoped.UpsertAsync(record); // record.Scope is set automatically
var scopedResults = await scoped.SearchAsync(queryVector);
Direct IVectorStore API
using Mythosia.VectorDb;
using Mythosia.VectorDb.InMemory;
var store = new InMemoryVectorStore();
await store.UpsertAsync(new VectorRecord
{
Namespace = "my-namespace",
Id = "doc-1",
Content = "Some text content",
Vector = new float[] { 0.1f, 0.2f, 0.3f },
Metadata = { ["source"] = "manual.txt" }
});
var results = await store.SearchAsync(
queryVector,
topK: 5,
filter: VectorFilter.ByNamespace("my-namespace"));
BM25 Index (v2.1.0)
Bm25Index provides in-memory BM25 keyword search for hybrid retrieval. When UseHybridSearch() is called with InMemoryVectorStore, the RAG pipeline automatically builds a BM25 index alongside the vector store and merges results via RRF.
// Automatic — just enable hybrid search in the builder
var store = await RagStore.BuildAsync(config => config
.AddText("환불은 14일 이내 가능합니다.", id: "refund")
.UseLocalEmbedding(512)
.UseInMemoryStore()
.UseHybridSearch() // BM25 index is built automatically
);
Standalone usage:
using Mythosia.VectorDb.InMemory;
var bm25 = new Bm25Index();
bm25.Index("doc1", "machine learning neural network");
bm25.Index("doc2", "cooking recipe pasta");
var results = bm25.Search("machine learning", topK: 5);
// results[0].Id == "doc1", results[0].Score > 0
When hybrid search is used, fused RRF scores are normalized to the [0, 1] range so VectorFilter.MinScore is applied consistently to the final merged score.
Vector Replacement
ReplaceByFilterAsync is available via the IVectorStore default interface method. It performs sequential DeleteByFilterAsync → UpsertBatchAsync (non-transactional, suitable for in-memory usage):
IVectorStore store = new InMemoryVectorStore();
var filter = VectorFilter.ByMetadata("full_path", "/docs/file.md");
filter.Namespace = "default";
await store.ReplaceByFilterAsync(filter, newRecords);
For transactional guarantees (zero query gap), use PostgresStore which wraps both operations in a single database transaction.
Limitations
- Data is not persisted — lost when the process exits
- Not suitable for large-scale production workloads (millions of vectors)
- For persistence or scale, implement a custom
IVectorStore(e.g., Qdrant, Chroma, Pinecone)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Lucene.Net (>= 4.8.0-beta00016)
- Lucene.Net.Analysis.Common (>= 4.8.0-beta00016)
- Mythosia.AI.Rag.Abstractions (>= 5.0.0)
- Mythosia.VectorDb.Abstractions (>= 2.3.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Mythosia.VectorDb.InMemory:
| Package | Downloads |
|---|---|
|
Mythosia.AI.Rag
RAG (Retrieval Augmented Generation) orchestration for Mythosia.AI. Implements Mythosia.AI.Rag.Abstractions v5.x. Includes RagPipeline, text splitters, context builder, OpenAI/vLLM embedding providers, hybrid search (BM25 + Vector + RRF), re-ranking (Cohere, LLM, vLLM), search gate, keyword extraction, weighted-blend final selection, progress reporting, DoclingDocument-to-RagDocument conversion, and per-query VectorFilter passthrough (StoreFilter). Depends on Mythosia.AI.Abstractions (IAIService) instead of the full Mythosia.AI implementation. |
GitHub repositories
This package is not used by any popular GitHub repositories.
v2.2.0: Compatible with Abstractions v2.3.0. ReplaceByFilterAsync available via default interface method (sequential DeleteByFilterAsync then UpsertBatchAsync).