smooth-app
전 세계 식품의 성분·영양·정보를 자유롭게 협업하고 공개하는 데이터베이스
고전 중의학 텍스트와 인용, 지식 그래프 관계를 탐색하는 연구 프로토타입, 의료 조언이 아님
A research prototype for exploring classical Chinese medicine texts, citations and recorded knowledge-graph relationships. Not medical advice.
건강Python · TypeScriptGitHub @AndyZHENG0715온라인운영자 미확인
써 보셨어요? 한 번만 눌러 주세요. 로그인은 필요 없어요.
아직 감지된 업데이트가 없습니다. GitHub 릴리스가 나오면 여기에 보입니다.
개인 계정의 공개 저장소 소유자는 GitHub로 로그인해 운영자를 확인하고 소개를 직접 관리할 수 있습니다. 관리자 승인은 필요하지 않습니다.
로그인한 뒤 확인 파일을 만들어 이 저장소의 기본 브랜치에 30분 안에 커밋해 주세요. 다른 브랜치나 포크의 파일은 인정하지 않습니다. 파일을 올린 뒤 아래에서 확인하면 관리자 승인 없이 관리할 수 있습니다. 자격을 유지하려면 파일을 남겨 두세요.
로그인이 필요하면 로그인 화면으로 이동합니다. 로그인 후 이곳으로 돌아와 원하는 확인 버튼을 다시 눌러 주세요.
프로젝트 폴더에서 /nomorevibe verify를 실행하면 소유권을 확인하고 소개를 직접 관리할 수 있습니다.
1분 만에 확인하기Evidence-synthesis RAG assistant for TCM practitioners — hybrid vector + knowledge graph retrieval over 17 classical texts, with query classification, self-critique verification, and blind A/B arena evaluation.
저장소 README에서 가져옴
README 전체를 불러오는 중입니다.
README 전문 보기 ↗The public site is tcm-sage-sandy.vercel.app. It starts with six clearly labelled prerecorded examples, original excerpts and saved SymMap relationships. These examples work without a model or backend request. English is the default; Chinese is available.
Optional live research requires a project access code. It uses the full12,204-chunk BGE-M3 index, SiliconFlow's fixed free BGE embedding/reranking models and OpenRouter's fixed free Nemotron model. Provider availability is not guaranteed. Historical prescriptions and graph labels are research material, not medical advice or evidence of clinical benefit. Public Arena submissions and raw statistics are disabled; the original presentation entrypoint remains available locally.
Vercel Hobby serves web/; Render Free serves src/release_api.py at tcm-sage-api.onrender.com. Provider keys belong only in the backend environment. Render may sleep; its SQLite quota ledger can reset on replacement instances. Initial live access is code-restricted and fixed-free, with no paid fallback. See release verification and limitations and release operations. The historical architecture/setup below describes the original presentation stack.
TCM-Sage is an evidence-synthesis tool for Traditional Chinese Medicine (TCM) practitioners. This project aims to empower practitioners by providing explainable, evidence-backed insights from the vast corpus of classical TCM literature using a Retrieval-Augmented Generation (RAG) architecture.
The vast body of TCM knowledge, spanning thousands of years of literature, represents both a profound asset and a significant operational challenge. Manually searching for analogous historical cases or cross-referencing symptoms during a patient consultation is impractical. This project leverages a Large Language Model (LLM) not as a decision-maker, but as an intelligent clinical reference assistant. By creating an explainable, evidence-backed tool, TCM-Sage empowers practitioners to query the entire corpus of TCM literature in seconds, helping them validate hypotheses and deliver informed, evidence-based care.
The system is built on a Modular RAG paradigm to handle the complexities of classical Chinese texts.
Knowledge Base: 17 classical TCM texts (3.72M characters) including the four canonical works (《黄帝内经》《伤寒论》《金匮要略》《神农本草经》), 本草纲目, 备急千金要方, 金元四大家著作, and 温病学 texts. Texts are chunked with sentence-aware splitting and embedded into a persistent ChromaDB vector store using DashScope text-embedding-v4 (1024 dimensions).
Hybrid Retriever: The retriever combines semantic vector search with the SymMap 2.0 Knowledge Graph (18,450 entities, 21,476 relationships) built with NetworkX and connected via a crosswalk bridge for entity resolution.
Reflective Generator: A two-layer "glass-box" generator inspired by Self-RAG ensures trustworthy answers:
Query Routing: A small, fast LLM pre-classifies query severity to apply either a creative (higher temperature) or strict (zero temperature) generation setting based on clinical severity.
Self-Critique: The main LLM generates an answer and then validates it against the retrieved source text, providing a direct citation to the source chapter.
The project is in active development approaching FYP presentation:
/kg/[entityId]) with interactive graph visualization.Clone the repository:
git clone https://github.com/AndyZHENG0715/TCM-Sage.git
cd TCM-Sage
Create a Python virtual environment (required):
python -m venv venv
Install backend dependencies using the project venv:
# Windows
venv\Scripts\python.exe -m pip install -r requirements.txt
# macOS / Linux
venv/bin/python -m pip install -r requirements.txt
Install frontend dependencies:
cd web
npm install
cd ..
Set up environment variables:
.env.example to .env.LLM_PROVIDER=alibaba
DASHSCOPE_API_KEY="your-api-key-here"
Build or refresh the vector knowledge base (run once after source updates):
# Windows
venv\Scripts\python.exe src/ingest.py
# macOS / Linux
venv/bin/python src/ingest.py
Start the backend API (http://127.0.0.1:8000):
# Windows
venv\Scripts\python.exe src/api.py
# macOS / Linux
venv/bin/python src/api.py
Start the frontend dev server (http://localhost:3000):
cd web
npm run dev
Run the CLI application (optional):
# Windows
venv\Scripts\python.exe src/main.py
# macOS / Linux
venv/bin/python src/main.py
Run lightweight verification scripts (optional):
# Citation formatting / reconstruction checks
venv\Scripts\python.exe src/test_citations.py
# SymMap KG retrieval sanity checks
venv\Scripts\python.exe scripts/verify_symmap_retrieval.py
TCM-Sage analyzes each query to determine clinical severity, routing it to optimized LLM instances with tailored temperature settings.
A modern, interactive graph viewer powered by @xyflow/react renders subgraph neighborhoods around cited entities with dagre layout, allowing practitioners to explore relationships between symptoms, herbs, formulas, and related entities from the SymMap 2.0 knowledge graph.
All responses are backed by direct, verifiable citations from the 17-text classical corpus. The system quotes original text verbatim before explaining, and presents citations in a dedicated panel with full paragraph viewing and source reconstruction.
A blind A/B comparison system where TCM practitioners evaluate RAG-enhanced responses against plain LLM responses without knowing which is which. Includes a statistics page (/arena/stats) with paired T-Test analysis, win rate charts (downloadable as PNG), and per-query results table.
Live statistical analysis of arena votes with downloadable bar charts and pie charts. Computes t-statistic, p-value, Cohen's d effect size, and significance interpretation for FYP presentation.
Seamlessly switch between Alibaba Cloud, Google, OpenAI, and Anthropic for maximum flexibility and availability.
See docs/CONFIGURATION.md for detailed configuration options including provider setup, retrieval parameters, model selection, and graph depth settings.
TCM-Sage/
├── src/ # Python RAG core (FastAPI, LangChain, retriever, arena)
│ ├── api.py # Thin FastAPI route layer (SSE, CORS, health)
│ ├── source_context.py # Citation source context and raw book lookup
│ ├── arena_stream.py # Arena dual-panel SSE scheduler
│ ├── arena_stats.py # Arena vote statistics and t-test analysis
│ ├── main.py # CLI entry point + LLM factory, prompts, classification
│ ├── retriever.py # HybridRetriever — vector + graph ensemble
│ ├── graph_builder.py # TCMKnowledgeGraph — NetworkX loader, traversal
│ ├── ingest.py # Build vector index + chunks.json
│ ├── arena.py # Arena blind A/B evaluation + vote storage
│ ├── embeddings.py # DashScope text-embedding-v4 + qwen3-rerank
│ └── config.py # Central paths and defaults
├── web/ # Next.js 16 frontend
│ ├── app/ # Routes: chat, arena/, arena/stats, kg/, source/
│ ├── components/ # UI components (CitationPanel, KGViewer, etc.)
│ ├── hooks/ # React hooks (useChat, useArena, useSettings)
│ ├── i18n/ # Chinese/English UI translations
│ └── lib/ # API client, markdown renderer, shared types
├── data/
│ ├── source/ # 17 classical TCM .txt corpus (UTF-8)
│ ├── processed/ # chunks.json + ingest_checkpoint.json
│ ├── graph/symmap/ # SymMap v2.0 KG JSON + raw xlsx
│ ├── graph/crosswalk/ # RAG↔SymMap entity bridge (approved/pending CSV)
│ └── feedback/ # Arena votes (arena_votes.jsonl)
├── scripts/ # Utility and test scripts
├── vectorstore/ # ChromaDB persistence (generated)
├── presentation/ # Slidev FYP presentation
├── docs/ # Project documentation
│ ├── ARCHITECTURE.md # System architecture
│ ├── CONFIGURATION.md # Configuration reference
│ ├── GETTING-STARTED.md # First-time setup guide
│ ├── DEVELOPMENT.md # Developer guide
│ ├── TESTING.md # Testing guide
│ ├── API.md # API reference
│ └── report/ # FYP Final Report (LaTeX + PDF)
└── requirements.txt # Python dependencies
This project is licensed under the MIT License. See the LICENSE file for details.