f4d9d09575
Funciones Python para embeddings: carga/guardado de modelos, encoding de texto, y almacenamiento/búsqueda vectorial con sqlite-vec y usearch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1.2 KiB
1.2 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | tested | tests | test_file_path | file_path | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| embedding_store_sqlvec | function | py | infra | 1.0.0 | impure | def embedding_store_sqlvec(db_path: str, table: str, ids: list, embeddings: list, dim: int = 384) -> int | Inserta embeddings en tabla sqlite-vec. Crea la tabla virtual si no existe. Insercion en batches. |
|
false | error_go_core |
|
false | python/functions/embedding/sqlvec.py |
Ejemplo
model = embedding_load_model(".local/models/e5-small")
docs = ["La IA transforma la industria", "Python es versatil"]
embs = embedding_encode(model, docs, mode="document")
n = embedding_store_sqlvec("vectors.db", "doc_embeddings", [0, 1], embs)
# n = 2
Notas
Usa sqlite-vec (extension pura C para SQLite). Los vectores se almacenan como blobs float32. Compatible con cualquier SQLite — se puede usar el mismo archivo para metadata con tablas normales. Insercion en batches de 500 para evitar limits de SQLite. Para 50k vectores dim=384: ~75 MB en disco, busqueda ~19ms/query.