模型简介
模型特点
模型能力
使用案例
🚀 ArindamSingh/gemma-3-1b-it-medical-o1-reasoning-finetune-16bit
本项目基于unsloth/gemma-3-1b-it
模型进行微调,专门针对医学推理场景进行优化,能够为医学教育、研究等领域提供支持。
🚀 快速开始
from transformers import pipeline
msg = "What is type 2 diabetes?"
pipe = pipeline("text-generation", model="ArindamSingh/gemma-3-1b-it-medical-o1-reasoning-finetune-16bit")
messages = [
{"role": "user", "content": msg},
]
pipe(messages)
✨ 主要特性
- Chain-of-Thought answers:借助Medical-O1数据集,能够提供逐步推理的答案。
- Unsloth加速:在单张A100上,使用Unsloth加速的LoRA将训练时间缩短了约40%。
- Merged weights:无需额外的适配器步骤,可直接替代Gemma模型。
- Tiny footprint:下载大小小于2GB,可在4GB显存或CPU上通过GGUF/HF库运行。
📦 安装指南
文档未提供安装步骤,故跳过此章节。
💻 使用示例
基础用法
from transformers import pipeline
msg = "What is type 2 diabetes?"
pipe = pipeline("text-generation", model="ArindamSingh/gemma-3-1b-it-medical-o1-reasoning-finetune-16bit")
messages = [
{"role": "user", "content": msg},
]
pipe(messages)
高级用法
文档未提供高级用法代码示例,故跳过此部分。
📚 详细文档
1. 模型卡片快照
属性 | 详情 |
---|---|
基础模型 | google/gemma-3-1b-it |
参数数量 | 10亿(完整)– LoRA秩8适配器合并 |
精度 | 16位 (fp16 ) |
领域 | 临床与生物医学推理 |
微调框架 | FreedomIntelligence Medical-O1 Reasoning (20 k Q-CoT-A) + Unsloth LoRA |
训练方法 | 监督式CoT SFT → LoRA合并与量化 |
最后更新时间 | 查看HF页面 |
许可证 | Apache-2.0 |
2. 与基础Gemma-3 1B-IT模型对比
- Chain-of-Thought answers:得益于Medical-O1数据集,能够提供逐步推理的答案。
- Unsloth加速:在单张A100上,使用Unsloth加速的LoRA将训练时间缩短了约40%。
- Merged weights:无需额外的适配器步骤,可直接替代Gemma模型。
- Tiny footprint:下载大小小于2GB,可在4GB显存或CPU上通过GGUF/HF库运行。
3. 预期用途
✔️ 预期用途 | ❌ 谨慎使用/超出范围 |
---|---|
医学教育、PubMed分类、编码建议(ICD、SNOMED)、研究构思 | 自动诊断、紧急分诊、任何需要监管批准的决策 |
4. 微调概述
项目 | 设置 |
---|---|
数据集 | FreedomIntelligence/medical-o1-reasoning-SFT (19 704行) |
提示格式 | 问题 + 复杂的思维链 → 响应 |
库 | Unsloth 0.6 + 8位 paged_adamw |
LoRA配置 | r = 8, α = 32, 丢弃率 = 0.05 (q/k/v/o & MLP投影) |
硬件 | 2 × T4-16 GB (flash-attn 2) |
训练 | 3个周期 - 学习率 = 2e-5 余弦 - 批次 = 1 × 4 梯度累积 |
运行时间 | 约4小时 (Unsloth对比普通PEFT约6.5小时) |
5. 评估亮点*
任务(开发子集) | 指标 | 基础Gemma-1B-IT | 本模型 |
---|---|---|---|
PubMedQA | QA-F1 | 46% | 57% |
*100个问题样本,贪心解码;脚本位于eval/
目录。
6. 局限性与偏差
- 可能会虚构引用或使用过时的指南。
- 数据集以英语为主,对儿科/罕见疾病的覆盖有限。
- 非医疗设备,使用时需有人为监督。
7. 负责任的AI清单
- [x] 临床使用前进行人工审核
- [x] 声明“非医疗建议”
8. 引用
@misc{singh2025gemma1bmed,
title = {Gemma-3 1B Medical-O1: Compact Chain-of-Thought Clinical LLM},
author = {Arindam Singh},
year = {2025},
url = {https://huggingface.co/ArindamSingh/gemma-3-1b-it-medical-o1-reasoning-finetune-16bit}
}
9. 致谢
感谢Google DeepMind(Gemma)、FreedomIntelligence(Medical-O1数据集)、Unsloth团队、Kaggle、Google Colab和Hugging Face提供的开放生态系统。
10. 示例输出
[{'generated_text': [{'role': 'user', 'content': 'What is type 2 diabetes?'}, {'role': 'assistant', 'content': "Okay, let's break down type 2 diabetes. It's a complex condition, but here's a comprehensive explanation:\n\nWhat is Type 2 Diabetes?\n\nType 2 diabetes is a chronic metabolic disorder in which the body doesn't use insulin properly. Insulin is a hormone produced by the pancreas that helps glucose (sugar) from food get into your cells to be used for energy. When insulin resistance develops, the pancreas has to work harder to produce more insulin to compensate, and eventually, it can't keep up with the demand.\n\nHere's a more detailed breakdown:\n\n1. It's Not About Insulin Resistance (Initially): The key difference between type 1 and type 2 diabetes is how the body handles insulin.\n * Type 1 Diabetes: This is an autoimmune condition where the body's immune system attacks and destroys the insulin-producing cells (beta cells) in the pancreas. People with type 1 diabetes require insulin injections or pump to survive.\n * Type 2 Diabetes: This is a process where the body becomes resistant to insulin, and the pancreas initially tries to compensate by producing more insulin. Over time, the pancreas can't keep up, and blood sugar levels rise.\n\n2. How it Develops:\n * Lifestyle Factors: Type 2 diabetes often develops gradually, often as a result of a combination of:\n * Genetics: A family history of diabetes increases your risk.\n * Diet: A diet high in processed foods, sugary drinks, and unhealthy fats can contribute.\n * Lack of Exercise: Being physically inactive increases your risk.\n * Obesity: Excess weight, particularly around the abdomen, is strongly linked to insulin resistance.\n * Pancreatic Dysfunction: As the pancreas struggles to produce enough insulin, it can gradually lose its ability to do so effectively.\n\n3. Symptoms: Many people with type 2 diabetes have no noticeable symptoms for months or even years. However, as the condition progresses, symptoms can develop:\n * Frequent Urination: The kidneys try to get rid of excess sugar in the urine.\n * Excessive Thirst: Due to the body’s attempt to regulate fluid balance.\n * Increased Hunger: The body isn't using glucose effectively.\n * Fatigue: Lack of energy.\n * Blurred Vision: High blood sugar can affect the lens of the eye.\n * Slow-Healing Sores: High blood sugar can impair wound healing.\n * Frequent Infections: High blood sugar can weaken the immune system.\n\n4. Complications (if not managed): If left untreated, type 2 diabetes can lead to serious health problems:\n * Cardiovascular Disease: Heart disease, stroke.\n * Neuropathy: Nerve damage, causing pain, numbness, and tingling (especially in the hands and feet).\n * Nephropathy: Kidney disease.\n * Retinopathy: Eye damage.\n * Foot Problems: Poor circulation and nerve damage can lead to infections and ulcers.\n\nDiagnosis:\n\n* Blood Tests: A fasting blood glucose test is the primary test. A random blood glucose test can also be done.\n* A1C Test: This tests your average blood sugar level over the past 2-3 months.\n\nTreatment:\n\n* Lifestyle Changes: Diet and exercise are crucial.\n* Metformin: A common medication that helps lower blood sugar.\n* Other Medications: Oral medications, insulin injections, or a combination of these may be needed.\n* Regular Monitoring: Blood sugar levels need to be monitored regularly to adjust treatment as needed.\n\nImportant Note: This information is for general knowledge and informational purposes only, and does not constitute medical advice. It is essential to consult with a qualified healthcare professional for any health concerns or before making any decisions related to your health or treatment.\n\nResources:\n\n* American Diabetes Association: https://www.diabetes.org/\n* Centers for Disease Control and Prevention (CDC) - Diabetes: https://www.cdc.gov/diabetes/index.html\n\n---\n\nDisclaimer: I am an AI Chatbot and not a medical professional. This information is intended for general knowledge and informational purposes only, and does not constitute medical advice. It is essential to consult with a qualified healthcare professional for any health concerns or before making any decisions related to your health or treatment.\n\nTo help me give you even more tailored information, could you tell me:\n\n* Are you interested in learning more about a specific aspect of type 2 diabetes (e.g., treatment options, prevention, symptoms)?"}]}]
🔧 技术细节
文档未提供技术实现细节,故跳过此章节。
📄 许可证
本项目使用Apache-2.0许可证。



