Skip to content

armgit / txtai

Public Imported from GitHub
0

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

Documentation updates

davidmezzettif1e05a442a7a
diff --git a/docs/api.md b/docs/api.md
index 8cb15012..b28eedc4 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -13,8 +13,7 @@ writable: True
# Enbeddings index
embeddings:
- method: transformers
- path: sentence-transformers/bert-base-nli-mean-tokens
+ path: sentence-transformers/nli-mpnet-base-v2
# Extractive QA
extractor:
diff --git a/docs/embeddings.md b/docs/embeddings.md
index b7e08354..da0cddfe 100644
--- a/docs/embeddings.md
+++ b/docs/embeddings.md
@@ -6,10 +6,11 @@ Embeddings parameters are set through the constructor. Examples below.
```python
# Transformers embeddings model
Embeddings({"method": "transformers",
- "path": "sentence-transformers/bert-base-nli-mean-tokens"})
+ "path": "sentence-transformers/nli-mpnet-base-v2"})
# Word embeddings model
-Embeddings({"path": vectors,
+Embeddings({"method": "words",
+ "path": vectors,
"storevectors": True,
"scoring": "bm25",
"pca": 3,
@@ -23,7 +24,8 @@ Embeddings({"path": vectors,
method: transformers|words
```
-Sets the sentence embeddings method to use. When set to _transformers_, the embeddings object builds sentence embeddings using the sentence transformers. Otherwise a word embeddings model is used. Defaults to words.
+Sets the sentence embeddings method to use. When set to _transformers_, the embeddings object builds sentence embeddings using a sentence transformers model.
+Otherwise a word embeddings model is used. The method is inferred using the _path_ if not provided.
### path
```yaml
@@ -38,38 +40,27 @@ it must be a path to a local word embeddings model.
tokenize: boolean
```
-Enables string tokenization (defaults to true). This method applies tokenization rules that work best with English language text and help increase the
-quality of English language sentence embeddings. This should be disabled when working with non-English text.
+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.
-### 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
+### backend
```yaml
-scoring: bm25|tfidf|sif
+backend: faiss|annoy|hnsw
```
-For word embedding models, a scoring model allows building 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
-```
+Approximate Nearest Neighbor (ANN) index backend for storing generated sentence embeddings. Defaults to Faiss. Additional backends require the "similarity extras
+package to be installed.
-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.
+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
+### faiss
```yaml
-backend: annoy|faiss|hnsw
+faiss:
+ components: Comma separated list of components - defaults to None
+ nprobe: search probe setting (int) - defaults to 6
```
-Approximate Nearest Neighbor (ANN) index backend for storing generated sentence embeddings. Defaults to Faiss for Linux/macOS and Annoy for Windows. Faiss currently is not supported on Windows.
-
-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.
+See Faiss documentation on the [index factory](https://github.com/facebookresearch/faiss/wiki/The-index-factory) and [search](https://github.com/facebookresearch/faiss/wiki/Faster-search) for more information on these parameters.
### annoy
```yaml
@@ -80,15 +71,6 @@ annoy:
See [Annoy documentation](https://github.com/spotify/annoy#full-python-api) for more information on these parameters.
-### faiss
-```yaml
-faiss:
- components: Comma separated list of components - defaults to None
- nprobe: search probe setting (int) - defaults to 6
-```
-
-See Faiss documentation on the [index factory](https://github.com/facebookresearch/faiss/wiki/The-index-factory) and [search](https://github.com/facebookresearch/faiss/wiki/Faster-search) for more information on these parameters.
-
### hnsw
```yaml
hnsw:
@@ -108,6 +90,33 @@ quantize: boolean
Enables quanitization of generated sentence embeddings. If the index backend supports it, sentence embeddings will be stored with 8-bit precision vs 32-bit.
Only Faiss currently supports quantization.
+## Additional configuration for Word embedding models
+
+Word embeddings provide a good tradeoff of performance to functionality for a similarity search system. With that being said, Transformers models are making great progress in scaling performance down to smaller models and are the preferred vector backend in txtai for most cases.
+
+Word embeddings models require the [similarity](https://neuml.github.io/txtai/install/) extras package to be installed.
+
+### 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.
+
::: txtai.embeddings.Embeddings.__init__
::: txtai.embeddings.Embeddings.batchsearch
::: txtai.embeddings.Embeddings.batchsimilarity
diff --git a/docs/install.md b/docs/install.md
index 5c8aff4b..f5fca6dd 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -8,41 +8,67 @@ You can also install txtai directly from GitHub. Using a Python Virtual Environm
pip install git+https://github.com/neuml/txtai
-Python 3.6+ is supported.
+Python 3.6+ is supported. Additional environment specific prerequisites are below.
+
+## Linux
+
+Optional audio transcription requires a [system library to be installed](https://github.com/bastibe/python-soundfile#installation)
+
+## macOS
+
+Run `brew install libomp` see [this link](https://github.com/kyamagu/faiss-wheels#prerequisite)
+
+## Windows
+
+Optional dependencies require [C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/)
+
+## Optional dependencies
txtai has the following optional dependencies that can be installed as extras. The patterns below are supported
in setup.py install_requires sections.
+### All
+
+Install all dependencies (mirrors txtai < 3.2)
+
```
-# Install all dependencies (mirrors txtai < 3.2)
pip install txtai[all]
+```
-# Serve txtai via a web API
-pip install txtai[api]
+### API
-# All pipelines - default install comes with most common pipelines
-pip install txtai[pipeline]
+Serve txtai via a web API.
-# Word vectors, support for sentence-transformer models not on the HF Hub and additional ANN libraries
-pip install txtai[similarity]
+```
+pip install txtai[api]
+```
-# All workflow tasks - default install comes with most common workflow tasks
-pip install txtai[workflow]
+### Pipeline
+
+All pipelines - default install comes with most common pipelines.
-# Pipelines and workflows
-pip install txtai[pipeline,workflow]
+```
+pip install txtai[pipeline]
```
-Additional environment specific prerequisites are below.
+### Similarity
-## Linux
+Word vectors, support for sentence-transformers models not on the HF Hub and additional ANN libraries.
-Optional audio transcription requires a [system library to be installed](https://github.com/bastibe/python-soundfile#installation)
+```
+pip install txtai[similarity]
+```
-## macOS
+### Workflow
-Run `brew install libomp` see [this link](https://github.com/kyamagu/faiss-wheels#prerequisite)
+All workflow tasks - default install comes with most common workflow tasks.
-## Windows
+```
+pip install txtai[workflow]
+```
-Optional dependencies require [C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/)
+Multiple dependencies can be specified at the same time.
+
+```
+pip install txtai[pipeline,workflow]
+```