VictorLib 1.0.10-Finalbeta
See the version list below for details.
dotnet add package VictorLib --version 1.0.10-Finalbeta
NuGet\Install-Package VictorLib -Version 1.0.10-Finalbeta
<PackageReference Include="VictorLib" Version="1.0.10-Finalbeta" />
<PackageVersion Include="VictorLib" Version="1.0.10-Finalbeta" />
<PackageReference Include="VictorLib" />
paket add VictorLib --version 1.0.10-Finalbeta
#r "nuget: VictorLib, 1.0.10-Finalbeta"
#addin nuget:?package=VictorLib&version=1.0.10-Finalbeta&prerelease
#tool nuget:?package=VictorLib&version=1.0.10-Finalbeta&prerelease
Victor Base C# Binding & SDK - INDEV Beta Final 1.0.10
Descripción / Description
Español:
VictorLib es el SDK en C# de la librería nativa Victor Base. Te Permite acceso eficiente a funcionalidades de indexación, búsqueda y gestión de vectores, con una API moderna, segura y performante para .NETEnglish:
VictorLib is the C# interoperability SDK for the native Victor Base library. It provides efficient access to indexing, search, and vector management features, with a modern and safe API for .NET.
CHANGELOG
Estructura del proyecto / Project Structure
Src/
Common/
Mapping.cs
Structs.cs
InterOp/
Factory/
Factory.cs
Native/
INativeMethods.cs
NativeMethodsLinux.cs
NativeMethodsWindows.cs
StaticNativeLinux.cs
StaticNativeWindows.cs
VictorExceptions/
VictorExceptions.cs
VictorSDK/
VictorLib.cs
VictorSDK_Index.cs
VictorSDKAsort.cs
Snapshots/
Snapshot.cs
VictorEntry.cs
Tests/
UnitTest1.cs
Examples/
(usage examples)
Español:
InterOp
contiene VictorSDK, la capa de abstracción sobre las funciones nativas.Common
incluye estructuras y utilidades reutilizables.Tests
contiene pruebas unitarias y de integración.Examples
incluye ejemplos prácticos de uso.Benchmark
Contiene un helper aún no público para medir rendimiento.
English:
InterOp
contains VictorSDK, the abstraction layer over native functions.Common
includes reusable structs and utilities.Tests
contains unit and integration tests.Examples
provides practical usage examples.
Métodos principales / Main Methods
Insert:
- Español: Inserta un vector en el índice con un ID único.
- English: Adds a vector to the index using a unique ID.
Search:
- Español: Busca el vector más cercano en el índice.
- English: Searches for the closest vector in the index.
Search_n:
- Español: Devuelve los N vectores más cercanos.
- English: Returns the N closest vectors.
Delete:
- Español: Elimina un vector por su ID.
- English: Deletes a vector by its ID.
GetSize:
- Español: Obtiene el número total de vectores en el índice.
- English: Gets the total number of vectors in the index.
DumpIndex:
- Español: Guarda el estado actual del índice en un archivo.
- English: Saves the current index state to a file.
LoadIndex:
- Español: Carga un índice desde un archivo.
- English: Loads an index from a file.
Dispose:
- Español: Libera recursos y evita fugas de memoria.
- English: Releases resources and prevents memory leaks.
GetStats:
- Español: Obtiene estadísticas detalladas del índice (operaciones, tiempos, etc).
- English: Gets detailed index statistics (operations, timings, etc).
SetBasePath
- Español: Te permite setear una ruta custom para guardar tus archivos json de índices.
- English: Allows you to set a custom file path to save your index json files.
DumpToAutoPath (Class VictorPersistence)
- Español: Guarda el/los índices en un json generado en una carpeta llamada ".victorIndex"(generalmente en la carpeta bin/Debug) de manera automática si no le proporcionás una ruta custom.
- English: Automatically saves the index/indices in a JSON file generated in a folder named ".victorIndex" (normally in bin/Debug) if you don't provide a custom path.
Instalación / Installation
Español
Para instalar la librería desde NuGet:
dotnet add package VictorLib --prerelease
English
To install the library from NuGet:
dotnet add package VictorLib --prerelease
Ejemplo de uso básico/Minimal Usage Example
Español
// Pista: El ctor VictorSDK implementa IDisposable, por lo tanto podemos evitar el metodo Dispose() con using cada vez que inicialicemos el ctor.
VictorSDK sdk = new(type: IndexType.FLAT, method: DistanceMethod.DOTPROD, dims: 128);
// Insertar un vector
sdk.Insert(id: 1,vector: new float[128],dims: 128);
// Buscar un vector
var result = sdk.Search(new float[128], 128);
Console.WriteLine($"Match ID: {result.Label}, Distance: {result.Distance}");
// Obtener el tamaño del índice
ulong size = sdk.GetSize();
Console.WriteLine($"Index size: {size}");
// Guardar el índice en un archivo
sdk.DumpIndex("index_dump.dat");
// Liberar recursos manualmente.
sdk.Dispose();
English
//Hint: VictorSDK implements IDisposable, so you can avoid Dispose() with using to free resources.
VictorSDK sdk = new (type: IndexType.FLAT, method: DistanceMethod.DOTPROD, dims: 128);
// Insert a vector
sdk.Insert(1, new float[128], 128);
// Search for a vector
var result = sdk.Search(new float[128], 128);
Console.WriteLine($"Match ID: {result.Label}, Distance: {result.Distance}");
// Get the size of the index
ulong size = sdk.GetSize();
Console.WriteLine($"Index size: {size}");
// Save the index to a file
sdk.DumpIndex("index_dump.dat");
// Release resources manually
sdk.Dispose();
Notas importantes / Important Notes
Contextos:
- Para índices tipo
HNSW
oNSW
, debes pasar un contexto válido al constructor. - Para índices tipo
FLAT
, el contexto es ignorado y puede sernull
.
- Para índices tipo
Logging y Diagnóstico:
- El SDK utiliza
Debug.WriteLine
para mensajes de depuración. - No se imprimen mensajes en consola a menos que el usuario lo haga explícitamente.
- El SDK utiliza
Compatibilidad:
- Compatible con Windows y Linux (x64).
- Requiere la biblioteca nativa Victor Base instalada y accesible en el sistema.
DevX:
- Más abajo te cuento cómo recomiendo usar los métodos en un ejemplo más detallado aprovechando mejor la potencia de la lib. Consultar: "Buenas prácticas / Good coding".
- Below you will find a more detailed example showing how to make the most of the library's features. See: "Good coding" for best practices.
Notas sobre tipos de índices y métodos de búsqueda / Notes on Index Types and Search Methods
Tipos de índice / Index Types
FLAT:
- No requiere contexto, pero puedes pasar
null
para el parámetrocontext
en el constructor. - Uso recomendado para índices pequeños o cuando no necesitas estructuras jerárquicas.
- No requiere contexto, pero puedes pasar
HNSW / NSW:
- Permiten y suelen requerir un contexto (
HNSWContext
oNSWContext
) para configurar parámetros avanzados. - Si pasas
null
, se usarán valores por defecto. - Uso recomendado para grandes volúmenes de datos y búsquedas rápidas.
- Permiten y suelen requerir un contexto (
Nota:
- Todos los tipos de índice aceptan
null
como contexto en el constructor. - El contexto solo es obligatorio para
HNSW
yNSW
si quieres personalizar parámetros.
Métricas de distancia / Distance Metrics
cosine:
- Mide la similitud angular entre dos vectores.
- Útil para comparar orientación más que magnitud (por ejemplo, embeddings de texto).
euclidian:
- Calcula la distancia euclidiana estándar.
- Útil para datos donde la magnitud importa.
dotproduct:
- Calcula el producto punto entre dos vectores.
- Útil para tareas de ranking y algunas aplicaciones de machine learning.
Métodos de búsqueda / Search Methods
Search:
- Devuelve el vector más cercano al vector de consulta.
- Uso general para obtener el mejor match.
Search_n:
- Devuelve los N vectores más cercanos.
- Útil para recomendaciones, clustering, o análisis de vecinos.
Contains:
- Verifica si uno o más IDs existen en el índice.
Delete:
- Elimina un vector por su ID.
Ejemplo de inicialización con y sin contexto
// FLAT index
var flatSdk = new VictorSDK(type: IndexType.FLAT, method: DistanceMethod.DOTPROD, dims: 128, context: null);
// HNSW index
var hnswContext = HNSWContext.Create(efConstruct: 200, efSearch: 100, m0: 32);
VictorSDK hnswSdk = new (type: IndexType.HNSW, method: DistanceMethod.COSINE, dims: 128, context: hnswContext);
// HNSW index
VictorSDK hnswDefaultSdk = new (type: IndexType.HNSW, method: DistanceMethod.COSINE, dims: 128, context: null);
Notes on Index Types and Search Methods
Index Types
FLAT:
- Does not require a context, but you can pass
null
for thecontext
parameter in the constructor. - Recommended for small indices or when you do not need hierarchical structures.
- Does not require a context, but you can pass
HNSW / NSW:
- Allow and usually require a context (
HNSWContext
orNSWContext
) to configure advanced parameters. - If you pass
null
, default values will be used. - Recommended for large datasets and fast searches.
- Allow and usually require a context (
Distance Metrics
cosine:
- Measures the angular similarity between two vectors.
- Useful for comparing orientation rather than magnitude (e.g., text embeddings).
euclidian:
- Computes the standard Euclidean distance.
- Useful when magnitude matters.
dotproduct:
- Computes the dot product between two vectors.
- Useful for ranking tasks and some machine learning applications.
Note:
- All index types accept
null
as the context in the constructor. - The context is only required for
HNSW
andNSW
if you want to customize parameters.
Search Methods
Search:
- Returns the closest vector to the query vector.
- General use for obtaining the best match.
Search_n:
- Returns the N closest vectors.
- Useful for recommendations, clustering, or neighbor analysis.
Contains:
- Checks if one or more IDs exist in the index.
Delete:
- Deletes a vector by its ID.
Example: Initialization With and Without Context
// FLAT index (context can be null)
var flatSdk = new VictorSDK(type: IndexType.FLAT, method: DistanceMethod.DOTPROD, dims: 128, context: null);
// HNSW index (with custom context)
var hnswContext = HNSWContext.Create(efConstruct: 200, efSearch: 100, m0: 32);
VictorSDK hnswSdk = new (type: IndexType.HNSW, method: DistanceMethod.COSINE, dims: 128, context: hnswContext);
// HNSW index
VictorSDK hnswDefaultSdk = new (type: IndexType.HNSW, method: DistanceMethod.COSINE, dims: 128, context: null);
Buenas prácticas / Good coding
- Un pequeño archivo de docs adicional donde te muestro cómo recomiendo usar las funciones de persistencia, y un patrón de diseño que recomiendo mientras uses la librería.
📖 Recomendado: Patrón Double Using + Persistencia JSON (Español)
- A little file where i show you how to use the Json persistence methods & a design pattern
📖 Recommended: Double Using + JSON Persistence Pattern (English)
Contribuciones / Contributions
Español
Las contribuciones son bienvenidas. Por favor, abrí un issue o un pull request siguiendo este formato:
git checkout -b feature/nombre-del-issue
English
Contributions are welcome. Please open an issue or pull request using this format:
git checkout -b feature/issue-name
Créditos y Licencia / Credits & License
Español:
Este SDK complementa Victor Base https://github.com/victor-base, un proyecto de Emiliano A. Billi.
SDK desarrollado por Iván E. Rodríguez bajo licencia LGPL-3.0.English:
This SDK complements Victor Base https://github.com/victor-base, a project by Emiliano A. Billi.
SDK developed by Iván E. Rodríguez under LGPL-3.0 license.
Soporte / Support
- Para consultas técnicas: ivanrwcm25@gmail.com
- Más información sobre el desarrollador: https://ivanrodportolio.netlify.app/
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 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. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.12-Finalbeta | 106 | 5/19/2025 |
1.0.11-Finalbeta | 102 | 5/19/2025 |
1.0.10-Finalbeta | 63 | 5/17/2025 |
1.0.9-beta | 123 | 4/7/2025 |
1.0.8-beta | 123 | 4/7/2025 |
1.0.7-beta | 125 | 4/7/2025 |
1.0.6-beta | 118 | 4/6/2025 |
1.0.5-beta | 116 | 4/6/2025 |
1.0.4-beta | 47 | 4/5/2025 |
1.0.3-beta | 114 | 4/4/2025 |
1.0.2-beta | 110 | 4/4/2025 |
1.0.1-beta | 115 | 4/4/2025 |
1.0.0-beta | 120 | 4/3/2025 |
This package is an independent contribution to Victor Base core library.
Original project by emiliano.billi@gmail.com.