Created
January 16, 2026 16:22
-
-
Save davidmezzetti/06a058d696b3275127722ef6929cc938 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from txtai import Embeddings | |
| # SQLite + NumPy | |
| embeddings = Embeddings(content=True, backend="numpy") | |
| embeddings.index(["test"]) | |
| embeddings.save("test") | |
| # SQLite File | |
| # sqlite3 test/documents "SELECT * FROM sections" | |
| # 0|0|test||2026-01-16 16:12:03.410194+00:00 | |
| # NumPy Embeddings | |
| # python -c 'import numpy as np; print(np.load("test/embeddings")[:,:5])' | |
| # [[ 0.01157344 0.02513618 -0.03670187 0.05932486 -0.00714904]] | |
| # Also works with DuckDB! | |
| embeddings = Embeddings(content="duckdb", backend="numpy") | |
| embeddings.index(["test"]) | |
| embeddings.save("test") | |
| # DuckDB File | |
| # duckdb -c 'SELECT * from sections' test/documents | |
| # ┌─────────┬─────────┬─────────┬─────────┬────────────────────────────┐ | |
| # │ indexid │ id │ text │ tags │ entry │ | |
| # │ int32 │ varchar │ varchar │ varchar │ timestamp │ | |
| # ├─────────┼─────────┼─────────┼─────────┼────────────────────────────┤ | |
| # │ 0 │ 0 │ test │ NULL │ 2026-01-16 11:14:29.692397 │ | |
| # └─────────┴─────────┴─────────┴─────────┴────────────────────────────┘ | |
| # Embeddings database configuration is JSON | |
| # jq "." test/config.json | |
| # { | |
| # "content": "duckdb", | |
| # "backend": "numpy", | |
| # "path": "sentence-transformers/all-MiniLM-L6-v2", | |
| # ... | |
| # } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment