Retrieve documents from txtai indexes for LlamaIndex
LlamaIndex reader that pulls documents from an existing txtai index by query.
Why it matters
Connect existing txtai vector indexes to LlamaIndex workflows, enabling users to query and retrieve relevant documents from in-memory txtai indexes and feed them into downstream LlamaIndex data structures for RAG and semantic search applications.
Outcomes
What it gets done
Initialize reader with an existing txtai index object
Query txtai index using vector embeddings to find relevant documents
Map document IDs to text content for retrieval
Load top-k documents as separate or combined LlamaIndex documents
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/li-reader-readers-txtai | bash Overview
LlamaIndex Readers Integration: txtai
The txtai Reader pulls documents from an existing in-memory txtai index into LlamaIndex, given a query vector, an ID-to-text map, and a result count. Use it when you already have a txtai index and need documents from it in LlamaIndex. To build and manage the index itself, use VectorStoreIndex with TxtaiVectorStore instead.
What it does
The txtai Reader retrieves documents through an existing, in-memory txtai index, for use in downstream LlamaIndex data structures. It does not build or manage the txtai index itself -- for that (inserting documents, organizing, and querying via txtai as your index), use VectorStoreIndex with TxtaiVectorStore instead.
When to use - and when NOT to
Use it when you already have a txtai index in memory and need to pull documents from it by query vector into LlamaIndex. If you want to use txtai itself as the index -- inserting and organizing documents, then querying them -- this reader is not the right tool; use VectorStoreIndex with TxtaiVectorStore for that instead.
Inputs and outputs
Install with:
pip install llama-index-readers-txtai
Initialize with an existing txtai index object, then load by query:
from llama_index.readers.txtai import TxtaiReader
reader = TxtaiReader(index="<txtai Index object>")
documents = reader.load_data(
query="<Query Vector>",
id_to_text_map={"<ID>": "<Text>"},
k=4,
separate_documents=True,
)
load_data takes a query vector, an id_to_text_map mapping IDs to their text, k (how many results to return), and separate_documents (whether to return one document per match).
Who it's for
Developers who already maintain a txtai index and need to pull matching documents from it into a LlamaIndex pipeline.
Source README
LlamaIndex Readers Integration: txtai
Overview
The txtai Reader retrieves documents through an existing in-memory txtai index. These documents can then be used in downstream LlamaIndex data structures. If you wish to use txtai itself as an index to organize documents, insert documents, and perform queries on them, please use VectorStoreIndex with TxtaiVectorStore.
Installation
You can install the txtai Reader via pip:
pip install llama-index-readers-txtai
Usage
from llama_index.readers.txtai import TxtaiReader
### Initialize TxtaiReader with an existing txtai index
reader = TxtaiReader(index="<txtai Index object>")
### Load data from txtai index
documents = reader.load_data(
query="<Query Vector>",
id_to_text_map={"<ID>": "<Text>"},
k=4,
separate_documents=True,
)
This loader is designed to be used as a way to load data into
LlamaIndex.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.