TCM-VisResolve: Multimodal Recognition of Dried Herbs and Clinical MCQ Answering in TCM
[cite_start]TCM-VisResolve (TCM-VR) is a domain-specific multimodal large language model (MLLM) designed for Traditional Chinese Medicine (TCM)[cite: 12, 13, 83].
[cite_start]This model, fine-tuned from Qwen2.5-VL [cite: 201][cite_start], is specifically engineered to bridge the gap between visual recognition and symbolic reasoning in TCM[cite: 14]. It excels at two primary tasks:
[cite_start]Recognizing images of dried medicinal herbs[cite: 13, 84].
[cite_start]Domain-Specific Expertise: Fine-tuned on a massive dataset of 220,000 herb images (163 classes) and 220,000 clinical MCQs[cite: 14, 84, 115, 203].
[cite_start]High Accuracy: Achieves 96.7% accuracy on a held-out test suite of TCM-related MCQs [cite: 22, 92, 117, 481][cite_start], significantly outperforming general-purpose models like GPT-40 and Gemini[cite: 22, 92, 117].
[cite_start]Robust & Reliable: Incorporates a Cross-Transformation Memory Mechanism (CTMM) to prevent overfitting and "answer position bias" [cite: 19, 91][cite_start], forcing the model to reason about content rather than memorizing patterns[cite: 23, 330, 443].
🛠️ Training Procedure
Base Model
[cite_start]TCM-VR uses Qwen2.5-VL as its vision-language backbone[cite: 84, 201].
Dataset
[cite_start]The model was fine-tuned using a comprehensive, specially-curated dataset[cite: 162, 203]:
[cite_start]Images: 220,000 real-world images of dried and processed herbs across 163 categories[cite: 14, 162, 203].
[cite_start]Text: 220,000 multiple-choice questions (totaling 880,000 answer options) [cite: 14, 84, 115] [cite_start]structured in a vision-language JSON format[cite: 211].
Cross-Transformation Memory Mechanism (CTMM)
[cite_start]To ensure the model learns to reason rather than memorize [cite: 316, 434][cite_start], the CTMM was applied during training[cite: 91, 472]. [cite_start]This mechanism enforces semantic consistency by[cite: 337]:
[cite_start]Paraphrasing Prompts: Using varied linguistic structures for semantically identical questions[cite: 19, 323, 343].
[cite_start]Shuffling Answer Orders: Randomizing the A, B, C, D options for each question to disrupt positional biases[cite: 19, 91, 325, 330].
📊 Performance
[cite_start]On a held-out test split, TCM-VR achieves 96.7% accuracy on multimodal clinical MCQs[cite: 22, 92, 117, 481]. [cite_start]Case studies confirm that the model can correctly identify the right answer even when its position is shuffled, demonstrating true reasoning capabilities[cite: 23, 442, 443].
🖼️ Example Multimodal Cases
Case 00 - Herb Image
Case 01 - Question
Case 01 - Answer
Case 02 - Question
Case 02 - Answer
[cite_start]These examples illustrate typical inputs (herb images + MCQs) and the model’s reasoning-style answers[cite: 185, 187, 190].
💡 How to Use
You can use this model similarly to other Qwen-VL models for multimodal chat. [cite_start]The model expects an image and a structured query, as shown in the paper's training data (Figure 2)[cite: 185, 187, 190].
python
1import torch
2from PIL import Image
3from transformers import AutoModelForCausalLM, AutoTokenizer
45# Set device6device ="cuda"if torch.cuda.is_available()else"cpu"78# Load the model and tokenizer9# !! Replace "your-username/TCM-VisResolve" with your model's HF path !!10model_id ="your-username/TCM-VisResolve"11tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)12model = AutoModelForCausalLM.from_pretrained(13 model_id,14 device_map="auto",15 trust_remote_code=True,16 bf16=True17).eval()1819# 1. Load your herb image20# [cite_start]Example using the 'Gan Jiang' image from the paper [cite: 169]21image_path ="path/to/your/herb_image.jpg"# e.g., "data/mcq_output/gangjiang_gangjiang_1577.jpg" [cite: 189]22image = Image.open(image_path)2324# 2. Format your query25# The query should include the image placeholder and the MCQ26# [cite_start]This example is based on Figure 2 in the paper [cite: 185, 190]27question =(28"这是什么中药? 以下哪项不是该药材的适应症? "29"A. 主治:赤眼涩痛;咳嗽上气... "30"B. 主治:补肝明目... "31"C. 主治:鼻血不止... "32"D. 主治:背痈..."33)3435# Format the prompt for the model36messages =[37{38"role":"user",39"content":[40{"type":"image","image": image},41{"type":"text","text": question},42],43}44]45text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)46model_inputs = tokenizer([text], return_tensors="pt").to(device)4748# 3. Generate the response49generated_ids = model.generate(50 model_inputs.input_ids,51 max_new_tokens=1024,52)53generated_ids =[54 output_ids[len(input_ids):]55for input_ids, output_ids inzip(model_inputs.input_ids, generated_ids)56]5758response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]59print(response)6061# [cite_start]Example output (based on Figure 2 [cite: 187]):62# "名称:干姜 拼音:gangjiang ... 功效:主治:赤眼涩痛... 正确答案是 A 选项内容:..."