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.
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
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.
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 = QuiraRetriever(pipeline=pipeline)
docs = retriever.invoke("How does context tetris work?")