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.1 KiB
1.1 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_usearch | function | py | infra | 1.0.0 | impure | def embedding_store_usearch(path: str, ids: list, embeddings: list, dim: int = 384) -> int | Crea indice USearch con embeddings y lo persiste a archivo. Busqueda sub-milisegundo. |
|
false | error_go_core |
|
false | python/functions/embedding/usearch_store.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_usearch("docs.usearch", [0, 1], embs)
# n = 2
Notas
USearch usa HNSW (approximate nearest neighbors). Para 50k vectores dim=384: ~80 MB en disco, busqueda ~0.13ms/query (150x mas rapido que sqlite-vec). El tradeoff es que no soporta metadata nativa — usar junto con SQLite para metadata. Sobreescribe el archivo si ya existe.