---
title: MKTY-3B-Chat
canonical_url: "https://www.modelscope.cn/models/duyu09/MKTY-3B-Chat"
md_url: "https://www.modelscope.cn/models/duyu09/MKTY-3B-Chat.md"
repository: duyu09/MKTY-3B-Chat
chinese_name: MKTY-3B-Chat
last_updated: 2025-11-05
license: "Apache License 2.0"
pipeline_tag: text-generation
tasks:
  - text-generation
  - chatbot
model_type:
  - qwen2
architectures:
  - Qwen2ForCausalLM
base_model:
  - Qwen/Qwen2.5-3B-Instruct
base_model_relation: finetune
parameters: 3.1B
tensor_type:
  - BF16
library_name:
  - transformer
  - safetensors
  - pytorch
frameworks:
  - PyTorch
language:
  - zh
  - en
  - vi
inference_backends:
  - "deploy_task text/emb"
  - "lmdeploy 0.9.1"
  - "lmdeploy_turbomind 0.9.1"
  - "sglang 0.5.2"
  - "vllm 0.9.2"
downloads: 37
stars: 0
tags:
  - biology
  - medical
---

# MKTY-3B-Chat

> MKTY-3B-Chat - duyu09 在 ModelScope 开源的模型。明康慧醫大規模語言模型（英語：Minh Khoe Tue Y Large-scale Language Model；越南語：Minh Khỏe Tuệ Y Mô Hình Ngôn Ngữ Quy Mô Lớn）是「明康慧醫 - 基於LLM與多模態人工智慧的健康管理與輔助診療系統設計與實現」專案（簡稱：明康慧醫智慧醫療系統）的組成部分，為本人2025級齊魯工業大學（山東省科學院）計算機科學與技術學部本科畢業設計而開發。專案已開源，地…

duyu09/MKTY-3B-Chat 是 ModelScope 魔搭社区上的 3.1B 参数text-generation、chatbot模型，采用 Apache License 2.0 许可，基于 Qwen/Qwen2.5-3B-Instruct 构建，可用 deploy_task text/emb、lmdeploy 0.9.1、lmdeploy_turbomind 0.9.1 部署。

- **Repository**: duyu09/MKTY-3B-Chat
- **License**: Apache License 2.0
- **Tasks**: text-generation, chatbot
- **Parameters**: 3.1B
- **Base model**: Qwen/Qwen2.5-3B-Instruct
- **Inference backends**: deploy_task text/emb, lmdeploy 0.9.1, lmdeploy_turbomind 0.9.1, sglang 0.5.2, vllm 0.9.2
- **Tags**: biology, medical
- **Downloads**: 37
- **Stars**: 0
- **Last updated**: 2025-11-05

Source: https://www.modelscope.cn/models/duyu09/MKTY-3B-Chat

---

# 明康慧医大模型 (MKTY-3B-Chat)

### 🌍 文档语言

[**简体中文**](./README.md) | [**英语 (English)**](./README_EN.md) | [**越南语 (Tiếng Việt)**](./README_VN.md)


> 请注意，本文档的英文与越南文版本均使用LLM翻译自中文版本，有人工校对但差错难免，若出现英文或越南文版本内容与中文版本的不一致时，以中文为准。

### 📖 模型简介

该模型是“明康慧医 - 基于LLM与多模态人工智能的健康管理与辅助诊疗系统设计与实现”项目（简称：明康慧医智慧医疗系统）的组成部分，为本人2025级齐鲁工业大学（山东省科学院）计算机科学与技术学部本科毕业设计而开发。项目已开源，地址为：[https://github.com/duyu09/MKTY-System](https://github.com/duyu09/MKTY-System)。

本模型在医学、医疗及生物学领域进行了微调与优化，其表现优于其底座模型`Qwen2.5-3B-Instruct`。微调过程采用LoRA算法，分两步进行，且仅针对中文语言。首先，通过增量训练（Pretrain）阶段，利用医学书籍、病历及医疗相关文章等语料数据进行初步训练。随后，进行指令监督微调（SFT），使用的语料包括症状与对应病历、医患对话（症状描述及诊断）、医学知识问答，以及基于“大模型讨论机制”的对话语料。总数据量约为`2.88GB`。

特别地，模型在“大模型讨论机制”方面进行了优化。该机制的具体运作方式如下：模型在回答每个问题时，会基于不同的上下文生成多个结果，模拟“多人发表观点”的场景。系统还设有“主持人”角色，负责总结各轮讨论的观点。随后，所有参与者根据原始问题、主持人的总结以及各自的上下文，进行下一轮讨论。此过程循环往复，直至讨论结果收敛（语义趋于一致）或达到预设的最大讨论轮数。

### 🔧 硬件条件

若使用GPU推理，则至少需要`7GB`显存。若显存容量不足7GB或无独立显卡，使用`CPU` + `7GB RAM`内存也可以运行MKTY-3B-Chat大模型。

### 🚀 使用示例

基于通义千问`Qwen2.5-3B-Instruct`，可直接通过`transformers`库快速加载启动。

**模型加载**

```python
from transformers import AutoModelForCausalLM, AutoTokenizer

def load_model_and_tokenizer(model_name):
    model = AutoModelForCausalLM.from_pretrained(
        model_name,
        torch_dtype="auto",
        device_map="auto"
    )
    tokenizer = AutoTokenizer.from_pretrained(model_name)
    return model, tokenizer


def generate_response(prompt, messages, model, tokenizer, max_new_tokens=2000):
    messages.append({"role": "user", "content": prompt})
    text = tokenizer.apply_chat_template(
        messages,
        tokenize=False,
        add_generation_prompt=True
    )
    model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
    generated_ids = model.generate(
        **model_inputs,
        max_new_tokens=max_new_tokens
    )
    generated_ids = [
        output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
    ]
    response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
    messages.append({"role": "assistant", "content": response})
    return response
```

**普通问答模式**

```python
if __name__ == "__main__":
    model_name = r"MKTY-3B-Chat"
    messages = []
    model, tokenizer = load_model_and_tokenizer(model_name)
    while True:
        prompt = input("User> ")
        if prompt == "exit":
            break
        response = generate_response(prompt, messages, model, tokenizer)
        print("MKTY>", response)
```

**大模型讨论模式**

```python
if __name__ == "__main__":
    model_name = "MKTY-3B-Chat"
    discuss_rounds = 3
    agent_number = 3
    model, tokenizer = load_model_and_tokenizer(model_name)
    messages_arr = [[] for _ in range(agent_number)]
    while True:
        prompt = input("User> ")
        if prompt == "exit":
            break
        moderator_opinion = "暂无"
        for i in range(discuss_rounds):
            responses_arr = []
            prompt_per_round = "- 问题：\n" + prompt + "\n - 上轮讨论主持人意见：\n" + moderator_opinion + "\n - 请你结合主持人意见，对上述医疗或医学专业的问题发表详细观点，可以质疑并说明理由。\n"
            for j in range(agent_number):
                messages = messages_arr[j]
                response = generate_response(prompt_per_round, messages, model, tokenizer)
                responses_arr.append(response)
                print(f"第{i + 1}轮讨论，LLM {j + 1}观点>\n", response)
                print("-------------------")
            moderator_prompt = "- 问题：\n" + prompt + "\n\n"
            for res_index in range(len(responses_arr)):
                moderator_prompt = moderator_prompt + f"- LLM {res_index + 1}观点：\n" + responses_arr[res_index] + "\n\n"
            moderator_prompt = moderator_prompt + "对于给定的医疗相关问题，请综合各LLM观点，结合自身知识，得出你自己的判断，尽可能详尽，全部都分析到位，还要充分说明理由。\n"
            moderator_opinion = generate_response(moderator_prompt, [], model, tokenizer)
            print(f"第{i + 1}轮讨论，主持人的意见>\n", moderator_opinion)
            print("-------------------")
            clear_history(messages_arr)
    
```

## 🎓 项目作者

```
██\      ██\     ██\   ██\   ████████\  ██\     ██\
███\    ███ |    ██ | ██  |  \__██  __| \██\   ██  |
████\  ████ |    ██ |██  /      ██ |     \██\ ██  /
██\██\██ ██ |    █████  /       ██ |      \████  /
██ \███  ██ |    ██  ██<        ██ |       \██  /
██ |\█  /██ |    ██ |\██\       ██ |        ██ |
██ | \_/ ██ |██\ ██ | \██\ ██\  ██ |██\     ██ |██\
\__|     \__|\__|\__|  \__|\__| \__|\__|    \__|\__|
```

该模型用于2025年齐鲁工业大学（山东省科学院）计算机科学与技术学部毕业设计，仅可进行学术交流，本人及指导老师均不对模型使用造成的任何后果负责。

- 🧑‍💻 项目作者：
  - **杜宇** (英语： _DU Yu_ ；越南语： _Đỗ Vũ_ ；<202103180009@stu.qlu.edu.cn> )，齐鲁工业大学（山东省科学院）计算机科学与技术学部 2025届本科毕业生

- 🏫 毕业设计指导教师：
  - 校方老师：**姜文峰** (英语： _JIANG Wenfeng_ ；越南语： _Khương Văn Phong_ )，齐鲁工业大学（山东省科学院）计算机科学与技术学部 副教授
  - 企业方老师：**李君** (英语： _LI Jun_ ；越南语：_Lý Quân_ )，安博教育科技集团([NYSE: AMBO](https://www.nyse.com/quote/XASE:AMBO)) 山东师创软件实训学院

完整项目开源地址：[https://github.com/duyu09/MKTY-System](https://github.com/duyu09/MKTY-System)，欢迎下载交流。

## 🔗 友情链接

- 齐鲁工业大学（山东省科学院）: [https://www.qlu.edu.cn/](https://www.qlu.edu.cn/)
  
- 山东省计算中心（国家超级计算济南中心）: [https://www.nsccjn.cn/](https://www.nsccjn.cn/)

- 齐鲁工业大学（山东省科学院）计算机科学与技术学部: [http://jsxb.scsc.cn/](http://jsxb.scsc.cn/)

- 杜宇的GitHub主页: [https://github.com/duyu09/](https://github.com/duyu09/)

## 📄 引用

```
@software{du_2025_17444889,
  author       = {Du, Yu},
  title        = {Minh Khoe Tue Y Smart Healthcare System},
  month        = oct,
  year         = 2025,
  publisher    = {Zenodo},
  version      = {v1.1.2},
  doi          = {10.5281/zenodo.17444889},
  url          = {https://github.com/duyu09/MKTY-System},
  swhid        = {swh:1:dir:a633243bf04e6ba18e2d5ffcf92ea57f73566f43
                   ;origin=https://doi.org/10.5281/zenodo.17444888;vi
                   sit=swh:1:snp:37dc91d2c166a07c7dc8ebac0b4be97961b0
                   267b;anchor=swh:1:rel:a88f82a5ca10d278bcc10734f5cf
                   a560286a8b47;path=duyu09-MKTY-System-8edd0c9
                  },
}

```
