Skip to content

armgit / txtai

Public Imported from GitHub
0

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

Reorganize embeddings configuration documentation, closes #504

davidmezzettidd40e886605d
diff --git a/docs/embeddings/configuration/ann.md b/docs/embeddings/configuration/ann.md
new file mode 100644
index 00000000..2c0949d3
--- /dev/null
+++ b/docs/embeddings/configuration/ann.md
@@ -0,0 +1,57 @@
+# ANN
+
+The following covers the available vector index configuration options.
+
+## backend
+```yaml
+backend: faiss|hnsw|annoy|numpy|torch|custom
+```
+
+Approximate Nearest Neighbor (ANN) index backend for storing generated sentence embeddings. `Defaults to faiss`. Additional backends require the
+[similarity](../../../install/#similarity) extras package to be installed. Add custom backends via setting this parameter to the fully resolvable
+class string.
+
+Backend-specific settings are set with a corresponding configuration object having the same name as the backend (i.e. annoy, faiss, or hnsw). None of these are required and are set to defaults if omitted.
+
+### faiss
+```yaml
+faiss:
+ components: comma separated list of components - defaults to "Flat" for small
+ indices and "IVFx,Flat" for larger indexes where
+ x = 4 * sqrt(embeddings count)
+ nprobe: search probe setting (int) - defaults to x/16 (as defined above)
+ for larger indexes
+ quantize: store vectors with 8-bit precision vs 32-bit (boolean)
+ defaults to false
+ mmap: load as on-disk index (boolean) - trade query response time for a
+ smaller RAM footprint, defaults to false
+ sample: percent of data to use for model training (0.0 - 1.0)
+ reduces indexing time for larger (>1M+ row) indexes, defaults to 1.0
+```
+
+See the following Faiss documentation links for more information.
+
+- [Guidelines for choosing an index](https://github.com/facebookresearch/faiss/wiki/Guidelines-to-choose-an-index)
+- [Index configuration summary](https://github.com/facebookresearch/faiss/wiki/Faiss-indexes)
+- [Index Factory](https://github.com/facebookresearch/faiss/wiki/The-index-factory)
+- [Search Tuning](https://github.com/facebookresearch/faiss/wiki/Faster-search)
+
+### hnsw
+```yaml
+hnsw:
+ efconstruction: ef_construction param for init_index (int) - defaults to 200
+ m: M param for init_index (int) - defaults to 16
+ randomseed: random-seed param for init_index (int) - defaults to 100
+ efsearch: ef search param (int) - defaults to None and not set
+```
+
+See [Hnswlib documentation](https://github.com/nmslib/hnswlib/blob/master/ALGO_PARAMS.md) for more information on these parameters.
+
+### annoy
+```yaml
+annoy:
+ ntrees: number of trees (int) - defaults to 10
+ searchk: search_k search setting (int) - defaults to -1
+```
+
+See [Annoy documentation](https://github.com/spotify/annoy#full-python-api) for more information on these parameters. Note that annoy indexes can not be modified after creation, upserts/deletes and other modifications are not supported.
diff --git a/docs/embeddings/configuration/database.md b/docs/embeddings/configuration/database.md
new file mode 100644
index 00000000..31820357
--- /dev/null
+++ b/docs/embeddings/configuration/database.md
@@ -0,0 +1,50 @@
+# Database
+
+The following covers available content storage configuration options.
+
+## content
+```yaml
+content: boolean|sqlite|duckdb|custom
+```
+
+Enables content storage. When true, the default storage engine, `sqlite` will be used to save metadata alongside embeddings vectors. Also supports `duckdb`. Add custom storage engines via setting this parameter to the fully resolvable class string.
+
+Content storage specific settings are set with a corresponding configuration object having the same name as the content storage engine (i.e. duckdb or sqlite). None of these are required and are set to defaults if omitted.
+
+### sqlite
+```yaml
+sqlite:
+ wal: enable write-ahead logging - allows concurrent read/write operations,
+ defaults to false
+```
+
+## objects
+```yaml
+objects: boolean
+```
+
+Enables object storage. When content storage is enabled and this is true, support for storing binary content alongside embeddings vectors and metadata is enabled.
+
+## functions
+```yaml
+functions: list
+```
+
+List of functions with user-defined SQL functions, only used when [content](#content) is enabled. Each list element must be one of the following:
+
+- function
+- callable object
+- dict with fields for name, argcount and function
+
+[An example can be found here](../../query#custom-sql-functions).
+
+## query
+```yaml
+query:
+ path: sets the path for the query model - this can be any model on the
+ Hugging Face Model Hub or a local file path.
+ prefix: text prefix to prepend to all inputs
+ maxlength: maximum generated sequence length
+```
+
+Query translation model. Translates natural language queries to txtai compatible SQL statements.
diff --git a/docs/embeddings/configuration/general.md b/docs/embeddings/configuration/general.md
new file mode 100644
index 00000000..bdf1779f
--- /dev/null
+++ b/docs/embeddings/configuration/general.md
@@ -0,0 +1,17 @@
+# General
+
+General configuration options that don't fit elsewhere.
+
+## format
+```yaml
+format: pickle|json
+```
+
+Sets the configuration storage format. Defaults to `pickle`.
+
+## autoid
+```yaml
+format: int|uuid function
+```
+
+Sets the auto id generation method. When this is not set, an autogenerated numeric sequence is used. This also supports [UUID generation functions](https://docs.python.org/3/library/uuid.html#uuid.uuid1). For example, setting this value to `uuid4` will generate random UUIDs. Setting this to `uuid5` will generate deterministic UUIDs for each input data row.
\ No newline at end of file
diff --git a/docs/embeddings/configuration/graph.md b/docs/embeddings/configuration/graph.md
new file mode 100644
index 00000000..231fc037
--- /dev/null
+++ b/docs/embeddings/configuration/graph.md
@@ -0,0 +1,42 @@
+# Graph
+
+The following covers available graph configuration options.
+
+## graph
+```yaml
+graph:
+ backend: graph network backend (string), defaults to "networkx"
+ batchsize: batch query size, used to query embeddings index (int)
+ defaults to 256
+ limit: maximum number of results to return per embeddings query (int)
+ defaults to 15
+ minscore: minimum score required to consider embeddings query matches (float)
+ defaults to 0.1
+ approximate: when true, queries only run for nodes without edges (boolean)
+ defaults to true
+ topics: see below
+```
+
+Enables graph storage. When set, a graph network is built using the embeddings index. Graph nodes are synced with each embeddings index operation (index/upsert/delete). Graph edges are created using the embeddings index upon completion of each index/upsert/delete embeddings index call.
+
+Add custom graph storage engines via setting the `graph.backend` parameter to the fully resolvable class string.
+
+Defaults are tuned so that in most cases these values don't need to be changed.
+
+### topics
+```yaml
+topics:
+ algorithm: community detection algorithm (string), options are
+ louvain (default), greedy, lpa
+ level: controls number of topics (string), options are best (default) or first
+ resolution: controls number of topics (int), larger values create more
+ topics (int), defaults to 100
+ labels: scoring index method used to build topic labels (string)
+ options are bm25 (default), tfidf, sif
+ terms: number of frequent terms to use for topic labels (int), defaults to 4
+ stopwords: optional list of stop words to exclude from topic labels
+ categories: optional list of categories used to group topics, allows
+ granular topics with broad categories grouping topics
+```
+
+Enables topic modeling. Defaults are tuned so that in most cases these values don't need to be changed (except for categories). These parameters are available for advanced use cases where one wants full control over the community detection process.
diff --git a/docs/embeddings/configuration/index.md b/docs/embeddings/configuration/index.md
index 54875113..f6211175 100644
--- a/docs/embeddings/configuration/index.md
+++ b/docs/embeddings/configuration/index.md
@@ -1,252 +1,47 @@
# Configuration
-This following describes available embeddings configuration. These parameters are set in the [Embeddings constructor](../methods#txtai.embeddings.base.Embeddings.__init__) via either the `config` parameter or as keyword arguments.
+The following describes available embeddings configuration. These parameters are set in the [Embeddings constructor](../methods#txtai.embeddings.base.Embeddings.__init__) via either the `config` parameter or as keyword arguments.
-## format
-```yaml
-format: pickle|json
-```
-
-Sets the configuration storage format. Defaults to `pickle`.
-
-## path
-```yaml
-path: string
-```
+Configuration is designed to be optional and set only when needed. Out of the box, sensible defaults are picked to get up and running fast. For example:
-Sets the path for a vectors model. When using a transformers/sentence-transformers model, this can be any model on the
-[Hugging Face Hub](https://huggingface.co/models) or a local file path. Otherwise, it must be a local file path to a word embeddings model.
+```python
+from txtai.embeddings import Embeddings
-## method
-```yaml
-method: transformers|sentence-transformers|words|external
+embeddings = Embeddings()
```
-Sentence embeddings method to use. If the method is not provided, it is inferred using the `path`.
-
-`sentence-transformers` and `words` require the [similarity](../../install/#similarity) extras package to be installed.
-
-### transformers
-
-Builds sentence embeddings using a transformers model. While this can be any transformers model, it works best with
-[models trained](https://huggingface.co/models?pipeline_tag=sentence-similarity) to build sentence embeddings.
-
-### sentence-transformers
+Creates a new embeddings instance, using [all-MiniLM-L6-v2](https://hf.co/sentence-transformers/all-MiniLM-L6-v2) as the vector model, [Faiss](https://faiss.ai/) as the ANN index backend and content disabled.
-Same as transformers but loads models with the [sentence-transformers](https://github.com/UKPLab/sentence-transformers) library.
+```python
+from txtai.embeddings import Embeddings
-### words
-
-Builds sentence embeddings using a word embeddings model. Transformers models are the preferred vector backend in most cases. Word embeddings models may be deprecated in the future.
-
-#### storevectors
-```yaml
-storevectors: boolean
+embeddings = Embeddings(content=True)
```
-Enables copying of a vectors model set in path into the embeddings models output directory on save. This option enables a fully encapsulated index with no external file dependencies.
+Is the same as above except it adds in [SQLite](https://www.sqlite.org/index.html) for content storage.
-#### scoring
-```yaml
-scoring: bm25|tfidf|sif
-```
+The following sections link to all the available configuration options.
-A scoring model builds weighted averages of word vectors for a given sentence. Supports BM25, TF-IDF and SIF (smooth inverse frequency) methods. If a scoring method is not provided, mean sentence embeddings are built.
+## [ANN](./ann)
-#### pca
-```yaml
-pca: int
-```
+The default vector index backend is Faiss.
-Removes _n_ principal components from generated sentence embeddings. When enabled, a TruncatedSVD model is built to help with dimensionality reduction. After pooling of vectors creates a single sentence embedding, this method is applied.
+## [Cloud](./cloud)
-### external
+Embeddings databases can optionally be synced with cloud storage.
-Sentence embeddings are loaded via an external model or API. Requires setting the [transform](#transform) parameter to a function that translates data into vectors.
+## [Database](./database)
-#### transform
-```yaml
-transform: function
-```
+Content storage is disabled by default. When enabled, SQLite is the default storage engine.
-When method is `external`, this function transforms input content into embeddings. The input to this function is a list of data. This method must return either a numpy array or list of numpy arrays.
+## [General](./general)
-#### gpu
-```yaml
-gpu: boolean|int|string|device
-```
+General configuration that doesn't fit elsewhere.
-Set the target device. Supports true/false, device id, device string and torch device instance. This is automatically derived if omitted.
+## [Graph](./graph)
-## batch
-```yaml
-batch: int
-```
+An accomplying graph index can be created with an embeddings database. This enables topic modeling, path traversal and more. [NetworkX](https://github.com/networkx/networkx) is the default graph index.
-Sets the transform batch size. This parameter controls how input streams are chunked and vectorized.
-
-## encodebatch
-```yaml
-encodebatch: int
-```
-
-Sets the encode batch size. This parameter controls the underlying vector model batch size. This often corresponds to a GPU batch size, which controls GPU memory usage.
-
-## tokenize
-```yaml
-tokenize: boolean
-```
-
-Enables string tokenization (defaults to false). This method applies tokenization rules that only work with English language text and may increase the quality of
-English language sentence embeddings in some situations.
-
-## instructions
-```yaml
-instructions:
- query: prefix for queries
- data: prefix for indexing
-```
-
-Instruction-based models use prefixes to modify how embeddings are computed. This is especially useful with asymmetric search, which is when the query and indexed data are of vastly different lengths. In other words, short queries with long documents.
-
-[E5-base](https://huggingface.co/intfloat/e5-base) is an example of a model that accepts instructions. It takes `query: ` and `passage: ` prefixes and uses those to generate embeddings that work well for asymmetric search.
-
-## backend
-```yaml
-backend: faiss|hnsw|annoy|numpy|torch|custom
-```
-
-Approximate Nearest Neighbor (ANN) index backend for storing generated sentence embeddings. `Defaults to faiss`. Additional backends require the
-[similarity](../../install/#similarity) extras package to be installed. Add custom backends via setting this parameter to the fully resolvable
-class string.
-
-Backend-specific settings are set with a corresponding configuration object having the same name as the backend (i.e. annoy, faiss, or hnsw). None of these are required and are set to defaults if omitted.
-
-### faiss
-```yaml
-faiss:
- components: comma separated list of components - defaults to "Flat" for small
- indices and "IVFx,Flat" for larger indexes where
- x = 4 * sqrt(embeddings count)
- nprobe: search probe setting (int) - defaults to x/16 (as defined above)
- for larger indexes
- quantize: store vectors with 8-bit precision vs 32-bit (boolean)
- defaults to false
- mmap: load as on-disk index (boolean) - trade query response time for a
- smaller RAM footprint, defaults to false
- sample: percent of data to use for model training (0.0 - 1.0)
- reduces indexing time for larger (>1M+ row) indexes, defaults to 1.0
-```
-
-See the following Faiss documentation links for more information.
-
-- [Guidelines for choosing an index](https://github.com/facebookresearch/faiss/wiki/Guidelines-to-choose-an-index)
-- [Index configuration summary](https://github.com/facebookresearch/faiss/wiki/Faiss-indexes)
-- [Index Factory](https://github.com/facebookresearch/faiss/wiki/The-index-factory)
-- [Search Tuning](https://github.com/facebookresearch/faiss/wiki/Faster-search)
-
-### hnsw
-```yaml
-hnsw:
- efconstruction: ef_construction param for init_index (int) - defaults to 200
- m: M param for init_index (int) - defaults to 16
- randomseed: random-seed param for init_index (int) - defaults to 100
- efsearch: ef search param (int) - defaults to None and not set
-```
-
-See [Hnswlib documentation](https://github.com/nmslib/hnswlib/blob/master/ALGO_PARAMS.md) for more information on these parameters.
-
-### annoy
-```yaml
-annoy:
- ntrees: number of trees (int) - defaults to 10
- searchk: search_k search setting (int) - defaults to -1
-```
-
-See [Annoy documentation](https://github.com/spotify/annoy#full-python-api) for more information on these parameters. Note that annoy indexes can not be modified after creation, upserts/deletes and other modifications are not supported.
-
-## content
-```yaml
-content: boolean|sqlite|duckdb|custom
-```
-
-Enables content storage. When true, the default storage engine, `sqlite` will be used to save metadata alongside embeddings vectors. Also supports `duckdb`. Add custom storage engines via setting this parameter to the fully resolvable class string.
-
-Content storage specific settings are set with a corresponding configuration object having the same name as the content storage engine (i.e. duckdb or sqlite). None of these are required and are set to defaults if omitted.
-
-### sqlite
-```yaml
-sqlite:
- wal: enable write-ahead logging - allows concurrent read/write operations,
- defaults to false
-```
-
-## objects
-```yaml
-objects: boolean
-```
-
-Enables object storage. When content storage is enabled and this is true, support for storing binary content alongside embeddings vectors and metadata is enabled.
-
-## functions
-```yaml
-functions: list
-```
-
-List of functions with user-defined SQL functions, only used when [content](#content) is enabled. Each list element must be one of the following:
-
-- function
-- callable object
-- dict with fields for name, argcount and function
-
-[An example can be found here](../query#custom-sql-functions).
-
-## query
-```yaml
-query:
- path: sets the path for the query model - this can be any model on the
- Hugging Face Model Hub or a local file path.
- prefix: text prefix to prepend to all inputs
- maxlength: maximum generated sequence length
-```
-
-Query translation model. Translates natural language queries to txtai compatible SQL statements.
-
-## graph
-```yaml
-graph:
- backend: graph network backend (string), defaults to "networkx"
- batchsize: batch query size, used to query embeddings index (int)
- defaults to 256
- limit: maximum number of results to return per embeddings query (int)
- defaults to 15
- minscore: minimum score required to consider embeddings query matches (float)
- defaults to 0.1
- approximate: when true, queries only run for nodes without edges (boolean)
- defaults to true
- topics: see below
-```
-
-Enables graph storage. When set, a graph network is built using the embeddings index. Graph nodes are synced with each embeddings index operation (index/upsert/delete). Graph edges are created using the embeddings index upon completion of each index/upsert/delete embeddings index call.
-
-Add custom graph storage engines via setting the `graph.backend` parameter to the fully resolvable class string.
-
-Defaults are tuned so that in most cases these values don't need to be changed.
-
-### topics
-```yaml
-topics:
- algorithm: community detection algorithm (string), options are
- louvain (default), greedy, lpa
- level: controls number of topics (string), options are best (default) or first
- resolution: controls number of topics (int), larger values create more
- topics (int), defaults to 100
- labels: scoring index method used to build topic labels (string)
- options are bm25 (default), tfidf, sif
- terms: number of frequent terms to use for topic labels (int), defaults to 4
- stopwords: optional list of stop words to exclude from topic labels
- categories: optional list of categories used to group topics, allows
- granular topics with broad categories grouping topics
-```
+## [Vectors](./vectors)
-Enables topic modeling. Defaults are tuned so that in most cases these values don't need to be changed (except for categories). These parameters are available for advanced use cases where one wants full control over the community detection process.
+Vector search is enabled by converting text and other binary data into embeddings vectors. These vectors are then stored in an ANN index. The vector model is optional and a default model is used when not provided.
diff --git a/docs/embeddings/configuration/vectors.md b/docs/embeddings/configuration/vectors.md
new file mode 100644
index 00000000..ac225bd3
--- /dev/null
+++ b/docs/embeddings/configuration/vectors.md
@@ -0,0 +1,105 @@
+# Vectors
+
+The following covers available vector model configuration options.
+
+## path
+```yaml
+path: string
+```
+
+Sets the path for a vectors model. When using a transformers/sentence-transformers model, this can be any model on the
+[Hugging Face Hub](https://huggingface.co/models) or a local file path. Otherwise, it must be a local file path to a word embeddings model.
+
+## method
+```yaml
+method: transformers|sentence-transformers|words|external
+```
+
+Sentence embeddings method to use. If the method is not provided, it is inferred using the `path`.
+
+`sentence-transformers` and `words` require the [similarity](../../../install/#similarity) extras package to be installed.
+
+### transformers
+
+Builds sentence embeddings using a transformers model. While this can be any transformers model, it works best with
+[models trained](https://huggingface.co/models?pipeline_tag=sentence-similarity) to build sentence embeddings.
+
+### sentence-transformers
+
+Same as transformers but loads models with the [sentence-transformers](https://github.com/UKPLab/sentence-transformers) library.
+
+### words
+
+Builds sentence embeddings using a word embeddings model. Transformers models are the preferred vector backend in most cases. Word embeddings models may be deprecated in the future.
+
+#### storevectors
+```yaml
+storevectors: boolean
+```
+
+Enables copying of a vectors model set in path into the embeddings models output directory on save. This option enables a fully encapsulated index with no external file dependencies.
+
+#### scoring
+```yaml
+scoring: bm25|tfidf|sif
+```
+
+A scoring model builds weighted averages of word vectors for a given sentence. Supports BM25, TF-IDF and SIF (smooth inverse frequency) methods. If a scoring method is not provided, mean sentence embeddings are built.
+
+#### pca
+```yaml
+pca: int
+```
+
+Removes _n_ principal components from generated sentence embeddings. When enabled, a TruncatedSVD model is built to help with dimensionality reduction. After pooling of vectors creates a single sentence embedding, this method is applied.
+
+### external
+
+Sentence embeddings are loaded via an external model or API. Requires setting the [transform](#transform) parameter to a function that translates data into vectors.
+
+#### transform
+```yaml
+transform: function
+```
+
+When method is `external`, this function transforms input content into embeddings. The input to this function is a list of data. This method must return either a numpy array or list of numpy arrays.
+
+#### gpu
+```yaml
+gpu: boolean|int|string|device
+```
+
+Set the target device. Supports true/false, device id, device string and torch device instance. This is automatically derived if omitted.
+
+## batch
+```yaml
+batch: int
+```
+
+Sets the transform batch size. This parameter controls how input streams are chunked and vectorized.
+
+## encodebatch
+```yaml
+encodebatch: int
+```
+
+Sets the encode batch size. This parameter controls the underlying vector model batch size. This often corresponds to a GPU batch size, which controls GPU memory usage.
+
+## tokenize
+```yaml
+tokenize: boolean
+```
+
+Enables string tokenization (defaults to false). This method applies tokenization rules that only work with English language text and may increase the quality of
+English language sentence embeddings in some situations.
+
+## instructions
+```yaml
+instructions:
+ query: prefix for queries
+ data: prefix for indexing
+```
+
+Instruction-based models use prefixes to modify how embeddings are computed. This is especially useful with asymmetric search, which is when the query and indexed data are of vastly different lengths. In other words, short queries with long documents.
+
+[E5-base](https://huggingface.co/intfloat/e5-base) is an example of a model that accepts instructions. It takes `query: ` and `passage: ` prefixes and uses those to generate embeddings that work well for asymmetric search.
\ No newline at end of file
diff --git a/docs/embeddings/index.md b/docs/embeddings/index.md
index f68917e1..9bfc4e9f 100644
--- a/docs/embeddings/index.md
+++ b/docs/embeddings/index.md
@@ -43,9 +43,9 @@ for query in ("feel good story", "climate change", "public health story", "war",
## Build
-An embeddings instance is [configuration-driven](configuration) based on what is passed in the constructor. Vectors are stored with the option to also [store content](configuration#content). Content storage enables additional filtering and data retrieval options.
+An embeddings instance is [configuration-driven](configuration) based on what is passed in the constructor. Vectors are stored with the option to also [store content](configuration/database#content). Content storage enables additional filtering and data retrieval options.
-The example above sets a specific embeddings vector model via the [path](configuration#path) parameter. An embeddings instance with no configuration can also be created.
+The example above sets a specific embeddings vector model via the [path](configuration/vectors/#path) parameter. An embeddings instance with no configuration can also be created.
```python
embeddings = Embeddings()
@@ -79,7 +79,7 @@ The index method takes an iterable and supports the following formats for each e
Single element to index. In this case, unique id's will automatically be generated. Note that for generated id's, [upsert](methods/#txtai.embeddings.base.Embeddings.upsert) and [delete](methods/#txtai.embeddings.base.Embeddings.delete) calls require a separate search to get the target ids.
-When the data field is a dictionary, text is passed via the `text` key, binary objects via the `object` key. Note that [content](configuration#content) must be enabled to store metadata and [objects](configuration#objects) to store binary object data. The `id` and `tags` keys will be extracted, if provided.
+When the data field is a dictionary, text is passed via the `text` key, binary objects via the `object` key. Note that [content](configuration/database#content) must be enabled to store metadata and [objects](configuration/database#objects) to store binary object data. The `id` and `tags` keys will be extracted, if provided.
The input iterable can be a list or generator. [Generators](https://wiki.python.org/moin/Generators) help with indexing very large datasets as only portions of the data is in memory at any given time.
@@ -93,7 +93,7 @@ Once data is indexed, it is ready for search.
embeddings.search(query, limit)
```
-The search method takes two parameters, the query and query limit. The results format is different based on whether [content](configuration/#content) is stored or not.
+The search method takes two parameters, the query and query limit. The results format is different based on whether [content](configuration/database#content) is stored or not.
- List of `(id, score)` when content is _not_ stored
- List of `{**query columns}` when content is stored
diff --git a/docs/embeddings/indexing.md b/docs/embeddings/indexing.md
index db7f1b82..f506b7cc 100644
--- a/docs/embeddings/indexing.md
+++ b/docs/embeddings/indexing.md
@@ -7,19 +7,19 @@ This section gives an in-depth overview on how to index data with txtai. We'll c
## Vectorization
-The most compute intensive step in building an index is vectorization. The [path](../configuration#path) parameter sets the path to the vector model. There is logic to automatically detect the vector model [method](../configuration#method) but it can also be set directly.
+The most compute intensive step in building an index is vectorization. The [path](../configuration/vectors#path) parameter sets the path to the vector model. There is logic to automatically detect the vector model [method](../configuration/vectors#method) but it can also be set directly.
-The [batch](../configuration#batch) and [encodebatch](../configuration#encodebatch) parameters control the vectorization process. Larger values for `batch` will pass larger batches to the vectorization method. Larger values for `encodebatch` will pass larger batches for each vector encode call. In the case of GPU vector models, larger values will consume more GPU memory.
+The [batch](../configuration/vectors#batch) and [encodebatch](../configuration/vectors#encodebatch) parameters control the vectorization process. Larger values for `batch` will pass larger batches to the vectorization method. Larger values for `encodebatch` will pass larger batches for each vector encode call. In the case of GPU vector models, larger values will consume more GPU memory.
-Data is buffered to temporary storage during indexing as embeddings vectors can be quite large (for example 768 dimensions of float32 is 768 * 4 = 3072 bytes per vector). Once vectorization is complete, a mmapped array is created with all vectors for [Approximate Nearest Neighbor (ANN)](../configuration#backend) indexing.
+Data is buffered to temporary storage during indexing as embeddings vectors can be quite large (for example 768 dimensions of float32 is 768 * 4 = 3072 bytes per vector). Once vectorization is complete, a mmapped array is created with all vectors for [Approximate Nearest Neighbor (ANN)](../configuration/vectors#backend) indexing.
## Setting a backend
-As mentioned above, computed vectors are stored in an ANN. There are various index [backends](../configuration#backend) that can be configured. Faiss is the default backend.
+As mentioned above, computed vectors are stored in an ANN. There are various index [backends](../configuration/ann#backend) that can be configured. Faiss is the default backend.
## Content storage
-Embeddings indexes can optionally [store content](../configuration#content). When this is enabled, the input content is saved in a database alongside the computed vectors. This enables filtering on additional fields and content retrieval.
+Embeddings indexes can optionally [store content](../configuration/database#content). When this is enabled, the input content is saved in a database alongside the computed vectors. This enables filtering on additional fields and content retrieval.
## Index vs Upsert
@@ -70,7 +70,7 @@ embeddings.delete(ids)
## Reindex
-When [content storage](../configuration#content) is enabled, [reindex](../methods#txtai.embeddings.base.Embeddings.reindex) can be called to rebuild the index with new settings. For example, the backend can be switched from faiss to hnsw or the vector model can be updated. This prevents having to go back to the original raw data.
+When [content storage](../configuration/database#content) is enabled, [reindex](../methods#txtai.embeddings.base.Embeddings.reindex) can be called to rebuild the index with new settings. For example, the backend can be switched from faiss to hnsw or the vector model can be updated. This prevents having to go back to the original raw data.
```python
embeddings.reindex(path="sentence-transformers/all-MiniLM-L6-v2", backend="hnsw")
@@ -80,7 +80,7 @@ embeddings.reindex(path="sentence-transformers/all-MiniLM-L6-v2", backend="hnsw"
Dimensionality reduction with UMAP combined with HDBSCAN is a popular topic modeling method found in a number of libraries. txtai takes a different approach with a semantic graph.
-Enabling a [graph network](../configuration#graph) adds a semantic graph at index time as data is being vectorized. Vector embeddings are used to create relationships in the graph. Finally, community detection algorithms build topic clusters. Semantic graphs can also be used to analyze data connectivity.
+Enabling a [graph network](../configuration/graph) adds a semantic graph at index time as data is being vectorized. Vector embeddings are used to create relationships in the graph. Finally, community detection algorithms build topic clusters. Semantic graphs can also be used to analyze data connectivity.
This approach has the advantage of only having to vectorize data once. It also has the advantage of better topic precision given there isn't a dimensionality reduction operation (UMAP). Semantic graph examples are shown below.
@@ -106,7 +106,7 @@ Graphs are persisted alongside an embeddings index. Each save and load will also
## Scoring
-When using [word vector backed models](../configuration#words) with scoring set, a separate call is required before calling `index` as follows:
+When using [word vector backed models](../configuration/vectors#words) with scoring set, a separate call is required before calling `index` as follows:
```python
embeddings.score(rows)
diff --git a/docs/embeddings/query.md b/docs/embeddings/query.md
index 796262fe..3f473367 100644
--- a/docs/embeddings/query.md
+++ b/docs/embeddings/query.md
@@ -18,7 +18,7 @@ The queries above [search](../methods#txtai.embeddings.base.Embeddings.search) t
## SQL
-txtai supports more complex queries with SQL. This is only supported if [content storage](../configuration/#content) is enabled. txtai has a translation layer that analyzes input SQL statements and combines similarity results with content stored in a relational database.
+txtai supports more complex queries with SQL. This is only supported if [content storage](../configuration/database#content) is enabled. txtai has a translation layer that analyzes input SQL statements and combines similarity results with content stored in a relational database.
SQL queries are run through `embeddings.search` like natural language queries but the examples below only show the SQL query for conciseness.
@@ -159,7 +159,7 @@ select id, text, score from txtai where similar('feel good story') and
entry >= date('now', '-1 day')
```
-This requires setting a [query translation model](../configuration#query). The default query translation model is [t5-small-txtsql](https://huggingface.co/NeuML/t5-small-txtsql) but this can easily be finetuned to handle different use cases.
+This requires setting a [query translation model](../configuration/database#query). The default query translation model is [t5-small-txtsql](https://huggingface.co/NeuML/t5-small-txtsql) but this can easily be finetuned to handle different use cases.
## Combined index architecture
diff --git a/mkdocs.yml b/mkdocs.yml
index 6f9899c6..e285e158 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -59,7 +59,12 @@ nav:
- embeddings/index.md
- Configuration:
- embeddings/configuration/index.md
+ - ANN: embeddings/configuration/ann.md
- Cloud: embeddings/configuration/cloud.md
+ - Database: embeddings/configuration/database.md
+ - General: embeddings/configuration/general.md
+ - Graph: embeddings/configuration/graph.md
+ - Vectors: embeddings/configuration/vectors.md
- Index Guide: embeddings/indexing.md
- Methods: embeddings/methods.md
- Query Guide: embeddings/query.md