一个功能强大的嵌入式数据库,整合了语义搜索、LLM编排和语言模型工作流。

davidmezzetti 3d4f97a035 Update documentation 1 day ago
.github 9d71aba655 Update build script 2 weeks ago
docker 099314adf4 Add RAG example application and Dockerfile, closes #743 2 weeks ago
docs f32218854c Update documentation 5 days ago
examples dd1067c877 Add streaming LLM support, closes #680 1 day ago
src 3d4f97a035 Update documentation 1 day ago
test dd1067c877 Add streaming LLM support, closes #680 1 day ago
.coveragerc 16ffac2741 Add txtai console, closes #252 2 years ago
.gitignore eb7f5ed68b Add custom detection function for language detection 1 year ago
.pre-commit-config.yaml e3ddc5e9de Update pylint and black versions in pre-commit 1 year ago
.pylintrc e3ddc5e9de Update pylint and black versions in pre-commit 1 year ago
CITATION.cff 38d0288857 Update documentation 11 months ago
LICENSE b8d339a92b Update LICENSE year 3 years ago
Makefile fb3440a141 Add support for binary content and MessagePack, closes #630, closes #658 5 months ago
README.md 98e5b75b03 Add txtai article link 1 week ago
apps.jpg 483f24765e Update txtai app image 1 year ago
demo.gif fdb2ae2828 Update documentation with new demo and diagrams, closes #313 2 years ago
logo.png f2e89d9b2d Update documentation 11 months ago
mkdocs.yml be28c76b7b Rename Extractor pipeline to RAG, closes #736 3 weeks ago
pyproject.toml 178c7cdc0a Add dev requirements, pre-commit hooks and psf black config for #50 3 years ago
setup.py 56a6300553 Bump version 1 month ago

README.md

All-in-one embeddings database

Version GitHub last commit GitHub issues Join Slack Build Status Coverage Status

txtai is an all-in-one embeddings database for semantic search, LLM orchestration and language model workflows.

architecture architecture

Embeddings databases are a union of vector indexes (sparse and dense), graph networks and relational databases. This enables vector search with SQL, topic modeling, retrieval augmented generation (RAG) and more.

Embeddings databases can stand on their own and/or serve as a powerful knowledge source for large language model (LLM) prompts.

Summary of txtai features:

  • 🔎 Vector search with SQL, object storage, topic modeling, graph analysis and multimodal indexing
  • 📄 Create embeddings for text, documents, audio, images and video
  • 💡 Pipelines powered by language models that run LLM prompts, question-answering, labeling, transcription, translation, summarization and more
  • ↪️️ Workflows to join pipelines together and aggregate business logic. txtai processes can be simple microservices or multi-model workflows.
  • ⚙️ Build with Python or YAML. API bindings available for JavaScript, Java, Rust and Go.
  • ☁️ Run local or scale out with container orchestration

txtai is built with Python 3.8+, Hugging Face Transformers, Sentence Transformers and FastAPI. txtai is open-source under an Apache 2.0 license.

Interested in an easy and secure way to run hosted txtai applications? Then join the txtai.cloud preview to learn more.

Why txtai?

why why

New vector databases, LLM frameworks and everything in between are sprouting up daily. Why build with txtai?

  • Up and running in minutes with pip or Docker ```python

    Get started in a couple lines

    import txtai

embeddings = txtai.Embeddings() embeddings.index(["Correct", "Not what we hoped"]) embeddings.search("positive", 1) #[(0, 0.29862046241760254)]

- Built-in API makes it easy to develop applications using your programming language of choice
```yaml
# app.yml
embeddings:
    path: sentence-transformers/all-MiniLM-L6-v2
CONFIG=app.yml uvicorn "txtai.api:app"
curl -X GET "http://localhost:8000/search?query=positive"
  • Run local - no need to ship data off to disparate remote services
  • Work with micromodels all the way up to large language models (LLMs)
  • Low footprint - install additional dependencies and scale up when needed
  • Learn by example - notebooks cover all available functionality

Use Cases

The following sections introduce common txtai use cases. A comprehensive set of over 50 example notebooks and applications are also available.

Semantic Search

Build semantic/similarity/vector/neural search applications.

demo

Traditional search systems use keywords to find data. Semantic search has an understanding of natural language and identifies results that have the same meaning, not necessarily the same keywords.

search search

Get started with the following examples.

Notebook Description
Introducing txtai ▶️ Overview of the functionality provided by txtai Open In Colab
Similarity search with images Embed images and text into the same space for search Open In Colab
Build a QA database Question matching with semantic search Open In Colab
Semantic Graphs Explore topics, data connectivity and run network analysis Open In Colab

LLM Orchestration

LLM chains, retrieval augmented generation (RAG), chat with your data, pipelines and workflows that interface with large language models (LLMs).

Chains

Integrate LLM chains (known as workflows in txtai), multiple LLM agents and self-critique.

llm

See below to learn more.

Notebook Description
Prompt templates and task chains Build model prompts and connect tasks together with workflows Open In Colab
Integrate LLM frameworks Integrate llama.cpp, LiteLLM and custom generation frameworks Open In Colab
Build knowledge graphs with LLMs Build knowledge graphs with LLM-driven entity extraction Open In Colab

Retrieval augmented generation

Retrieval augmented generation (RAG) reduces the risk of LLM hallucinations by constraining the output with a knowledge base as context. RAG is commonly used to "chat with your data".

rag rag

A novel feature of txtai is that it can provide both an answer and source citation.

Notebook Description
Build RAG pipelines with txtai Guide on retrieval augmented generation including how to create citations Open In Colab
How RAG with txtai works Create RAG processes, API services and Docker instances Open In Colab
Advanced RAG with graph path traversal Graph path traversal to collect complex sets of data for advanced RAG Open In Colab
Advanced RAG with guided generation Retrieval Augmented and Guided Generation Open In Colab

Language Model Workflows

Language model workflows, also known as semantic workflows, connect language models together to build intelligent applications.

flows flows

While LLMs are powerful, there are plenty of smaller, more specialized models that work better and faster for specific tasks. This includes models for extractive question-answering, automatic summarization, text-to-speech, transcription and translation.

Notebook Description
Run pipeline workflows ▶️ Simple yet powerful constructs to efficiently process data Open In Colab
Building abstractive text summaries Run abstractive text summarization Open In Colab
Transcribe audio to text Convert audio files to text Open In Colab
Translate text between languages Streamline machine translation and language detection Open In Colab

Installation

install install

The easiest way to install is via pip and PyPI

pip install txtai

Python 3.8+ is supported. Using a Python virtual environment is recommended.

See the detailed install instructions for more information covering optional dependencies, environment specific prerequisites, installing from source, conda support and how to run with containers.

Model guide

models

See the table below for the current recommended models. These models all allow commercial use and offer a blend of speed and performance.

Component Model(s)
Embeddings all-MiniLM-L6-v2
Image Captions BLIP
Labels - Zero Shot BART-Large-MNLI
Labels - Fixed Fine-tune with training pipeline
Large Language Model (LLM) Mistral 7B OpenOrca
Summarization DistilBART
Text-to-Speech ESPnet JETS
Transcription Whisper
Translation OPUS Model Series

Models can be loaded as either a path from the Hugging Face Hub or a local directory. Model paths are optional, defaults are loaded when not specified. For tasks with no recommended model, txtai uses the default models as shown in the Hugging Face Tasks guide.

See the following links to learn more.

Powered by txtai

The following applications are powered by txtai.

apps

Application Description
txtchat Retrieval Augmented Generation (RAG) powered search
paperai Semantic search and workflows for medical/scientific papers
codequestion Semantic search for developers
tldrstory Semantic search for headlines and story text

In addition to this list, there are also many other open-source projects, published research and closed proprietary/commercial projects that have built on txtai in production.

Further Reading

further further

Documentation

Full documentation on txtai including configuration settings for embeddings, pipelines, workflows, API and a FAQ with common questions/issues is available.

Contributing

For those who would like to contribute to txtai, please see this guide.