RAG without vector embeddings β tree-based retrieval powered by LLM navigation
vectorless is a Rust-based RAG (Retrieval-Augmented Generation) system that uses tree-based indexing and LLM navigation instead of traditional vector embeddings. No vector database required.
- Tree-Based Indexing β Documents are organized as hierarchical trees with summaries at each node
- LLM Navigation β Intelligent traversal using LLM to find relevant content
- No Vector Database β Eliminates infrastructure complexity and costs
- Built in Rust β Blazing fast performance with memory safety
- HTTP API β Simple RESTful API for easy integration
- Multiple LLM Support β Pluggable LLM providers (ZAI, OpenAI, etc.)
# Clone the repository
git clone https://github.com/zTgx/vectorless
cd vectorless
# Build the project
cargo build --release# Set your LLM API credentials
export ZAI_API_KEY="your-api-key"
export ZAI_ENDPOINT="https://api.z.ai/api/coding/paas/v4"
# Start the HTTP server
cargo run -p vectorless-ragThe server will start on http://localhost:8080
use vectorless_core::*;
use vectorless_llm::openai::OpenAIClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize LLM client (OpenAI)
let llm = OpenAIClient::new("your-api-key");
// Or use ZAI
// let llm = vectorless_llm::zai::ZaiClient::new("your-api-key");
// Configure indexer
let config = IndexerConfig::builder()
.subsection_threshold(200)
.max_segment_tokens(4000)
.summary_model("gpt-4o")
.max_summary_tokens(200)
.build();
// Parse document
let root = parse_document_with_config(&llm, document_text, &config).await?;
// Build summaries
build_summaries_with_config(&llm, &root, &config).await?;
// Save index
save(&root, "index.json")?;
// Query
let answer = retrieve(&llm, "What is the main topic?", &root).await?;
println!("Answer: {}", answer);
Ok(())
}vectorless/
βββ core/ # Core indexing and retrieval logic
βββ llm/ # LLM abstraction layer
βββ rag/ # HTTP RAG service
βββ agent/ # Agent framework
βββ cli/ # Command-line interface
βββ sdk/ # Client SDK
- Parse β Documents are segmented into sections based on structure
- Index β A hierarchical tree is built with summaries for each node
- Retrieve β The LLM navigates the tree to find relevant content
- Generate β Results are used for RAG generation
# Create a document
POST /documents
{"title": "My Document"}
# Upload content
POST /documents/{id}/content
{"content": "Document content here..."}
# List documents
GET /documents
# Get document
GET /documents/{id}
# Delete document
DELETE /documents/{id}# Query the knowledge base
POST /query
{
"query": "What is the main point?",
"max_results": 3
}# Check service health
GET /healthConfiguration is done via environment variables:
| Variable | Description | Default |
|---|---|---|
OPENAI_API_KEY |
OpenAI API key | - |
OPENAI_ENDPOINT |
OpenAI endpoint | https://api.openai.com/v1 |
OPENAI_MODEL |
Model name | gpt-4o |
ZAI_API_KEY |
ZAI API key | - |
ZAI_ENDPOINT |
ZAI endpoint | https://api.z.ai/api/paas/v4 |
ZAI_MODEL |
Model name | glm-5 |
| Variable | Description | Default |
|---|---|---|
RAG_HOST |
Server host | 0.0.0.0 |
RAG_PORT |
Server port | 8080 |
RAG_DATA_DIR |
Data directory | ./data |
RAG_INDEX_DIR |
Index directory | ./indices |
RAG_SUBSECTION_THRESHOLD |
Subsection token threshold | 200 |
RAG_MAX_SEGMENT_TOKENS |
Max segment tokens | 4000 |
RAG_MAX_SUMMARY_TOKENS |
Max summary tokens | 200 |
| Vector RAG | Vectorless | Keyword Search |
|---|---|---|
| Requires embedding model | β No embeddings | No semantic understanding |
| Vector database costs | β Zero extra costs | Keyword matching only |
| Approximate results | β Precise retrieval | Limited relevance |
| Complex infrastructure | β Simple deployment | No context awareness |
cargo run --package basic --bin basicOutput:
> Hello! How can I help you today?
Building index...
Parsing document...
Building summaries...
Saving index to index.json
Index built successfully!
Query: What is this document about?
Answer: This document is an introductory book about the Rust programming language.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under either of:
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
at your option.