Skip to content

armgit / txtai

Public Imported from GitHub
0

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

Update documentation

davidmezzetti9ba3009da098
diff --git a/docs/embeddings/configuration/ann.md b/docs/embeddings/configuration/ann.md
index ee4f31ce..883aeb02 100644
--- a/docs/embeddings/configuration/ann.md
+++ b/docs/embeddings/configuration/ann.md
@@ -1,17 +1,15 @@
# ANN
-The following covers the available vector index configuration options.
+Approximate Nearest Neighbor (ANN) index configuration for storing vector embeddings.
## backend
```yaml
-backend: faiss|hnsw|annoy|numpy|torch|custom
+backend: faiss|hnsw|annoy|numpy|torch|pgvector|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.
+Sets the ANN backend. Defaults to `faiss`. Additional backends are available via the [ann](../../../install/#ann) extras package. Set 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.
+Backend-specific settings are set with a corresponding configuration object having the same name as the backend (i.e. annoy, faiss, or hnsw). These are optional and set to defaults if omitted.
### faiss
```yaml
@@ -23,7 +21,7 @@ faiss:
nprobe: search probe setting (int) - defaults to x/16 (as defined above)
for larger indexes
nflip: same as nprobe - only used with binary hash indexes
- quantize: store vectors with x-bit precision vs 32-bit (bool|int)
+ quantize: store vectors with x-bit precision vs 32-bit (boolean|int)
true sets 8-bit precision, false disables, int sets specified
precision
mmap: load as on-disk index (boolean) - trade query response time for a
@@ -61,3 +59,25 @@ annoy:
```
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.
+
+### numpy
+```yaml
+numpy:
+ quantize: number of quantized bits when working with quantized vectors (int)
+```
+
+The NumPy backend is a k-nearest neighbors backend. It's designed for simplicity and works well with smaller datasets.
+
+The `torch` backend supports the same options. The only difference is that the vectors can be search using GPUs.
+
+### pgvector
+```yaml
+pgvector:
+ url: database url connection string, alternatively can be set via
+ ANN_URL environment variable
+ table: database table to store vectors - defaults to `vectors`
+ efconstruction: ef_construction param (int) - defaults to 200
+ m: M param for init_index (int) - defaults to 16
+```
+
+The pgvector backend stores embeddings in a Postgres database. See the [pgvector documentation](https://github.com/pgvector/pgvector-python?tab=readme-ov-file#sqlalchemy) for more information on these parameters. See the [SQLAlchemy](https://docs.sqlalchemy.org/en/20/core/engines.html#database-urls) documentation for more information on how to construct url connection strings.
diff --git a/docs/embeddings/configuration/database.md b/docs/embeddings/configuration/database.md
index d22ecf64..6c74bec6 100644
--- a/docs/embeddings/configuration/database.md
+++ b/docs/embeddings/configuration/database.md
@@ -1,19 +1,19 @@
# Database
-The following covers available content storage configuration options.
+Databases store metadata, text and binary content.
## content
```yaml
content: boolean|sqlite|duckdb|client|url|custom
```
-Enables content storage. When true, the default storage engine, `sqlite` will be used to save metadata alongside embeddings vectors.
+Enables content storage. When true, the default storage engine, `sqlite` will be used to save metadata.
Client-server connections are supported with either `client` or a full connection URL. When set to `client`, the CLIENT_URL environment variable must be set to the full connection URL. See the [SQLAlchemy](https://docs.sqlalchemy.org/en/20/core/engines.html#database-urls) documentation for more information on how to construct connection strings for client-server databases.
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.
+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). These are optional and set to defaults if omitted.
### sqlite
```yaml
@@ -27,7 +27,7 @@ sqlite:
objects: boolean|image|pickle
```
-Enables object storage. Supports storing binary content alongside embeddings vectors and metadata. Requires content storage to also be enabled.
+Enables object storage. Supports storing binary content. Requires content storage to also be enabled.
Object encoding options are:
diff --git a/docs/embeddings/configuration/graph.md b/docs/embeddings/configuration/graph.md
index 231fc037..53408145 100644
--- a/docs/embeddings/configuration/graph.md
+++ b/docs/embeddings/configuration/graph.md
@@ -1,29 +1,57 @@
# Graph
-The following covers available graph configuration options.
+Enable graph storage via the `graph` parameter. This component requires the [graph](../../../install/#graph) extras package.
-## graph
+When enabled, 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.
+
+## backend
+```yaml
+backend: networkx|rdbms|custom
+```
+
+Sets the graph backend. Defaults to `networkx`.
+
+Add custom graph storage engines via setting this parameter to the fully resolvable class string.
+
+The `rdbms` backend has the following additional settings.
+
+### rdbms
+```yaml
+url: database url connection string, alternatively can be set via the
+ GRAPH_URL environment variable
+nodes: table to store node data, defaults to `nodes`
+edges: table to store edge data, defaults to `edges`
+```
+
+## batchsize
```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
+batchsize: int
```
-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.
+Batch query size, used to query embeddings index - defaults to 256.
-Add custom graph storage engines via setting the `graph.backend` parameter to the fully resolvable class string.
+## limit
+```yaml
+limit: int
+```
+
+Maximum number of results to return per embeddings query - defaults to 15.
+
+## minscore
+```yaml
+minscore: float
+```
+
+Minimum score required to consider embeddings query matches - defaults to 0.1.
+
+## approximate
+```yaml
+approximate: boolean
+```
-Defaults are tuned so that in most cases these values don't need to be changed.
+When true, queries only run for nodes without edges - defaults to true.
-### topics
+## topics
```yaml
topics:
algorithm: community detection algorithm (string), options are
diff --git a/docs/embeddings/configuration/scoring.md b/docs/embeddings/configuration/scoring.md
index 67098fec..d5870b71 100644
--- a/docs/embeddings/configuration/scoring.md
+++ b/docs/embeddings/configuration/scoring.md
@@ -1,12 +1,14 @@
# Scoring
-An embeddings instance can optionally have an associated scoring instance. This scoring instance can serve two purposes, depending on the settings.
+Enable scoring support via the `scoring` parameter.
+
+This scoring instance can serve two purposes, depending on the settings.
One use case is building sparse/keyword indexes. This occurs when the `terms` parameter is set to `True`.
The other use case is with word vector term weighting. This feature has been available since the initial version but isn't quite as common anymore.
-The following covers the available options
+The following covers the available options.
## method
```yaml
diff --git a/docs/embeddings/configuration/vectors.md b/docs/embeddings/configuration/vectors.md
index 563807a9..35e81d6a 100644
--- a/docs/embeddings/configuration/vectors.md
+++ b/docs/embeddings/configuration/vectors.md
@@ -15,14 +15,14 @@ Sets the path for a vectors model. When using a transformers/sentence-transforme
method: transformers|sentence-transformers|words|external
```
-Sentence embeddings method to use. If the method is not provided, it is inferred using the `path`.
+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.
+`sentence-transformers` and `words` require the [vectors](../../../install/#vectors) 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.
+Builds 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 embeddings.
Both `mean` and `cls` pooling are supported and automatically infered from the model. The pooling method can be overwritten by changing the method
from `transformers` to `meanpooling` or `clspooling` respectively.
@@ -33,7 +33,7 @@ Same as transformers but loads models with the [sentence-transformers](https://g
### 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.
+Builds 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
@@ -47,11 +47,11 @@ Enables copying of a vectors model set in path into the embeddings models output
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.
+Removes _n_ principal components from generated embeddings. When enabled, a TruncatedSVD model is built to help with dimensionality reduction. After pooling of vectors creates a single 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.
+Embeddings are created via an external model or API. Requires setting the [transform](#transform) parameter to a function that translates data into embeddings.
#### transform
```yaml
@@ -90,7 +90,7 @@ Enables truncation of vectors to this dimensionality. This is only useful for mo
## quantize
```yaml
-quantize: int|bool
+quantize: int|boolean
```
Enables scalar quantization at the specified precision. Supports 1-bit through 8-bit quantization. Scalar quantization transforms continuous floating point values
diff --git a/src/python/txtai/embeddings/base.py b/src/python/txtai/embeddings/base.py
index d8a3087d..d1b02cf6 100644
--- a/src/python/txtai/embeddings/base.py
+++ b/src/python/txtai/embeddings/base.py
@@ -324,7 +324,7 @@ class Embeddings:
# Default vector model, if necessary
model = self.model if self.model else self.indexes.model()
- # Convert documents into sentence embeddings
+ # Convert documents into embeddings
embeddings = model.batchtransform(Stream(self)(documents), category)
# Reduce the dimensionality of the embeddings. Scale the embeddings using this
@@ -613,7 +613,7 @@ class Embeddings:
# Create output directory, if necessary
os.makedirs(path, exist_ok=True)
- # Copy sentence vectors model
+ # Copy vectors model
if self.config.get("storevectors"):
shutil.copyfile(self.config["path"], os.path.join(path, os.path.basename(self.config["path"])))
diff --git a/src/python/txtai/vectors/base.py b/src/python/txtai/vectors/base.py
index 6181d2aa..84405862 100644
--- a/src/python/txtai/vectors/base.py
+++ b/src/python/txtai/vectors/base.py
@@ -12,7 +12,7 @@ from ..version import __pickle__
class Vectors:
"""
- Base class for sentence embeddings/vector models. Vector models transform input content into numeric vectors.
+ Base class for vector models. Vector models transform input content into numeric vectors.
"""
def __init__(self, config, scoring, models):
diff --git a/src/python/txtai/vectors/external.py b/src/python/txtai/vectors/external.py
index 9f096f61..8a621322 100644
--- a/src/python/txtai/vectors/external.py
+++ b/src/python/txtai/vectors/external.py
@@ -13,8 +13,7 @@ from .base import Vectors
class ExternalVectors(Vectors):
"""
- Loads pre-computed vectors. Pre-computed vectors allow integrating other vector models. They can also be used to efficiently
- test different model configurations without having to recompute vectors.
+ Builds vectors using an external method. This can be a local function or an external API call.
"""
def __init__(self, config, scoring, models):
diff --git a/src/python/txtai/vectors/transformers.py b/src/python/txtai/vectors/transformers.py
index 0f4483a6..f666da07 100644
--- a/src/python/txtai/vectors/transformers.py
+++ b/src/python/txtai/vectors/transformers.py
@@ -17,7 +17,7 @@ from ..pipeline import Tokenizer
class TransformersVectors(Vectors):
"""
- Builds sentence embeddings/vectors using the transformers library.
+ Builds vectors using the transformers library.
"""
def loadmodel(self, path):
diff --git a/src/python/txtai/vectors/words.py b/src/python/txtai/vectors/words.py
index 592e6035..35924604 100644
--- a/src/python/txtai/vectors/words.py
+++ b/src/python/txtai/vectors/words.py
@@ -65,7 +65,7 @@ def transform(document):
class WordVectors(Vectors):
"""
- Builds sentence embeddings/vectors using weighted word embeddings.
+ Builds vectors using weighted word embeddings.
"""
def loadmodel(self, path):