Knexion: Project Story
Inspiration
The inspiration for Knexion came from a daily frustration I experienced as someone working with knowledge-intensive tasks. I found myself constantly drowning in PDFs - research papers, technical documentation, reports, manuals - each containing valuable insights but existing in complete isolation from one another.
Traditional document search felt primitive, like looking for a needle in a haystack. Even when I found relevant documents, I had to manually piece together connections between concepts across different sources. Existing RAG systems weren't much better - they treated documents as disconnected fragments, missing the rich relationships that make knowledge truly useful.
The breakthrough moment came when I realized that human understanding doesn't work through isolated facts. We learn by seeing how ideas connect, influence, and build upon each other. A concept in one document might be the missing piece that explains something in another, but there was no system to automatically discover and surface these connections.
I wanted to build something that could recreate this interconnected understanding - a system that doesn't just retrieve relevant text, but actually understands the web of relationships between concepts and can reason about knowledge gaps in real-time.
What it does
Knexion transforms static PDF documents into an intelligent, interconnected knowledge network that provides contextual, validated answers to user questions.
When you upload PDFs, Knexion performs dual processing:
- Knowledge Graph Construction: Extracts entities (concepts, people, events, processes) and maps relationships between them
- Vector Embedding: Creates semantic representations for similarity-based search
When you ask questions, Knexion uses hybrid retrieval that combines both structured graph reasoning and semantic vector search. But the real intelligence lies in what happens next - the system evaluates whether it has sufficient context to provide a quality answer.
If knowledge gaps are detected, Knexion autonomously searches the web to bridge those gaps, seamlessly integrating external knowledge with your documents. Every generated answer goes through multiple validation layers to prevent hallucinations and ensure grounding in provided context.
The result is an adaptive knowledge assistant that doesn't just search your documents, but actually understands them and can reason about what it knows and what it doesn't know.
How we built it
The architecture follows a modular design with clear separation of concerns:
Frontend (Streamlit): Clean interface for document upload, conversation management, and knowledge graph visualization. Users can see not just the answers, but the underlying reasoning through interactive graph displays.
Backend (FastAPI): RESTful API handling file processing, conversation persistence, and coordination between system components.
Knowledge Storage (TiDB): Dual-purpose database storing both vector embeddings for semantic search and relational data for knowledge graphs. This eliminated the complexity of managing separate systems.
Agent Workflow (LangGraph): The core intelligence layer implementing an agentic workflow that makes decisions about retrieval, validation, and knowledge augmentation.
LLM Integration: Google Gemini for generation and evaluation tasks, OpenAI embeddings for vector representations, structured outputs using Pydantic for reliable data handling.
The system follows this decision process:
- Retrieve context from both knowledge graph and vector store
- Grade document relevance and filter low-quality results
- Generate answer using hybrid context
- Validate for hallucinations and answer quality
- If validation fails, search web for additional context
- Iterate until quality thresholds are met
Challenges we ran into
Knowledge Graph Quality: Initial attempts at entity extraction produced inconsistent results with too much granularity. LLMs would extract entities like "Chapter 1" or "Topic" instead of meaningful concepts. Solving this required extensive prompt engineering with detailed examples and validation rules.
Hybrid Retrieval Balance: Finding the right balance between structured knowledge (graph) and unstructured content (vectors) proved tricky. Different query types benefited from different approaches, and naive combination strategies often emphasized the wrong context.
Performance Bottlenecks: Knowledge graph traversal became computationally expensive as graphs grew. Implementing breadth-first search with smart depth limits and caching was crucial for maintaining real-time response speeds.
Hallucination Prevention: Even with good context retrieval, the LLM would sometimes generate confident-sounding but unsupported claims. Building a robust validation pipeline with multiple checking stages was more complex than initially anticipated.
State Management Complexity: Managing conversation state, document context, and workflow decisions in LangGraph required careful design to handle error conditions and edge cases gracefully.
Database Integration: Coordinating between vector operations and relational graph data while maintaining consistency and performance required deep understanding of TiDB's capabilities and limitations.
Accomplishments that we're proud of
Hybrid Intelligence: Successfully combined symbolic reasoning (knowledge graphs) with semantic understanding (vector embeddings) in a way that leverages the strengths of both approaches.
Autonomous Gap Detection: The system can automatically identify when it lacks sufficient knowledge and take corrective action through web search, creating truly adaptive responses.
Multi-Layer Validation: Built a comprehensive validation pipeline that significantly reduces hallucinations while maintaining response quality and relevance.
Interactive Knowledge Visualization: Users can explore the underlying knowledge structure through interactive graphs, providing transparency into the system's reasoning process.
Production-Ready Architecture: Created a modular, scalable system with proper error handling, security measures, and conversation persistence that could realistically be deployed.
Self-Improving Workflow: The agentic approach means the system gets better at answering questions by learning from validation failures and iteratively improving context.
What we learned
Prompt Engineering is an Art: The quality of knowledge extraction depends heavily on carefully crafted prompts. Generic instructions produce poor results, while specific examples and constraints dramatically improve output quality.
Validation is Non-Negotiable: Without proper grounding checks, even sophisticated retrieval systems can produce confident-sounding but incorrect answers. Multiple validation layers are essential for trustworthy AI systems.
User Experience Drives Adoption: The most technically advanced system is worthless if users can't understand or effectively interact with it. Investing in clear UI/UX pays dividends in system utility.
Performance vs Quality Trade-offs: Every additional validation step improves answer quality but increases response time. Finding the optimal balance requires careful benchmarking and user feedback.
Modularity Enables Innovation: Separating concerns into distinct components made it much easier to iterate on individual pieces without breaking the entire system.
Observability is Critical: Complex agent workflows require extensive logging and visualization capabilities to debug issues and understand system behavior.
What's next for Knexion
Adaptive Learning: Implement user feedback mechanisms so the system can learn from corrections and preferences, continuously improving relevance and accuracy for specific use cases.
Multi-Modal Expansion: Extend beyond PDFs to support images, videos, spreadsheets, and other document types, creating truly comprehensive knowledge bases.
Collaborative Knowledge: Enable knowledge sharing across teams while maintaining privacy controls, allowing organizations to build collective intelligence.
Domain Specialization: Fine-tune extraction and reasoning capabilities for specific domains like legal documents, scientific literature, or technical manuals.
Advanced Reasoning: Implement more sophisticated logical reasoning capabilities, including temporal reasoning, causal inference, and multi-step problem solving.
Integration Ecosystem: Build connectors for popular productivity tools, databases, and enterprise systems to seamlessly integrate with existing workflows.
Performance Optimization: Implement advanced caching, parallel processing, and model optimization techniques to reduce response times while maintaining quality.
Enterprise Features: Add role-based access controls, audit logging, and compliance features needed for enterprise deployment.
Built With
- dspy
- fastapi
- google-gemini-2.0-flash
- langchain
- langgraph
- openai-embeddings
- pydantic
- python
- pyvis
- sqlalchemy
- streamlit
- tavily-api
- tidb-cloud
Log in or sign up for Devpost to join the conversation.