Skip to content

prayaslashkari/nlp-knowledge-graph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image

NL-to-SPARQL

A local-first web application that converts natural language queries into SPARQL, executes them against a GraphDB instance, and returns structured results.

Features

  • Natural Language Querying: Ask questions in English (e.g., "Who are the authors from MIT?").
  • Swappable LLM Providers: Support for Claude (Anthropic), OpenAI (Implementation ready), and a local Mock provider for testing.
  • SPARQL Transparency: View, edit, and re-execute the generated SPARQL queries.
  • Interactive Results: Browse results in a clean table format.
  • Ontology Visualization: View the underlying schema.

Tech Stack

  • Frontend: React + TypeScript + Vite + Tailwind CSS
  • Backend: FastAPI + Python 3.11
  • Database: GraphDB (Running via Docker)
  • LLM: Anthropic Claude API (or Mock)

Prerequisites

  • Docker & Docker Compose
  • Node.js 18+ (for local frontend dev)
  • Python 3.11+ (for local backend dev)
  • Anthropic API Key (optional, can use Mock mode)

Getting Started

1. Setup Environment

Create a .env file in the backend/ directory (optional, for LLM keys):

ANTHROPIC_API_KEY=your_key_here
LLM_PROVIDER=claude  # or 'mock'

2. Generate Seed Data

Generate the synthetic knowledge graph data:

pip3 install rdflib
python3 data/generate_data.py

3. Run with Docker Compose

The easiest way to run the full stack:

docker compose up --build

4. Load Data into GraphDB

  1. Open GraphDB at http://localhost:7200
  2. Create a repository named research-kg.
  3. Import data/ontology.ttl and data/seed.ttl into the repository.

Development

Backend

cd backend
pip install -r requirements.txt
uvicorn app.main:app --reload

Frontend

cd frontend
npm install
npm run dev

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors