Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Document txtai index format, closes #779

davidmezzetti65c92f15d236
diff --git a/docs/embeddings/format.md b/docs/embeddings/format.md
new file mode 100644
index 00000000..addf017b
--- /dev/null
+++ b/docs/embeddings/format.md
@@ -0,0 +1,59 @@
+# Index format
+
+![format](../images/format.png#only-light)
+![format](../images/format-dark.png#only-dark)
+
+This section documents the txtai index format. The goal of each component in txtai is to enable open access to the underlying data in a programatic and platform independent way.
+
+If an underlying library has an index format, that is used. Otherwise, txtai persists content with [MessagePack](https://msgpack.org/index.html) serialization.
+
+To learn more about how these components work together, read the [Index Guide](../indexing) and [Query Guide](../query).
+
+## ANN
+
+Approximate Nearest Neighbor (ANN) index configuration for storing vector embeddings.
+
+| Component | Storage Format |
+| ------------------------------------------------------------- | ---------------------------------------------------------------------------- |
+| [Faiss](https://github.com/facebookresearch/faiss) | Local file format provided by library |
+| [Hnswlib](https://github.com/nmslib/hnswlib) | Local file format provided by library |
+| [Annoy](https://github.com/spotify/annoy) | Local file format provided by library |
+| [NumPy](https://github.com/numpy/numpy) | Local NumPy array files via np.save / np.load |
+| [Postgres via pgvector](https://github.com/pgvector/pgvector) | Vector tables in a Postgres database |
+
+## Core
+
+Core embeddings index files.
+
+| Component | Storage Format |
+| ------------------------------------------------------------- | ---------------------------------------------------------------------------- |
+| [Configuration](https://www.json.org/) | Embeddings index configuration stored as JSON |
+| [Index Ids](https://msgpack.org/index.html) | Embeddings index ids serialized with MessagePack. Only enabled when when content storage (database) is disabled. |
+
+## Database
+
+Databases store metadata, text and binary content.
+
+| Component | Storage Format |
+| ------------------------------------------------------------- | ---------------------------------------------------------------------------- |
+| [SQLite](https://www.sqlite.org/) | Local database files with SQLite |
+| [DuckDB](https://github.com/duckdb/duckdb) | Local database files with DuckDB |
+| [Postgres](https://www.postgresql.org/) | Postgres relational database via [SQLAlchemy](https://github.com/sqlalchemy/sqlalchemy). Supports additional databases via this library. |
+
+## Graph
+
+Graph nodes and edges for an embeddings index
+
+| Component | Storage Format |
+| ------------------------------------------------------------- | ----------------------------------------------------------------------------- |
+| [NetworkX](https://github.com/networkx/networkx) | Nodes and edges exported to local file serialized with MessagePack |
+| [Postgres](https://github.com/aplbrain/grand) | Nodes and edges stored in a Postgres database. Supports additional databases. |
+
+## Scoring
+
+Sparse/keyword indexing
+
+| Component | Storage Format |
+| ------------------------------------------------------------- | ----------------------------------------------------------------------------- |
+| [Local index](https://www.sqlite.org/) | Metadata serialized with MessagePack. Terms stored in SQLite. |
+| [Postgres](https://www.postgresql.org/docs/current/textsearch.html) | Text indexed with Postgres Full Text Search (FTS) |
diff --git a/docs/images/format-dark.png b/docs/images/format-dark.png
new file mode 100644
index 00000000..61534185
Binary files /dev/null and b/docs/images/format-dark.png differ
diff --git a/docs/images/format.excalidraw b/docs/images/format.excalidraw
new file mode 100644
index 00000000..18e9fd2a
--- /dev/null
+++ b/docs/images/format.excalidraw
@@ -0,0 +1,446 @@
+{
+ "type": "excalidraw",
+ "version": 2,
+ "source": "https://excalidraw.com",
+ "elements": [
+ {
+ "type": "rectangle",
+ "version": 564,
+ "versionNonce": 555415043,
+ "index": "aZV",
+ "isDeleted": false,
+ "id": "c8q6be5K81xmCJ-ukSRnZ",
+ "fillStyle": "hachure",
+ "strokeWidth": 1,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 518,
+ "y": -130.82625000000002,
+ "strokeColor": "#03a9f4",
+ "backgroundColor": "#03a9f4",
+ "width": 261,
+ "height": 183,
+ "seed": 443859885,
+ "groupIds": [
+ "2ZFdM1ONmx5lh5aHlDXqH"
+ ],
+ "frameId": null,
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1724584360105,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 518,
+ "versionNonce": 1253679021,
+ "index": "aa",
+ "isDeleted": false,
+ "id": "uKvu2zcnLI9S3D-aFErJQ",
+ "fillStyle": "hachure",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 616.6083333333333,
+ "y": -129.82625000000002,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "#03a9f4",
+ "width": 53.78333333333333,
+ "height": 35,
+ "seed": 848196621,
+ "groupIds": [
+ "2ZFdM1ONmx5lh5aHlDXqH"
+ ],
+ "frameId": null,
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1724584360105,
+ "link": null,
+ "locked": false,
+ "fontSize": 28,
+ "fontFamily": 5,
+ "text": "ANN",
+ "textAlign": "left",
+ "verticalAlign": "top",
+ "containerId": null,
+ "originalText": "ANN",
+ "autoResize": true,
+ "lineHeight": 1.25
+ },
+ {
+ "type": "text",
+ "version": 480,
+ "versionNonce": 944506682,
+ "index": "ab",
+ "isDeleted": false,
+ "id": "DCqImwTRCBh0nmPIv-3zR",
+ "fillStyle": "hachure",
+ "strokeWidth": 1,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 536.8249969482422,
+ "y": -85.17374999999998,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "#03a9f4",
+ "width": 213.35000610351562,
+ "height": 125,
+ "seed": 1618350307,
+ "groupIds": [
+ "2ZFdM1ONmx5lh5aHlDXqH"
+ ],
+ "frameId": null,
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1724587151711,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 5,
+ "text": "- Faiss\n- HNSWLib\n- Annoy\n- NumPy\n- Postgres (pgvector)",
+ "textAlign": "left",
+ "verticalAlign": "top",
+ "containerId": null,
+ "originalText": "- Faiss\n- HNSWLib\n- Annoy\n- NumPy\n- Postgres (pgvector)",
+ "autoResize": true,
+ "lineHeight": 1.25
+ },
+ {
+ "type": "rectangle",
+ "version": 780,
+ "versionNonce": 1085123203,
+ "index": "abV",
+ "isDeleted": false,
+ "id": "Jo5LO2bSebtz54pWb3XHT",
+ "fillStyle": "hachure",
+ "strokeWidth": 1,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 810.5,
+ "y": -131.82625000000002,
+ "strokeColor": "#00e676",
+ "backgroundColor": "#00e676",
+ "width": 282.9999999999999,
+ "height": 182,
+ "seed": 848620899,
+ "groupIds": [
+ "hCyHVfABhzmE_8xEhUbGD"
+ ],
+ "frameId": null,
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1724584372798,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 717,
+ "versionNonce": 708473645,
+ "index": "ac",
+ "isDeleted": false,
+ "id": "wX4udz8nceRrNC3uUDLYf",
+ "fillStyle": "hachure",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 886.2583312988281,
+ "y": -121.82625000000002,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "#03a9f4",
+ "width": 131.48333740234375,
+ "height": 35,
+ "seed": 16206083,
+ "groupIds": [
+ "hCyHVfABhzmE_8xEhUbGD"
+ ],
+ "frameId": null,
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1724584372798,
+ "link": null,
+ "locked": false,
+ "fontSize": 28,
+ "fontFamily": 5,
+ "text": "Database",
+ "textAlign": "left",
+ "verticalAlign": "top",
+ "containerId": null,
+ "originalText": "Database",
+ "autoResize": true,
+ "lineHeight": 1.25
+ },
+ {
+ "type": "text",
+ "version": 722,
+ "versionNonce": 1181998310,
+ "index": "ad",
+ "isDeleted": false,
+ "id": "-5HdWsMbtE_7EnREtXBfc",
+ "fillStyle": "hachure",
+ "strokeWidth": 1,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 831.1999969482422,
+ "y": -77.17374999999998,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "#03a9f4",
+ "width": 241.60000610351562,
+ "height": 75,
+ "seed": 1976381603,
+ "groupIds": [
+ "hCyHVfABhzmE_8xEhUbGD"
+ ],
+ "frameId": null,
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1724587158353,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 5,
+ "text": "- SQLite\n- DuckDB\n- Postgres (SQLAlchemy)",
+ "textAlign": "left",
+ "verticalAlign": "top",
+ "containerId": null,
+ "originalText": "- SQLite\n- DuckDB\n- Postgres (SQLAlchemy)",
+ "autoResize": true,
+ "lineHeight": 1.25
+ },
+ {
+ "type": "rectangle",
+ "version": 900,
+ "versionNonce": 1747610221,
+ "index": "adV",
+ "isDeleted": false,
+ "id": "AK1nt4FrnmjinS2uZVZ2g",
+ "fillStyle": "hachure",
+ "strokeWidth": 1,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 1125,
+ "y": -132.32625000000002,
+ "strokeColor": "#ffeb3b",
+ "backgroundColor": "#ffeb3b",
+ "width": 266.9999999999999,
+ "height": 180,
+ "seed": 961514755,
+ "groupIds": [
+ "KOc5NUqUBL03A8qlCEUgw"
+ ],
+ "frameId": null,
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1724584372798,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 828,
+ "versionNonce": 1440317155,
+ "index": "ae",
+ "isDeleted": false,
+ "id": "yeFldcgggtNS8S44yWdtq",
+ "fillStyle": "hachure",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 1218.7916666666667,
+ "y": -129.32625000000002,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "#ffeb3b",
+ "width": 79.41666666666667,
+ "height": 35,
+ "seed": 41743523,
+ "groupIds": [
+ "KOc5NUqUBL03A8qlCEUgw"
+ ],
+ "frameId": null,
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1724584372798,
+ "link": null,
+ "locked": false,
+ "fontSize": 28,
+ "fontFamily": 5,
+ "text": "Graph",
+ "textAlign": "left",
+ "verticalAlign": "top",
+ "containerId": null,
+ "originalText": "Graph",
+ "autoResize": true,
+ "lineHeight": 1.25
+ },
+ {
+ "type": "text",
+ "version": 937,
+ "versionNonce": 766285005,
+ "index": "af",
+ "isDeleted": false,
+ "id": "FSHrZ4DMc-ubEPZmgY7M3",
+ "fillStyle": "hachure",
+ "strokeWidth": 1,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 1128.8999938964844,
+ "y": -78.67374999999998,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "#ffeb3b",
+ "width": 259.20001220703125,
+ "height": 75,
+ "seed": 2094819395,
+ "groupIds": [
+ "KOc5NUqUBL03A8qlCEUgw"
+ ],
+ "frameId": null,
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1724584372798,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 5,
+ "text": "- NetworkX (MessagePack)\n- Postgres (grand-graph)\n",
+ "textAlign": "left",
+ "verticalAlign": "top",
+ "containerId": null,
+ "originalText": "- NetworkX (MessagePack)\n- Postgres (grand-graph)\n",
+ "autoResize": true,
+ "lineHeight": 1.25
+ },
+ {
+ "type": "rectangle",
+ "version": 784,
+ "versionNonce": 868973283,
+ "index": "afV",
+ "isDeleted": false,
+ "id": "C_7EOPOUjQk0kE44hF9WC",
+ "fillStyle": "hachure",
+ "strokeWidth": 1,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 1423.5,
+ "y": -130.82625000000002,
+ "strokeColor": "#9775fa",
+ "backgroundColor": "#9775fa",
+ "width": 290.9999999999999,
+ "height": 174,
+ "seed": 606086243,
+ "groupIds": [
+ "-E2Q3MkgggNSCRYPrSvhr"
+ ],
+ "frameId": null,
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1724584154381,
+ "link": null,
+ "locked": false
+ },
+ {
+ "type": "text",
+ "version": 712,
+ "versionNonce": 1558730957,
+ "index": "ag",
+ "isDeleted": false,
+ "id": "nbfo2fj-5l1xNK7r9SnT8",
+ "fillStyle": "hachure",
+ "strokeWidth": 2,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 1520.2333335876465,
+ "y": -127.82625000000002,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "#ffeb3b",
+ "width": 97.53333282470703,
+ "height": 35,
+ "seed": 704880643,
+ "groupIds": [
+ "-E2Q3MkgggNSCRYPrSvhr"
+ ],
+ "frameId": null,
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1724584154381,
+ "link": null,
+ "locked": false,
+ "fontSize": 28,
+ "fontFamily": 5,
+ "text": "Scoring",
+ "textAlign": "left",
+ "verticalAlign": "top",
+ "containerId": null,
+ "originalText": "Scoring",
+ "autoResize": true,
+ "lineHeight": 1.25
+ },
+ {
+ "type": "text",
+ "version": 832,
+ "versionNonce": 2104267693,
+ "index": "ah",
+ "isDeleted": false,
+ "id": "6a1UVKWBLqgnaAvPSuSfw",
+ "fillStyle": "hachure",
+ "strokeWidth": 1,
+ "strokeStyle": "solid",
+ "roughness": 1,
+ "opacity": 100,
+ "angle": 0,
+ "x": 1431.6750030517578,
+ "y": -76.17374999999998,
+ "strokeColor": "#1e1e1e",
+ "backgroundColor": "#ffeb3b",
+ "width": 274.6499938964844,
+ "height": 75,
+ "seed": 154576803,
+ "groupIds": [
+ "-E2Q3MkgggNSCRYPrSvhr"
+ ],
+ "frameId": null,
+ "roundness": null,
+ "boundElements": [],
+ "updated": 1724584347937,
+ "link": null,
+ "locked": false,
+ "fontSize": 20,
+ "fontFamily": 5,
+ "text": "- Local index (MessagePack)\n- Postgres\n",
+ "textAlign": "left",
+ "verticalAlign": "top",
+ "containerId": null,
+ "originalText": "- Local index (MessagePack)\n- Postgres\n",
+ "autoResize": true,
+ "lineHeight": 1.25
+ }
+ ],
+ "appState": {
+ "gridSize": 20,
+ "gridStep": 5,
+ "gridModeEnabled": false,
+ "viewBackgroundColor": "#ffffff"
+ },
+ "files": {}
+}
\ No newline at end of file
diff --git a/docs/images/format.png b/docs/images/format.png
new file mode 100644
index 00000000..b107c702
Binary files /dev/null and b/docs/images/format.png differ
diff --git a/mkdocs.yml b/mkdocs.yml
index db12de63..e281f49c 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -67,6 +67,7 @@ nav:
- Graph: embeddings/configuration/graph.md
- Scoring: embeddings/configuration/scoring.md
- Vectors: embeddings/configuration/vectors.md
+ - Index Format: embeddings/format.md
- Index Guide: embeddings/indexing.md
- Methods: embeddings/methods.md
- Query Guide: embeddings/query.md