Convert Figma logo to code with AI

neuml logotxtai

💡 All-in-one open-source embeddings database for semantic search, LLM orchestration and language model workflows

10,629
674
10,629
13

Top Related Projects

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.

31,212

💫 Industrial-strength Natural Language Processing (NLP) in Python

34,439

A library for efficient similarity search and clustering of dense vectors.

Official Python client for Elasticsearch

19,922

AI orchestration framework to build customizable, production-ready LLM applications. Connect components (models, vector DBs, file converters) to pipelines or agents that can interact with your data. With advanced retrieval methods, it's best suited for building RAG, question answering, semantic search or conversational agent chatbots.

19,698

💬 Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants

Quick Overview

txtai is an AI-powered search engine for text data. It allows users to build semantic search applications and workflows, enabling natural language queries and text analysis. The library combines machine learning and natural language processing to create powerful, flexible text-based solutions.

Pros

  • Easy to use and integrate with existing Python projects
  • Supports multiple embedding models and can be extended with custom models
  • Provides a wide range of functionalities beyond search, including text extraction, similarity, and classification
  • Offers both local and API-based deployment options

Cons

  • May require significant computational resources for large datasets
  • Learning curve for advanced features and customizations
  • Limited documentation for some of the more complex use cases
  • Dependency on external libraries and models, which may require additional setup

Code Examples

  1. Creating a simple search index:
from txtai.embeddings import Embeddings

embeddings = Embeddings({"path": "sentence-transformers/all-MiniLM-L6-v2"})
embeddings.index(["US tops 5 million confirmed virus cases",
                  "Canada's last fully intact ice shelf has suddenly collapsed, forming a Manhattan-sized iceberg",
                  "Beijing mobilises invasion craft along coast as Taiwan tensions escalate",
                  "The National Park Service warns against sacrificing slower friends in a bear attack",
                  "Maine man wins $1M from $25 lottery ticket"],
                 range(5))

print(embeddings.search("virus cases", 1))
  1. Performing text extraction:
from txtai.pipeline import TextExtractor

extractor = TextExtractor()
text = "This is a sample text. It contains information about txtai."
result = extractor(text, "What is this text about?")
print(result)
  1. Text classification:
from txtai.pipeline import Labels

labels = Labels()
data = [("This is a positive review", "positive"),
        ("I didn't like the product", "negative")]
labels.fit(data)

result = labels("The product exceeded my expectations")
print(result)

Getting Started

To get started with txtai, follow these steps:

  1. Install txtai:
pip install txtai
  1. Create a simple search application:
from txtai.embeddings import Embeddings

# Create embeddings model
embeddings = Embeddings({"path": "sentence-transformers/all-MiniLM-L6-v2"})

# Index data
data = ["Text to search", "Add more text", "And more text"]
embeddings.index(data)

# Run a search
results = embeddings.search("search", 1)
print(results)

This basic example creates an embeddings model, indexes some text data, and performs a search. You can expand on this foundation to build more complex applications using txtai's various features.

Competitor Comparisons

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.

Pros of transformers

  • Extensive library of pre-trained models for various NLP tasks
  • Large community support and frequent updates
  • Comprehensive documentation and examples

Cons of transformers

  • Steeper learning curve for beginners
  • Larger library size and potential overhead for simple tasks
  • May require more computational resources for some models

Code comparison

txtai:

embeddings = Embeddings({"path": "sentence-transformers/all-MiniLM-L6-v2"})
embeddings.index([(1, "Text to embed"), (2, "Another text")])
embeddings.search("Query text", 1)

transformers:

from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
model = AutoModel.from_pretrained("bert-base-uncased")
inputs = tokenizer("Text to embed", return_tensors="pt")
outputs = model(**inputs)

txtai focuses on simplifying embedding and search operations, while transformers provides a more comprehensive toolkit for various NLP tasks. txtai offers a more straightforward API for specific use cases, whereas transformers gives users more control and flexibility at the cost of increased complexity.

31,212

💫 Industrial-strength Natural Language Processing (NLP) in Python

Pros of spaCy

  • More comprehensive NLP toolkit with advanced linguistic features
  • Larger community and ecosystem with extensive documentation
  • Better performance for traditional NLP tasks like parsing and named entity recognition

Cons of spaCy

  • Steeper learning curve for beginners
  • Larger model sizes and memory footprint
  • Less focus on modern AI/ML techniques like embeddings and transformers

Code Comparison

spaCy:

import spacy

nlp = spacy.load("en_core_web_sm")
doc = nlp("Apple is looking at buying U.K. startup for $1 billion")

for ent in doc.ents:
    print(ent.text, ent.label_)

txtai:

from txtai.pipeline import EntityExtraction

extractor = EntityExtraction()
text = "Apple is looking at buying U.K. startup for $1 billion"
print(extractor(text))

spaCy provides more detailed linguistic analysis out-of-the-box, while txtai offers a simpler API for common NLP tasks. spaCy is better suited for traditional NLP workflows, whereas txtai focuses on AI-powered text analysis and search capabilities.

34,439

A library for efficient similarity search and clustering of dense vectors.

Pros of FAISS

  • Highly optimized for large-scale similarity search and clustering
  • Supports GPU acceleration for improved performance
  • Extensive documentation and benchmarks available

Cons of FAISS

  • Steeper learning curve and more complex API
  • Primarily focused on vector similarity search, less versatile for general NLP tasks
  • Requires separate text embedding process before indexing

Code Comparison

FAISS example:

import faiss
import numpy as np

d = 64  # dimension
nb = 100000  # database size
nq = 10000  # nb of queries
xb = np.random.random((nb, d)).astype('float32')
xq = np.random.random((nq, d)).astype('float32')

index = faiss.IndexFlatL2(d)
index.add(xb)
D, I = index.search(xq, k=4)

txtai example:

from txtai.embeddings import Embeddings

embeddings = Embeddings({"path": "sentence-transformers/all-MiniLM-L6-v2"})
embeddings.index(["Sentence 1", "Sentence 2", "Sentence 3"])

results = embeddings.search("Query text", 2)

FAISS excels in high-performance vector similarity search, while txtai offers a more user-friendly API for general NLP tasks, including embeddings and search functionality.

Official Python client for Elasticsearch

Pros of elasticsearch-py

  • Comprehensive API for Elasticsearch, supporting all features and operations
  • Well-established and widely used in production environments
  • Extensive documentation and community support

Cons of elasticsearch-py

  • Focused solely on Elasticsearch, lacking broader NLP capabilities
  • Steeper learning curve for those new to Elasticsearch
  • Requires separate Elasticsearch server setup and maintenance

Code Comparison

elasticsearch-py:

from elasticsearch import Elasticsearch

es = Elasticsearch()
doc = {"title": "Test Document", "content": "This is a test"}
es.index(index="my_index", id=1, body=doc)
result = es.search(index="my_index", body={"query": {"match": {"content": "test"}}})

txtai:

from txtai.embeddings import Embeddings

embeddings = Embeddings({"path": "sentence-transformers/all-MiniLM-L6-v2"})
embeddings.index([(0, "This is a test", None)])
results = embeddings.search("test", 1)

Summary

While elasticsearch-py offers a robust solution for working with Elasticsearch, txtai provides a more streamlined approach to text embeddings and search. elasticsearch-py is better suited for complex, large-scale search applications, while txtai excels in simplicity and ease of use for NLP tasks. The choice between the two depends on the specific requirements of your project and the scale of your search needs.

19,922

AI orchestration framework to build customizable, production-ready LLM applications. Connect components (models, vector DBs, file converters) to pipelines or agents that can interact with your data. With advanced retrieval methods, it's best suited for building RAG, question answering, semantic search or conversational agent chatbots.

Pros of Haystack

  • More comprehensive framework with a wider range of components and integrations
  • Stronger focus on production-ready deployments and scalability
  • More extensive documentation and tutorials

Cons of Haystack

  • Steeper learning curve due to its complexity and broader feature set
  • Potentially heavier resource requirements for smaller projects
  • Less flexibility for custom pipelines compared to txtai's modular approach

Code Comparison

Haystack example:

from haystack import Pipeline
from haystack.nodes import EmbeddingRetriever, FARMReader

retriever = EmbeddingRetriever(document_store=document_store)
reader = FARMReader(model_name_or_path="deepset/roberta-base-squad2")
pipe = Pipeline()
pipe.add_node(component=retriever, name="Retriever", inputs=["Query"])
pipe.add_node(component=reader, name="Reader", inputs=["Retriever"])

txtai example:

from txtai.pipeline import Extractor

extractor = Extractor()
result = extractor("What is the capital of France?", "The capital of France is Paris.")

Both Haystack and txtai offer powerful NLP capabilities, but they cater to different use cases. Haystack is more suitable for large-scale, production-ready applications with complex requirements, while txtai provides a simpler, more flexible approach for smaller projects or rapid prototyping. The choice between the two depends on the specific needs of your project and the level of complexity you're comfortable with.

19,698

💬 Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants

Pros of Rasa

  • Comprehensive conversational AI framework with built-in NLU and dialogue management
  • Large community and extensive documentation for easier adoption and support
  • Supports multiple languages and can be deployed on-premises for data privacy

Cons of Rasa

  • Steeper learning curve due to its complex architecture and numerous components
  • Requires more computational resources and setup time compared to lighter alternatives
  • May be overkill for simpler text processing or embedding tasks

Code Comparison

Rasa (dialogue management):

from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher

class ActionGreet(Action):
    def name(self) -> str:
        return "action_greet"

    def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[str, Any]) -> List[Dict[str, Any]]:
        dispatcher.utter_message(text="Hello! How can I help you today?")
        return []

txtai (text embedding and search):

from txtai.embeddings import Embeddings

embeddings = Embeddings({"path": "sentence-transformers/all-MiniLM-L6-v2"})
embeddings.index(["Sentence 1", "Sentence 2", "Sentence 3"])

results = embeddings.search("Query text", 1)
print(results)

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

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 foundation enables vector search and/or serves as a powerful knowledge source for large language model (LLM) applications.

Build autonomous agents, retrieval augmented generation (RAG) processes, multi-model workflows and more.

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.
  • 🤖 Agents that intelligently connect embeddings, pipelines, workflows and other agents together to autonomously solve complex problems
  • ⚙️ Build with Python or YAML. API bindings available for JavaScript, Java, Rust and Go.
  • 🔋 Batteries included with defaults to get up and running fast
  • ☁️ Run local or scale out with container orchestration

txtai is built with Python 3.9+, 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
# 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
# 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 60 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.

NotebookDescription
Introducing txtai ▶️Overview of the functionality provided by txtaiOpen In Colab
Similarity search with imagesEmbed images and text into the same space for searchOpen In Colab
Build a QA databaseQuestion matching with semantic searchOpen In Colab
Semantic GraphsExplore topics, data connectivity and run network analysisOpen In Colab

LLM Orchestration

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

llm

See below to learn more.

NotebookDescription
Prompt templates and task chainsBuild model prompts and connect tasks together with workflowsOpen In Colab
Integrate LLM frameworksIntegrate llama.cpp, LiteLLM and custom generation frameworksOpen In Colab
Build knowledge graphs with LLMsBuild knowledge graphs with LLM-driven entity extractionOpen In Colab
Parsing the stars with txtaiExplore an astronomical knowledge graph of known stars, planets, galaxiesOpen In Colab

Agents

Agents connect embeddings, pipelines, workflows and other agents together to autonomously solve complex problems.

agent

txtai agents are built on top of the Transformers Agent framework. This supports all LLMs txtai supports (Hugging Face, llama.cpp, OpenAI / Claude / AWS Bedrock via LiteLLM).

See the link below to learn more.

NotebookDescription
Analyzing Hugging Face Posts with Graphs and AgentsExplore a rich dataset with Graph Analysis and AgentsOpen In Colab
Granting autonomy to agentsAgents that iteratively solve problems as they see fitOpen In Colab
Analyzing LinkedIn Company Posts with Graphs and AgentsExploring how to improve social media engagement with AIOpen 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.

NotebookDescription
Build RAG pipelines with txtaiGuide on retrieval augmented generation including how to create citationsOpen In Colab
Chunking your data for RAGExtract, chunk and index content for effective retrievalOpen In Colab
Advanced RAG with graph path traversalGraph path traversal to collect complex sets of data for advanced RAGOpen In Colab
Speech to Speech RAG ▶️Full cycle speech to speech workflow with RAGOpen 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.

NotebookDescription
Run pipeline workflows ▶️Simple yet powerful constructs to efficiently process dataOpen In Colab
Building abstractive text summariesRun abstractive text summarizationOpen In Colab
Transcribe audio to textConvert audio files to textOpen In Colab
Translate text between languagesStreamline machine translation and language detectionOpen In Colab

Installation

install install

The easiest way to install is via pip and PyPI

pip install txtai

Python 3.9+ 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.

ComponentModel(s)
Embeddingsall-MiniLM-L6-v2
Image CaptionsBLIP
Labels - Zero ShotBART-Large-MNLI
Labels - FixedFine-tune with training pipeline
Large Language Model (LLM)Llama 3.1 Instruct
SummarizationDistilBART
Text-to-SpeechESPnet JETS
TranscriptionWhisper
TranslationOPUS 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

ApplicationDescription
ragRetrieval Augmented Generation (RAG) application
ragdataBuild knowledge bases for RAG
paperaiSemantic search and workflows for medical/scientific papers
annotateaiAutomatically annotate papers with LLMs

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.