How irlab-sdu/fuzi.mingcha works
Project Type and Purpose
• This is an open‑source AI tool: a Chinese judicial large language model (“夫子·明察司法大模型”) built on ChatGLM‑6B.
• It exposes a CLI for legal Q&A, case retrieval, statute retrieval, and syllogistic reasoning, combining LLM inference with retrieval modules (Elasticsearch and PyLucene).
Key Elements from File Structure
• Top‐level:
• README.md, LICENSE, CITATION.cff, images/ (screenshots)
• src/ (all code and configs)
• src/:
• cli_demo.py – the entrypoint for model deployment and user interaction
• es_task1/api.py, es_task2/api.py – Elasticsearch–based statute & case retrieval
• pylucene_task1/api.py, pylucene_task2/api.py – PyLucene–based retrieval with CSV seed data
• src/requirements.txt – Python dependencies
• Singularity安装与使用.md – containerization instructions
• csv_files/ – seed data for Lucene indexes
High‑Level Components to Model
a. User & Interface
– CLI (cli_demo.py): accepts user question or legal case description
b. Retrieval Layer
– Elasticsearch Service
• es_task1: statute retrieval
• es_task2: case retrieval
– Local Lucene Index
• pylucene_task1: statute retrieval from CSV
• pylucene_task2: case retrieval from CSV
c. Model Inference Layer
– ChatGLM‑6B model loaded locally (ModelScope/HuggingFace API)
– Prompt assembler: integrates retrieved statutes/cases into prompt
d. Data Stores and Preprocessing
– CSV seed files (pylucene_task*/csv_files)
– External datasets (HuggingFace datasets for training/tuning)
e. External Services
– HuggingFace / ModelScope (model weights & datasets)
Relationships and Data Flow
1. User → CLI
2. CLI dispatches to Retrieval Layer in parallel (ES + Lucene)
3. Retrieval Layer → returns top‑k statutes & case snippets
4. CLI / Prompt assembler → builds final prompt combining user input + retrieved context
5. Prompt → LLM Inference Layer (via Python SDK)
6. LLM → generates legal consultation / judgment / reasoning
7. CLI → outputs result back to user
Architectural Patterns & Principles
• Modular separation: retrieval modules are pluggable (swap ES with Lucene or other retrievers)
• Pipeline pattern: input → retrieval → prompt assembly → LLM inference → output
• Single‐process Python orchestrator (no web server)—monolithic CLI tool
• Containerization support (Singularity recipe) for reproducible deployments
Essential Details to Capture
• The dual retrieval paths and how they feed into prompt construction
• The external dependency on HuggingFace/ModelScope for model weights
• The CLI as the single orchestrator (no front‑end or web server)
• Containerization instructions in Singularity安装与使用.md as an optional deployment layer