💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows
Python agentsaiai-agentsembeddingsinformation-retrievallanguage-modellarge-language-modelsllmnlppythonragretrieval-augmented-generationsearchsearch-enginesemantic-searchsentence-embeddingstransformerstxtaivector-databasevector-search
Integrate txtai python docs into doc site, fix python doc error
davidmezzetti5f7bcc3f902c
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.ymlindex 872f684a..808cc523 100644--- a/.github/workflows/docs.yml+++ b/.github/workflows/docs.yml@@ -11,6 +11,6 @@ jobs:- uses: actions/setup-python@v2with:python-version: 3.6- - run: pip install mkdocs-material+ - run: pip install mkdocs-material mkdocstrings- run: mkdocs gh-deploy --force\ No newline at end of filediff --git a/docs/api.md b/docs/api.mdindex ae485be5..b3febee7 100644--- a/docs/api.md+++ b/docs/api.md@@ -72,3 +72,5 @@ The following programming languages have txtai bindings:- [Go](https://github.com/neuml/txtai.go)See each of the projects above for details on how to install and use. Please add an issue to request additional language bindings!++::: txtai.api.application\ No newline at end of filediff --git a/docs/embeddings.md b/docs/embeddings.mdindex 81671dbb..d27ac95e 100644--- a/docs/embeddings.md+++ b/docs/embeddings.md@@ -1,5 +1,4 @@# Embeddings-An Embeddings instance is the engine that provides similarity search. Embeddings can be used to run ad-hoc similarity comparisions or build/search large indices.Embeddings parameters are set through the constructor. Examples below.@@ -17,14 +16,16 @@ Embeddings({"path": vectors,"quantize": True})```-## method+## Configuration++### method```yamlmethod: 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.-## path+### path```yamlpath: string```@@ -32,7 +33,7 @@ path: stringRequired field that sets the path for a vectors model. When method set to _transformers_, this must be a path to a Hugging Face transformers model. Otherwise,it must be a path to a local word embeddings model.-## tokenize+### tokenize```yamltokenize: boolean```@@ -40,28 +41,28 @@ tokenize: booleanEnables string tokenization (defaults to true). This method applies tokenization rules that work best with English language text and help increase thequality of English language sentence embeddings. This should be disabled when working with non-English text.-## storevectors+### storevectors```yamlstorevectors: 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+### scoring```yamlscoring: bm25|tfidf|sif```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+### pca```yamlpca: 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.-## backend+### backend```yamlbackend: annoy|faiss|hnsw```@@ -70,39 +71,51 @@ Approximate Nearest Neighbor (ANN) index backend for storing generated sentenceBackend-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.-## annoy+### annoy```yamlannoy:- ntrees: number of trees (int) - defaults to 10- searchk: search_k search setting (int) - defaults to -1+ 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.-## faiss+### faiss```yamlfaiss:- components: Comma separated list of components - defaults to None- nprobe: search probe setting (int) - defaults to 6+ 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+### hnsw```yamlhnsw:- 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 (init) - defaults to 100- efsearch: ef search param (int) - defaults to None and not set+ 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 (init) - 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.-## quantize+### quantize```yamlquantize: 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.++::: txtai.embeddings.Embeddings.__init__+::: txtai.embeddings.Embeddings.batchsearch+::: txtai.embeddings.Embeddings.batchsimilarity+::: txtai.embeddings.Embeddings.batchtransform+::: txtai.embeddings.Embeddings.index+::: txtai.embeddings.Embeddings.load+::: txtai.embeddings.Embeddings.save+::: txtai.embeddings.Embeddings.score+::: txtai.embeddings.Embeddings.search+::: txtai.embeddings.Embeddings.similarity+::: txtai.embeddings.Embeddings.transformdiff --git a/docs/pipelines/extractor.md b/docs/pipelines/extractor.mdindex fd83c955..306e6405 100644--- a/docs/pipelines/extractor.md+++ b/docs/pipelines/extractor.md@@ -8,16 +8,5 @@ Extractor parameters are set as constructor arguments. Examples below.Extractor(embeddings, path, quantize, gpu, model, tokenizer)```-## embeddings-```yaml-embeddings: Embeddings object instance-```--Embeddings object instance. Used to query and find candidate text snippets to run the question-answer model against.--## tokenizer-```yaml-tokenizer: Tokenizer function-```--Optional custom tokenizer function to parse input queries+::: txtai.pipeline.Extractor.__init__+::: txtai.pipeline.Extractor.__call__diff --git a/docs/pipelines/labels.md b/docs/pipelines/labels.mdindex d3fe14d9..f80bd37d 100644--- a/docs/pipelines/labels.md+++ b/docs/pipelines/labels.md@@ -8,3 +8,6 @@ Labels parameters are set as constructor arguments. Examples below.Labels()Labels("roberta-large-mnli")```++::: txtai.pipeline.Labels.__init__+::: txtai.pipeline.Labels.__call__diff --git a/docs/pipelines/overview.md b/docs/pipelines/overview.mdindex fdd65962..868f63a2 100644--- a/docs/pipelines/overview.md+++ b/docs/pipelines/overview.md@@ -1,31 +1,17 @@# Pipelines-txtai provides a light wrapper around a couple of the Hugging Face pipelines. All pipelines have the following common parameters.--### path-```yaml-path: string-```--Required path to a Hugging Face model--### quantize-```yaml-quantize: boolean-```--Enables dynamic quantization of the Hugging Face model. This is a runtime setting and doesn't save space. It is used to improve the inference time performance of models.--### gpu-```yaml-gpu: boolean-```--Enables GPU inference.--### model-```yaml-model: Hugging Face pipeline or txtai pipeline-```--Shares the underlying model of the passed in pipeline with this pipeline. This allows having variations of a pipeline without having to store multiple copies of the full model in memory.+txtai provides a generic pipeline processing framework with the only interface requirement being a `__call__` method. Pipelines are flexible and can+process various types of data. Pipelines can wrap machine learning models as well as other processes.++The following pipeline types are currently supported.++- Hugging Face pipelines+ - [Extractive QA](/pipelines/extractor)+ - [Labeling](/pipelines/labels)+ - [Similarity](/pipelines/similarity)+ - [Summary](/pipelines/summary)+- Hugging Face models+ - [Transcription](/pipelines/transcription)+ - [Translation](/pipelines/translation)+- Data processing calls+ - [Text extraction](/pipelines/textractor)diff --git a/docs/pipelines/similarity.md b/docs/pipelines/similarity.mdindex 87f4c765..028d30c4 100644--- a/docs/pipelines/similarity.md+++ b/docs/pipelines/similarity.md@@ -8,3 +8,6 @@ Similarity parameters are set as constructor arguments. Examples below.Similarity()Similarity("roberta-large-mnli")```++::: txtai.pipeline.Similarity.__init__+::: txtai.pipeline.Similarity.__call__diff --git a/docs/pipelines/summary.md b/docs/pipelines/summary.mdnew file mode 100644index 00000000..6b176832--- /dev/null+++ b/docs/pipelines/summary.md@@ -0,0 +1,13 @@+# Summary++A Summary pipeline summarizes text.++Summary parameters are set as constructor arguments. Examples below.++```python+Summary()+Summary("sshleifer/distilbart-cnn-12-3")+```++::: txtai.pipeline.Summary.__init__+::: txtai.pipeline.Summary.__call__diff --git a/docs/pipelines/textractor.md b/docs/pipelines/textractor.mdnew file mode 100644index 00000000..a9248474--- /dev/null+++ b/docs/pipelines/textractor.md@@ -0,0 +1,12 @@+# Textractor++A Textractor pipeline extracts and splits text from documents.++Textractor parameters are set as constructor arguments. Examples below.++```python+Textractor()+```++::: txtai.pipeline.Textractor.__init__+::: txtai.pipeline.Textractor.__call__diff --git a/docs/pipelines/transcription.md b/docs/pipelines/transcription.mdnew file mode 100644index 00000000..332cd93c--- /dev/null+++ b/docs/pipelines/transcription.md@@ -0,0 +1,13 @@+# Transcription++A Transcription pipeline converts speech in audio files to text.++Transcription parameters are set as constructor arguments. Examples below.++```python+Transcription()+Transcription("facebook/wav2vec2-large-960h")+```++::: txtai.pipeline.Transcription.__init__+::: txtai.pipeline.Transcription.__call__diff --git a/docs/pipelines/translation.md b/docs/pipelines/translation.mdnew file mode 100644index 00000000..2ef2c7cf--- /dev/null+++ b/docs/pipelines/translation.md@@ -0,0 +1,12 @@+# Translation++A Translation pipeline translates text between languages++Translation parameters are set as constructor arguments. Examples below.++```python+Translation()+```++::: txtai.pipeline.Translation.__init__+::: txtai.pipeline.Translation.__call__diff --git a/docs/workflows.md b/docs/workflows.mdnew file mode 100644index 00000000..b83467f9--- /dev/null+++ b/docs/workflows.md@@ -0,0 +1,58 @@+# Workflows++Workflows are a simple yet powerful construct that takes a callable and returns elements. Workflows don't know they are working with pipelines but enable efficient processing of pipeline data. Workflows are streaming by nature and work on data in batches, allowing large volumes of data to be processed efficiently.++An example Workflow is shown below. This workflow will work with both documents and audio files. Documents will have text extracted and summarized. Audio files will be transcribed. Both results will be joined, translated into French and loaded into an Embeddings index.++```python+# file:// prefixes are required to signal to the workflow this is a file and not a text string+files = [+ "file://txtai/article.pdf",+ "file://txtai/US_tops_5_million.wav",+ "file://txtai/Canadas_last_fully.wav",+ "file://txtai/Beijing_mobilises.wav",+ "file://txtai/The_National_Park.wav",+ "file://txtai/Maine_man_wins_1_mil.wav",+ "file://txtai/Make_huge_profits.wav"+]++data = [(x, element, None) for x, element in enumerate(files)]++# Workflow that extracts text and builds a summary+articles = Workflow([+ FileTask(textractor),+ Task(lambda x: summary([y[:1024] for y in x]))+])++# Define workflow tasks. Workflows can also be tasks!+tasks = [+ WorkflowTask(articles, r".\.pdf$"),+ FileTask(transcribe, r"\.wav$"),+ Task(lambda x: translate(x, "fr")),+ Task(index, unpack=False)+]++# Workflow that translates text to French+workflow = Workflow(tasks)+for _ in workflow(data):+ pass+```++::: txtai.workflow.Workflow.__init__+::: txtai.workflow.Workflow.__call__++## Tasks++::: txtai.workflow.Task.__init__++### File Task++Task that processes file urls++### Image Task++Task that processes image urls++### Workflow Task++Task that runs a Workflow. Allows creating workflows of workflows.diff --git a/mkdocs.yml b/mkdocs.ymlindex f5f94e13..558b5a47 100644--- a/mkdocs.yml+++ b/mkdocs.yml@@ -1,4 +1,11 @@+#+# txtai Material for MkDocs configuration+#+site_name: txtai+repo_name: neuml/txtai+repo_url: https://github.com/neuml/txtai+copyright: © NeuML LLC, Apache-2.0 Licensetheme:name: materiallogo: images/logo.png@@ -8,9 +15,18 @@ theme:palette:primary: blueaccent: blue-copyright: © NeuML LLC, Apache-2.0 License-repo_name: neuml/txtai-repo_url: https://github.com/neuml/txtai+plugins:+ - search+ - mkdocstrings:+ handlers:+ python:+ rendering:+ show_root_full_path: false+ show_root_heading: true+ show_root_toc_entry: false+markdown_extensions:+ - pymdownx.highlight+ - pymdownx.superfencesnav:- Home: index.md- Installation: install.md@@ -21,4 +37,9 @@ nav:- Extractor: pipelines/extractor.md- Labels: pipelines/labels.md- Similarity: pipelines/similarity.md+ - Summary: pipelines/summary.md+ - Textractor: pipelines/textractor.md+ - Transcription: pipelines/transcription.md+ - Translation: pipelines/translation.md+ - Workflows: workflows.md- API: api.mddiff --git a/src/python/txtai/pipeline/transcription.py b/src/python/txtai/pipeline/transcription.pyindex 9c59f64b..0d9471fe 100644--- a/src/python/txtai/pipeline/transcription.py+++ b/src/python/txtai/pipeline/transcription.py@@ -29,7 +29,6 @@ class Transcription(HFModel):quantize: if model should be quantized, defaults to Falsegpu: True/False if GPU should be enabled, also supports a GPU device idbatch: batch size used to incrementally process content- langdetect: path to language detection model, uses a default path if not provided"""# Call parent constructor