2025-06-26 12:07:37 +05:30
2025-06-25 16:11:00 +05:30
2025-06-25 16:11:00 +05:30
2025-06-26 12:07:37 +05:30

🧠 SemantiCore

Python 3.8+ License: MIT PyPI version Downloads Tests

Transform Unstructured Data into Intelligent Semantic Layers for AI Systems

SemantiCore is an open-source toolkit that transforms raw, unstructured data into semantic knowledge representations including ontologies, knowledge graphs, and context-aware embeddings. Built for developers creating AI agents, RAG systems, and intelligent applications that need to understand meaning, not just text.


🚀 Core Features Overview

🧠 Semantic Processing

  • Multi-layer Understanding: Lexical, syntactic, semantic, and pragmatic analysis
  • Entity & Relationship Extraction: Named entities, relationships, and complex event detection
  • Context Preservation: Maintain semantic context across document boundaries
  • Domain Adaptation: Specialized processing for cybersecurity, finance, healthcare, research

🎯 LLM Optimization

  • Context Engineering: Intelligent context compression and enhancement for LLMs
  • Prompt Optimization: Semantic-aware prompt engineering and optimization
  • Memory Management: Episodic, semantic, and procedural memory systems
  • Multi-Model Support: OpenAI, Anthropic, Google Gemini, Hugging Face, local models

🕸️ Knowledge Graphs

  • Automated Construction: Build knowledge graphs from unstructured data
  • Graph Databases: Neo4j, KuzuDB, ArangoDB, Amazon Neptune integration
  • Semantic Reasoning: Inductive, deductive, and abductive reasoning capabilities
  • Temporal Modeling: Time-aware relationships and evolution tracking

📊 Vector & Embeddings

  • Contextual Embeddings: Semantic embeddings with preserved context
  • Vector Stores: Pinecone, Milvus, Weaviate, Chroma, FAISS integration
  • Hybrid Search: Combine semantic and keyword search strategies
  • Embedding Models: OpenAI, Cohere, Sentence Transformers, custom models

🔗 Ontology Generation

  • Automated Ontology Creation: Generate OWL/RDF ontologies from data
  • Schema Evolution: Dynamic schema adaptation and versioning
  • Standard Compliance: Schema.org, FIBO, domain-specific ontologies
  • Multi-format Export: OWL, RDF, JSON-LD, Turtle formats

🤖 Agent Integration

  • Semantic Routing: Intelligent request routing based on semantic understanding
  • Agent Orchestration: Coordinate multiple AI agents with shared semantic context
  • Framework Integration: LangChain, LlamaIndex, CrewAI, AutoGen compatibility
  • Real-time Processing: Stream processing for live data semantic analysis

🚀 Quick Start

Installation

# Basic installation
pip install semanticore

# Install with all integrations
pip install "semanticore[all]"

# Install specific providers
pip install "semanticore[openai,anthropic,neo4j,pinecone]"

# Available extras: openai, anthropic, google, huggingface, neo4j, kuzu, 
# pinecone, milvus, weaviate, chroma, langchain, llamaindex, crewai

30-Second Demo

from semanticore import SemantiCore

# Initialize with your preferred providers
core = SemantiCore(
    llm_provider="openai",
    embedding_model="text-embedding-3-large",
    vector_store="pinecone",
    graph_db="neo4j"
)

# Transform unstructured text into semantic knowledge
text = """
Tesla reported Q4 2024 earnings with $25.2B revenue, a 15% increase year-over-year.
CEO Elon Musk highlighted the success of the Model Y and expansion in the Chinese market.
The company plans to launch three new models in 2025, including the long-awaited Cybertruck.
"""

# Extract semantic information
result = core.extract_semantics(text)

print("Entities:", result.entities)
# [Entity(name="Tesla", type="ORGANIZATION"), Entity(name="Elon Musk", type="PERSON")]

print("Relationships:", result.relationships) 
# [Relation(subject="Tesla", predicate="reported", object="Q4 2024 earnings")]

print("Events:", result.events)
# [Event(type="EARNINGS_REPORT", date="Q4 2024", amount="$25.2B")]

# Generate knowledge graph
knowledge_graph = core.build_knowledge_graph(text)
print("Graph nodes:", len(knowledge_graph.nodes))
print("Graph edges:", len(knowledge_graph.edges))

🔧 Integration Examples

🤖 LLM Provider Integration

from semanticore.llm import LLMProvider

# OpenAI Integration
openai_provider = LLMProvider(
    provider="openai",
    model="gpt-4-turbo",
    api_key="your-openai-key"
)

# Anthropic Integration
anthropic_provider = LLMProvider(
    provider="anthropic", 
    model="claude-3-opus-20240229",
    api_key="your-anthropic-key"
)

# Google Gemini Integration
gemini_provider = LLMProvider(
    provider="google",
    model="gemini-pro",
    api_key="your-google-key"
)

# Hugging Face Integration
hf_provider = LLMProvider(
    provider="huggingface",
    model="mistralai/Mistral-7B-Instruct-v0.1",
    api_key="your-hf-key"
)

# Local Model Integration
local_provider = LLMProvider(
    provider="local",
    model_path="/path/to/model",
    device="cuda"
)

# Use with SemantiCore
core = SemantiCore(llm_provider=openai_provider)

🕸️ Knowledge Graph Database Integration

from semanticore.graph import GraphDatabase

# Neo4j Integration
neo4j_db = GraphDatabase(
    provider="neo4j",
    uri="bolt://localhost:7687",
    username="neo4j",
    password="password"
)

# KuzuDB Integration (Embedded Graph Database)
kuzu_db = GraphDatabase(
    provider="kuzu",
    database_path="/path/to/kuzu/db"
)

# ArangoDB Integration
arango_db = GraphDatabase(
    provider="arangodb",
    host="localhost",
    port=8529,
    username="root",
    password="password"
)

# Amazon Neptune Integration
neptune_db = GraphDatabase(
    provider="neptune",
    endpoint="your-neptune-endpoint.amazonaws.com",
    port=8182,
    region="us-east-1"
)

# Build knowledge graph
from semanticore import SemantiCore

core = SemantiCore(graph_db=neo4j_db)
documents = ["doc1.txt", "doc2.txt", "doc3.txt"]

# Automatically extract entities and relationships, build graph
knowledge_graph = core.build_knowledge_graph_from_documents(documents)
print(f"Created graph with {knowledge_graph.node_count} nodes and {knowledge_graph.edge_count} edges")

📊 Vector Store Integration

from semanticore.vector import VectorStore

# Pinecone Integration
pinecone_store = VectorStore(
    provider="pinecone",
    api_key="your-pinecone-key",
    environment="us-west1-gcp",
    index_name="semanticore-index"
)

# Milvus Integration
milvus_store = VectorStore(
    provider="milvus",
    host="localhost",
    port=19530,
    collection_name="semantic_embeddings"
)

# Weaviate Integration
weaviate_store = VectorStore(
    provider="weaviate",
    url="http://localhost:8080",
    class_name="SemanticChunk"
)

# Chroma Integration
chroma_store = VectorStore(
    provider="chroma",
    persist_directory="/path/to/chroma/db",
    collection_name="documents"
)

# FAISS Integration (Local)
faiss_store = VectorStore(
    provider="faiss",
    index_path="/path/to/faiss/index",
    dimension=1536
)

# Use with SemantiCore for RAG
core = SemantiCore(
    vector_store=pinecone_store,
    embedding_model="text-embedding-3-large"
)

# Semantic chunking and embedding
chunks = core.semantic_chunk_documents(documents)
embeddings = core.embed_chunks(chunks)
vector_store.store_embeddings(chunks, embeddings)

# Semantic search
query = "What are the latest AI developments?"
results = core.semantic_search(query, top_k=5)

🔗 Framework Integration

# LangChain Integration
from semanticore.integrations.langchain import SemanticChain
from langchain.chains import ConversationalRetrievalChain

semantic_chain = SemanticChain(
    semanticore_instance=core,
    retriever_type="semantic",
    context_engineering=True
)

langchain_chain = ConversationalRetrievalChain(
    retriever=semantic_chain.as_retriever(),
    memory=semantic_chain.get_memory(),
    return_source_documents=True
)

# LlamaIndex Integration
from semanticore.integrations.llamaindex import SemanticIndex
from llama_index import VectorStoreIndex

semantic_index = SemanticIndex(
    semanticore_instance=core,
    enable_semantic_routing=True
)

llama_index = VectorStoreIndex.from_vector_store(
    semantic_index.get_vector_store()
)

# CrewAI Integration
from semanticore.integrations.crewai import SemanticCrew
from crewai import Agent, Task, Crew

# Create semantic-aware agents
researcher = Agent(
    role='Research Analyst',
    goal='Analyze semantic patterns in data',
    backstory='Expert in semantic data analysis',
    semantic_memory=core.get_semantic_memory()
)

writer = Agent(
    role='Content Writer',
    goal='Create semantic-rich content',
    backstory='Specialist in semantic content creation',
    semantic_memory=core.get_semantic_memory()
)

# Create semantic crew
semantic_crew = SemanticCrew(
    agents=[researcher, writer],
    semantic_coordination=True,
    knowledge_sharing=True
)

🎯 Advanced Features

🧠 Multi-Domain Semantic Processing

from semanticore.domains import CybersecurityProcessor, FinanceProcessor, HealthcareProcessor

# Cybersecurity semantic processing
cyber_processor = CybersecurityProcessor(
    threat_intelligence_feeds=["misp", "stix"],
    ontology="cybersecurity.owl",
    enable_threat_hunting=True
)

# Process security incidents
incident_report = """
APT29 exploited CVE-2024-1234 in Microsoft Exchange to deploy Cobalt Strike.
The attack used spear-phishing emails with malicious attachments.
"""

cyber_analysis = cyber_processor.analyze(incident_report)
print("Threat Actors:", cyber_analysis.threat_actors)
print("Vulnerabilities:", cyber_analysis.vulnerabilities)
print("Attack Techniques:", cyber_analysis.mitre_techniques)

# Financial semantic processing
finance_processor = FinanceProcessor(
    market_data_sources=["yahoo", "alpha_vantage"],
    ontology="finance.owl",
    enable_sentiment_analysis=True
)

# Healthcare semantic processing
health_processor = HealthcareProcessor(
    medical_ontologies=["snomed", "icd10"],
    enable_drug_interaction_detection=True
)

🎯 Context Engineering for RAG

from semanticore.context import ContextEngineer

# Advanced context engineering
context_engineer = ContextEngineer(
    max_context_length=128000,
    compression_strategy="semantic_preservation",
    relevance_scoring=True
)

# Optimize context for specific queries
query = "How can we improve cloud security against APT attacks?"
documents = load_security_documents()

# Intelligent context compression
optimized_context = context_engineer.optimize_context(
    query=query,
    documents=documents,
    preserve_entities=True,
    maintain_relationships=True,
    compression_ratio=0.3  # 70% reduction while preserving meaning
)

print(f"Context compressed from {len(documents)} to {len(optimized_context)} tokens")
print(f"Semantic preservation: {context_engineer.preservation_score:.2%}")

🔄 Real-time Semantic Processing

from semanticore.streaming import SemanticStreamProcessor

# Real-time semantic processing
stream_processor = SemanticStreamProcessor(
    input_streams=["kafka://events", "websocket://feeds"],
    processing_pipeline=[
        "entity_extraction",
        "relationship_detection", 
        "ontology_mapping",
        "knowledge_graph_update"
    ],
    batch_size=100,
    processing_interval="5s"
)

# Process streaming data
async for semantic_event in stream_processor.process():
    if semantic_event.confidence > 0.8:
        # Update knowledge graph
        core.update_knowledge_graph(semantic_event)
        
        # Trigger alerts if needed
        if semantic_event.importance == "critical":
            await alert_system.send_alert(semantic_event)

🔀 Semantic Routing & Orchestration

from semanticore.routing import SemanticRouter

# Multi-dimensional semantic routing
router = SemanticRouter(
    routing_dimensions=["intent", "domain", "complexity", "urgency"],
    agents={
        "security_analyst": SecurityAgent(),
        "data_scientist": DataScienceAgent(),
        "business_analyst": BusinessAgent()
    }
)

# Route queries to appropriate agents
query = "Analyze the security implications of our latest data breach"
routed_agent = router.route_query(query)
response = routed_agent.process(query)

🏗️ Architecture & Deployment

🏢 Enterprise Architecture

from semanticore.enterprise import SemanticEnterprise

# Enterprise-grade deployment
enterprise = SemanticEnterprise(
    deployment_mode="distributed",
    scaling_strategy="auto",
    monitoring_enabled=True,
    security_features=[
        "encryption_at_rest",
        "encryption_in_transit", 
        "access_control",
        "audit_logging"
    ]
)

# Multi-tenant configuration
enterprise.configure_tenants({
    "healthcare_org": {
        "compliance": ["hipaa", "gdpr"],
        "ontology": "healthcare.owl",
        "data_classification": "sensitive"
    },
    "finance_org": {
        "compliance": ["sox", "pci_dss"],
        "ontology": "finance.owl", 
        "data_classification": "confidential"
    }
})

☁️ Cloud Deployment

# docker-compose.yml
version: '3.8'
services:
  semanticore:
    image: semanticore:latest
    environment:
      - SEMANTICORE_MODE=production
      - OPENAI_API_KEY=${OPENAI_API_KEY}
      - NEO4J_URI=${NEO4J_URI}
      - PINECONE_API_KEY=${PINECONE_API_KEY}
    ports:
      - "8000:8000"
    volumes:
      - ./ontologies:/app/ontologies
      - ./models:/app/models
    depends_on:
      - neo4j
      - redis
      
  neo4j:
    image: neo4j:latest
    environment:
      - NEO4J_AUTH=neo4j/password
    ports:
      - "7474:7474"
      - "7687:7687"
      
  redis:
    image: redis:alpine
    ports:
      - "6379:6379"

🚀 Kubernetes Deployment

# k8s/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: semanticore
spec:
  replicas: 3
  selector:
    matchLabels:
      app: semanticore
  template:
    metadata:
      labels:
        app: semanticore
    spec:
      containers:
      - name: semanticore
        image: semanticore:latest
        ports:
        - containerPort: 8000
        env:
        - name: SEMANTICORE_MODE
          value: "production"
        - name: DISTRIBUTED_PROCESSING
          value: "true"
        resources:
          requests:
            memory: "2Gi"
            cpu: "1"
          limits:
            memory: "4Gi"
            cpu: "2"

🎓 Examples & Use Cases

🔐 Cybersecurity Intelligence

# Threat intelligence analysis
threat_data = """
New malware family 'StealthBot' discovered targeting financial institutions.
Uses advanced evasion techniques and communicates with C2 servers via encrypted channels.
Initial infection vector appears to be phishing emails with malicious PDF attachments.
"""

# Extract threat intelligence
threat_analysis = core.extract_threat_intelligence(threat_data)
print("Malware Family:", threat_analysis.malware_families)
print("Attack Vectors:", threat_analysis.attack_vectors)
print("Indicators:", threat_analysis.iocs)

# Update threat knowledge graph
core.update_threat_landscape(threat_analysis)

📊 Financial Analysis

# Market sentiment analysis
financial_news = """
Tesla's Q4 earnings beat expectations with record deliveries. 
Stock surged 12% in after-hours trading as investors responded positively 
to the company's guidance for 2025 production targets.
"""

# Extract financial insights
financial_analysis = core.extract_financial_semantics(financial_news)
print("Companies:", financial_analysis.companies)
print("Financial Metrics:", financial_analysis.metrics)
print("Sentiment:", financial_analysis.sentiment)
print("Market Impact:", financial_analysis.market_impact)

🧬 Research Intelligence

# Scientific literature analysis
research_paper = """
Our study demonstrates that CRISPR-Cas9 gene editing can effectively 
target oncogenes in pancreatic cancer cells, showing 85% reduction 
in tumor growth in mouse models.
"""

# Extract research insights
research_analysis = core.extract_research_semantics(research_paper)
print("Techniques:", research_analysis.techniques)
print("Findings:", research_analysis.findings)
print("Entities:", research_analysis.biological_entities)
print("Relationships:", research_analysis.causal_relationships)

🛠️ Configuration

⚙️ Configuration File

# semanticore.yaml
llm:
  provider: "openai"
  model: "gpt-4-turbo"
  api_key: "$OPENAI_API_KEY"
  temperature: 0.1
  max_tokens: 4000

embeddings:
  provider: "openai"
  model: "text-embedding-3-large"
  dimensions: 1536

vector_store:
  provider: "pinecone"
  api_key: "$PINECONE_API_KEY"
  environment: "us-west1-gcp"
  index_name: "semanticore"

graph_database:
  provider: "neo4j"
  uri: "bolt://localhost:7687"
  username: "neo4j"
  password: "$NEO4J_PASSWORD"

processing:
  semantic_layers: ["lexical", "syntactic", "semantic", "pragmatic"]
  enable_coreference_resolution: true
  enable_temporal_reasoning: true
  enable_causal_reasoning: true

ontology:
  auto_generate: true
  formats: ["owl", "rdf", "json-ld"]
  validation: true
  versioning: true

🔧 Environment Variables

# Core configuration
export SEMANTICORE_MODE=production
export SEMANTICORE_LOG_LEVEL=info

# LLM providers
export OPENAI_API_KEY=your_openai_key
export ANTHROPIC_API_KEY=your_anthropic_key
export GOOGLE_API_KEY=your_google_key

# Vector stores
export PINECONE_API_KEY=your_pinecone_key
export MILVUS_HOST=localhost
export MILVUS_PORT=19530

# Graph databases
export NEO4J_URI=bolt://localhost:7687
export NEO4J_USERNAME=neo4j
export NEO4J_PASSWORD=your_password

# Optional: Enable specific features
export ENABLE_REAL_TIME_PROCESSING=true
export ENABLE_SEMANTIC_CACHING=true
export ENABLE_DISTRIBUTED_PROCESSING=true

📚 Documentation & Resources

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

🛣️ Development Roadmap

v1.0 (Current)

  • Core semantic processing engine
  • Multi-LLM integration (OpenAI, Anthropic, Google)
  • Knowledge graph construction (Neo4j, KuzuDB)
  • Vector store integration (Pinecone, Milvus, Weaviate)
  • Ontology generation and management

v1.1 (Next)

  • 🔄 Multimodal processing (images, audio, video)
  • 🔄 Advanced reasoning capabilities
  • 🔄 Real-time streaming processing
  • 🔄 Enhanced enterprise features

v1.2 (Future)

  • 🔄 Federated learning capabilities
  • 🔄 Quantum-inspired semantic processing
  • 🔄 Advanced causal reasoning
  • 🔄 Autonomous semantic agents

📄 License

SemantiCore is released under the MIT License. See LICENSE for details.

🙏 Acknowledgments

  • Built with ❤️ by the open-source community
  • Inspired by the latest advances in semantic AI and knowledge representation
  • Powered by cutting-edge LLM and embedding technologies

Ready to transform your unstructured data into intelligent semantic knowledge?

pip install semanticore

Get started in 30 seconds → Quick Start Guide

Languages
Python 91.4%
TypeScript 8.4%