Optimized Hybrid RAG SDK with smart deduplication, enhanced fact extraction, and competitive performance
Project description
VRIN Hybrid RAG SDK v0.2.1
Optimized Hybrid RAG SDK with smart deduplication, enhanced fact extraction, and competitive performance.
๐ New in v0.2.1 - Performance Optimizations
- ๐ฏ Smart Deduplication - Prevents duplicate facts and chunks, reduces storage by 40-60%
- โก Enhanced Performance - Sub-3s queries with 7+ combined graph + vector results
- ๐ง Improved Fact Quality - 0.8+ confidence facts with self-updating system
- ๐พ Storage Optimization - Only stores unique, fact-rich content
- ๐ Self-Improving - Higher confidence facts automatically update existing ones
- ๐ Competitive Edge - Outperforms pure RAG and basic GraphRAG systems
๐ Core Features
- โก Hybrid RAG Architecture - Graph reasoning + Vector similarity search
- ๐ง Intelligent Entity Matching - AI-powered compound entity recognition
- ๐ Advanced Fact Extraction - High-confidence structured knowledge extraction
- ๐ Sub-3s Query Response - Optimized retrieval with comprehensive coverage
- ๐ฏ AI-Powered Summaries - Natural language answers with cited sources
- ๐ Enterprise-Ready - User isolation, authentication, and production scaling
๐ฆ Installation
pip install vrin
๐ง Quick Start
from vrin import VRINClient
# Initialize with your API key
client = VRINClient(api_key="your_vrin_api_key")
# Insert knowledge with automatic fact extraction
result = client.insert(
content="Python is a high-level programming language created by Guido van Rossum in 1991. It emphasizes code readability and supports multiple programming paradigms.",
title="Python Programming Language",
tags=["programming", "python", "language"]
)
print(f"โ
Extracted {result['facts_extracted']} facts")
# Output: โ
Extracted 7 facts
# Query with intelligent hybrid search
response = client.query("Who created Python and when?")
print(f"๐ Answer: {response['summary']}")
print(f"โก Performance: {response['total_facts']} graph + {response['total_chunks']} vector = {response['combined_results']} results")
print(f"๐ Query time: {response['search_time']}")
# Output:
# ๐ Answer: Python was created by Guido van Rossum in 1991. It is a high-level programming language known for its simplicity and readability...
# โก Performance: 4 graph + 5 vector = 9 results
# ๐ Query time: 2.85s
๐ Advanced Usage
Storage Optimization Features
# Insert content with optimization details
result = client.insert(content, title, tags)
print(f"๐ง Facts extracted: {result['facts_extracted']}")
print(f"๐พ Storage optimization: {result['storage_optimization']}")
print(f"๐ฆ Chunk stored: {result['chunk_stored']}")
print(f"โก Processing time: {result['processing_time']}")
# Check deduplication efficiency
storage = result['storage_result']
print(f"๐ New facts: {storage['stored_facts']}")
print(f"๐ Updated facts: {storage['updated_facts']}")
print(f"โญ๏ธ Skipped duplicates: {storage['skipped_duplicates']}")
print(f"๐พ Efficiency: {storage['storage_efficiency']}")
Raw Results Access
# Get detailed graph facts and vector results
details = client.get_raw_results("Python programming language")
print("๐ Graph Facts:")
for fact in details['graph_facts']:
confidence = fact['confidence']
print(f" โข {fact['subject']} โ {fact['predicate']} โ {fact['object']} (confidence: {confidence:.2f})")
print(f"\n๐ Vector Chunks: {len(details['vector_results'])}")
print(f"๐ง Entities Found: {details['entities_found']}")
Knowledge Graph Visualization
# Get knowledge graph data for visualization
graph = client.get_knowledge_graph()
print(f"๐ Graph: {len(graph['data']['nodes'])} nodes, {len(graph['data']['edges'])} edges")
Batch Processing
# Insert multiple documents efficiently
documents = [
{"content": "Machine learning is a subset of AI...", "title": "ML Basics"},
{"content": "Neural networks consist of layers...", "title": "Neural Networks"},
{"content": "Deep learning uses multiple layers...", "title": "Deep Learning"}
]
for doc in documents:
result = client.insert(doc['content'], doc['title'])
print(f"Processed: {doc['title']} -> {result['facts_extracted']} facts")
๐ฏ API Reference
VRINClient
__init__(api_key: str)
Initialize the VRIN client with your API key.
insert(content: str, title: str = None, tags: List[str] = None) -> Dict
Insert knowledge into the system with automatic fact extraction.
Returns:
success: Whether the operation succeededfacts_extracted: Number of facts extractedchunk_id: Unique identifier for the contentmessage: Status message
query(query: str, include_summary: bool = True, include_raw_results: bool = False) -> Dict
Query the knowledge base with optimized hybrid retrieval.
Parameters:
query: Search query stringinclude_summary: Include AI-generated summary (default: True)include_raw_results: Include detailed graph facts and vector results
Returns:
success: Whether the query succeededsummary: AI-generated comprehensive answersearch_time: Query execution timeentities_found: Extracted entities from the querytotal_facts: Number of graph facts foundtotal_chunks: Number of vector chunks found
get_raw_results(query: str) -> Dict
Get complete raw results including graph facts and vector chunks.
get_knowledge_graph() -> Dict
Get knowledge graph visualization data with nodes and edges.
๐ Authentication
- Sign up at VRIN Console
- Create a new API key
- Use the API key to initialize your client
client = VRINClient(api_key="vrin_your_api_key_here")
๐๏ธ Architecture
VRIN uses a sophisticated Hybrid RAG architecture:
- Fact Extraction - LLM-powered extraction of structured facts
- Graph Storage - Facts stored as a knowledge graph in Neptune
- Vector Storage - Semantic embeddings in OpenSearch
- Hybrid Retrieval - Combines graph traversal + vector similarity
- Result Fusion - Intelligent ranking and result combination
- AI Summarization - Natural language response generation
๐ Performance (v0.2.1 Optimized)
- Fact Extraction: 3-8 high-quality facts per insertion (0.8+ confidence)
- Query Response: Sub-3s with 7+ combined graph + vector results
- Hybrid Coverage: 2-5 graph facts + 3-5 vector chunks per query
- Storage Efficiency: 40-60% reduction through smart deduplication
- Self-Improvement: Facts automatically update with higher confidence versions
- Competitive Advantage: Outperforms single-method RAG systems
๐ ๏ธ Requirements
- Python 3.8+
- Active internet connection
- VRIN API key
๐ License
MIT License - see LICENSE file for details.
๐ค Support
- ๐ง Email: support@vrin.ai
- ๐ Documentation: https://docs.vrin.ai
- ๐ Issues: https://github.com/vrin-ai/vrin-sdk/issues
Built with โค๏ธ by the VRIN Team
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vrin-0.2.3.tar.gz.
File metadata
- Download URL: vrin-0.2.3.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dccfad2ac864b9e32795877e1f7dfdea648f36d79d4c1b5b5b8ea5dd0cf9481b
|
|
| MD5 |
7ff1a34ba3616f444070ff656b37c194
|
|
| BLAKE2b-256 |
efe7833fd8fd0ac118ac1ceb77e06939312d3716c7a0aa11e54279df8668abc7
|
File details
Details for the file vrin-0.2.3-py3-none-any.whl.
File metadata
- Download URL: vrin-0.2.3-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e4cdf4fa4cdd5433e8a1066e5eccadefe1b49acc7aa09ba74a5a3c333da9091
|
|
| MD5 |
af2e6b081a3502e04c2de793f3da0ae2
|
|
| BLAKE2b-256 |
f1c199d288b716c6a3c3280edf413c05694d23e008a88abbc1bd93624728ae95
|