Skip to main content

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 succeeded
  • facts_extracted: Number of facts extracted
  • chunk_id: Unique identifier for the content
  • message: 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 string
  • include_summary: Include AI-generated summary (default: True)
  • include_raw_results: Include detailed graph facts and vector results

Returns:

  • success: Whether the query succeeded
  • summary: AI-generated comprehensive answer
  • search_time: Query execution time
  • entities_found: Extracted entities from the query
  • total_facts: Number of graph facts found
  • total_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

  1. Sign up at VRIN Console
  2. Create a new API key
  3. 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:

  1. Fact Extraction - LLM-powered extraction of structured facts
  2. Graph Storage - Facts stored as a knowledge graph in Neptune
  3. Vector Storage - Semantic embeddings in OpenSearch
  4. Hybrid Retrieval - Combines graph traversal + vector similarity
  5. Result Fusion - Intelligent ranking and result combination
  6. 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


Built with โค๏ธ by the VRIN Team

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vrin-0.2.2.tar.gz (27.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vrin-0.2.2-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file vrin-0.2.2.tar.gz.

File metadata

  • Download URL: vrin-0.2.2.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for vrin-0.2.2.tar.gz
Algorithm Hash digest
SHA256 8a5a4aa2037f602a0f9e1abc8e2d2ccf6bf09921f2610cdc3d597fdfaee6501e
MD5 13f3de885dbec724e81d28d846e13a81
BLAKE2b-256 91af875093121c4be30c945b02d7354be3e31045ae7d70de60aafbc45de50bfa

See more details on using hashes here.

File details

Details for the file vrin-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: vrin-0.2.2-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

Hashes for vrin-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 750290fa87c4f3de42d1c5abc5dcd58b9d6b11634941c2bee69d56f0a3ba9318
MD5 06eba82fe77bea11f0550e890dfcf134
BLAKE2b-256 5845950c066f73539b24fe504622a935baa1abd256075a08f827ea5f6067fc3b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page