QuiraQuira
Docs/Getting Started

Quira Framework

The high-performance Retrieval Augmented Generation framework built from the ground up for token efficiency and zero perceived latency.


Installation

Quira is distributed via PyPI. We highly recommend installing the all variant, which automatically pulls in the official client libraries for our supported vector databases and LLM providers.

pip
poetry
uv
$pip install "quira[all]"

If you prefer a lightweight installation and want to manage dependencies yourself, use pip install quira.

Speculative Retrieval

Standard RAG pipelines suffer from high latency because retrieval happens sequentially after the user submits their query. Network calls to vector databases (like Pinecone or Qdrant) can take anywhere from 200ms to over 500ms.

How it works

Quira tracks keyboard typing speeds in your UI. It implements advanced debounce logic—specifically Lexical Intent Debouncing—which checks if the user's intent has actually changed before speculatively searching the database. By the time the user presses "Enter", the relevant chunks are already loaded in local memory, reducing perceived latency to absolutely zero without spamming your database.

Context Tetris

Language models have strict context window limits. Instead of blindly passing the top-K retrieved chunks (which often leads to repetitive or irrelevant context), Quira employs a dynamic scoring algorithm. It intelligently packs the most valuable chunks into your remaining token budget based on four strict dimensions.

1. Relevance

Standard cosine similarity between the embedded query and the document chunks.

2. Recency

Decay function applied to document creation dates to favor newer information.

3. Diversity

Penalizes chunks that are too semantically similar to each other using MMR.

4. Density

Extracts keyword density to prioritize factual information over filler text.

Differential Retrieval

In a multi-turn chat session, standard frameworks continuously re-query the vector database for identical context, adding hundreds of milliseconds of redundant latency to every turn.

Quira uses Differential Retrieval. We maintain the state of the conversation on the server and only fetch the delta — new information relevant to the current turn — from the vector database. This densely packed context pool is then compressed by Context Tetris before being sent to the LLM, saving both database reads and LLM tokens.

Provider Abstraction

Quira exposes unified classes like BaseVectorStore and BaseLLMProvider. When writing your RAG application, you program against these interfaces. Swapping from Qdrant to Pinecone, or OpenAI to Anthropic, is literally a one-line config change.

pipeline.py
pipeline = quiraPipeline(
vector_store="qdrant", # or "pinecone", "weaviate"
llm="anthropic/claude-3-opus", # or "openai/gpt-4o"
cache="redis"
)

Integrations

We don't want to reinvent the wheel. If you have an existing application built on LangChain or LlamaIndex, you can use Quira seamlessly as a high-performance retrieval step.

LangChain Compatible Retriever

Quira provides a LangChain-compatible retriever class that conforms to the BaseRetriever interface.

retriever.py
from quira.integrations import QuiraRetriever

retriever = QuiraRetriever(pipeline=pipeline)
docs = retriever.invoke("How does context tetris work?")