yolo-hyl/medical-rag

医学中文RAG项目,使用langchain+milvus,支持快速一键式部署,支持无缝领域迁移

What it solves

This project provides a professional medical question-answering system that overcomes the limitations of simple retrieval by using a Retrieval-Augmented Generation (RAG) approach. It specifically addresses the challenge of maintaining high accuracy in the medical domain by combining semantic search with keyword-based matching and providing an agentic framework to handle complex queries.

How it works

The system utilizes a hybrid retrieval strategy combining dense vectors (for semantic meaning) and sparse vectors (BM25 for keyword matching), stored in a Milvus vector database. It employs a pipeline that includes data preprocessing, domain-specific tokenization (via pkuseg), and a flexible configuration system for various LLMs (like OpenAI or Ollama).

To handle complex interactions, it implements:

  • RAG Agents: Intelligent agents that automatically determine retrieval parameters, verify if answers are supported by the documents, and decide when to trigger external web searches (via Tencent Cloud).
  • Multi-turn Dialogue: A system that manages conversation history with token estimation and dynamic summarization to maintain context.
  • Evaluation Tools: A built-in pipeline to generate and test Q-A pairs to measure the system's recall and precision.

Who it’s for

  • Developers building specialized medical AI assistants.
  • Researchers needing a high-precision RAG pipeline for domain-specific knowledge bases.
  • Engineers looking for a template to migrate RAG systems to other professional fields like law or finance.

Highlights

  • Hybrid Retrieval: Combines dense and sparse vectors to achieve higher recall (91.32%) and precision (92.15%) than single-method retrieval.
  • Agentic Orchestration: Uses LangGraph to create agents that manage the entire retrieval process and can fallback to web search.
  • Domain Optimization: Includes medical-specific tokenization and vocabulary management.
  • Flexible Infrastructure: Supports multiple LLM providers and embedding models via a unified configuration file.

Related

  • Project
  • Project
  • Project
  • Project