CoolFace
Apppublic

OutstandingOm/knowledge-graph-env

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes
README.md109 linesDownload Raw Back to root
1---2title: Knowledge Graph Environment3emoji: 🧠4colorFrom: blue5colorTo: indigo6sdk: docker7app_port: 78608---9 10# Self‑Evolving Knowledge Graph Environment for Continuous Reasoning11 12> *Think of it as a system that stores knowledge like a graph, learns continuously after deployment, and answers in milliseconds.*13 14> *Fast, memory‑efficient, and continuously learning – designed for real‑world customer support automation.*15 16---17 18## 🎯 What is this?19 20A **reinforcement learning environment** that simulates customer support ticket triage.  21An agent learns to:22 231. **Identify** the main issue from a support ticket.242. **Relate** it to a known concept in a dynamic knowledge graph.253. **Answer** with a resolution action.26 27Unlike static environments or large language models (LLMs), our system **maintains persistent memory of concepts and relationships** and **improves after deployment through continuous background updates** – without retraining.28 29---30 31## 🧠 Key Innovations (Why it’s different)32 33| Feature | What it does | Why it matters |34|---------|--------------|----------------|35| **Persistent memory** | Stores concepts and relationships permanently | The agent never forgets past tickets |36| **Continuous learning** | Background trainer updates vectors every 10 seconds | The system gets smarter over time, even after deployment |37| **DNA‑inspired encoding** | Each concept is built from structured combinations of simple components (letters A–Z), enabling compact and composable representations. Compact 16‑dim vectors. | Very low memory (~150 MB for 1000 concepts) and fast (<1 ms query) |38| **Reasoning engine** | Multi‑hop graph propagation + analogical reasoning | Can answer complex queries like “A is to B as C is to ?” |39| **Deterministic grading** | Clear reward rules (exact match → 1.0, partial → 0.7/0.3) | Judges can reproduce scores 100% of the time |40 41---42 43## ⚙️ How It Works (simple version)44 451. **Input** – a support ticket (e.g., *“I can’t log in”*)462. **Feature extraction** – keywords become features (e.g., “login”, “password”)473. **DNA encoding** – each feature maps to a sequence of letters (A–Z) with learnable vectors; a concept vector is the sum of its features’ encodings. *DNA‑inspired encoding means each concept is built from structured combinations of simple components (letters A–Z), enabling compact and composable representations.*484. **Knowledge graph** – concepts are nodes; relationships are edges. When two concepts are linked, their vectors move closer – the whole graph learns.495. **Reasoning** – FAISS search (similarity) + multi‑hop activation + analogical arithmetic.506. **Reward** – deterministic scoring based on exact match, substring, or word overlap (0.0 / 0.3 / 0.7 / 1.0).51 52---53 54## 📊 OpenEnv Tasks (3 independent graders)55 56| Task | Difficulty | Description | Example input | Expected output |57|------|------------|-------------|---------------|-----------------|58| `task_easy` | Easy | Identify the main concept | *“Login not working”* | `login issue` |59| `task_medium` | Medium | Find the correct relation | *“Bill is wrong”* | `refund` |60| `task_hard` | Hard | Provide the resolution | *“Locked out after failed payment”* | `reset password` |61 62All graders are **deterministic** and return a score between 0.0 and 1.0.63 64---65 66## ⚡ Performance (on 2 vCPU / 8GB)67 68| Metric | Value |69|--------|-------|70| Latency per step | < 1 ms |71| Full episode (3 steps) | < 5 ms |72| Memory for 1,000 concepts | ~150 MB |73| Determinism | 100% (same input → same score) |74| Scalability | Up to 100,000 concepts with < 2 ms search |75 76---77 78## 🔄 Comparison with LLMs (balanced view)79 80| Aspect | LLM‑based approach | Our environment |81|--------|--------------------|-----------------|82| **Memory** | Context window only; external DB needed | Persistent graph, built‑in |83| **Latency** | Seconds | Microseconds |84| **Cost** | API or GPU | Zero (CPU only) |85| **Learning after deployment** | Expensive fine‑tuning | Automatic background updates |86| **Best for** | General reasoning, creative generation | Structured, repetitive, fast queries |87 88> *We do not claim to replace LLMs – we provide a complementary solution for tasks that require low latency, persistent memory, and incremental learning.*89 90---91 92## 🚀 Real‑World Use Cases93 94- **Customer support ticket routing** – learn new issues continuously.95- **Enterprise knowledge management** – keep a living graph of documents.96- **Educational tutoring systems** – track student misconceptions.97- **Legal case law analysis** – link new precedents to old rulings.98 99---100 101## 🛠️ How to Run102 103### Locally104```bash105git clone https://github.com/outstandingom/dna-modal.git106cd dna-modal107pip install -r requirements.txt108python inference.py109