medical en arxiv:1910.09700 license:apache-2.0 region:us
---
language:
- en
license: apache-2.0
tags:
- medical
---

# MedLang-13B

<!-- Provide a quick summary of what the model is/does. -->

This modelcard aims to be a base template for new models. It has been generated using [Baichuan-13B](https://huggingface.co/baichuan-inc/Baichuan-13B-Base).

## Model Details

### Model Description

<!-- Provide a longer summary of what this model is. -->



- **Developed by:** Huang chiang
<!-- - **Funded by [optional]:** [More Information Needed]
- **Shared by [optional]:** [More Information Needed] -->
- **Model type:** Medical LLM
- **Language(s) (NLP):** Chinese
<!-- - **License:** [More Information Needed] -->
- **Finetuned from model:** Baichuan-13B

<!-- ### Model Sources:  -->

<!-- Provide the basic links for the model. -->

<!-- - **Repository:** [More Information Needed]
- **Paper [optional]:** [More Information Needed]
- **Demo [optional]:** [More Information Needed] -->

<!-- ## Uses -->

<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->

<!-- ### Direct Use

<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->


<!-- ### Downstream Use [optional] -->

<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->

<!-- [More Information Needed] -->

<!-- ### Out-of-Scope Use -->

<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->

<!-- [More Information Needed] -->

## How to Get Started with the Model

Use the code below to get started with the model.

<div class="relative group repo-copy-code"><pre><code class="language-python">
def init_model():
    model = AutoModelForCausalLM.from_pretrained(
        "EnjoyCodeX/MedLang-13B/MedLang-13B",
        torch_dtype=torch.float16,
        device_map="auto",
        trust_remote_code=True
    )
    model.generation_config = GenerationConfig.from_pretrained(
        "EnjoyCodeX/MedLang-13B/MedLang-13B",
    )
    tokenizer = AutoTokenizer.from_pretrained(
        "EnjoyCodeX/MedLang-13B/MedLang-13B",
        use_fast=False,
        trust_remote_code=True
    )
    return model, tokenizer
</code></pre></div>

<div class="relative group repo-copy-code"><pre><code class="language-python"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.generation.utils <span class="hljs-keyword">import</span> GenerationConfig
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"EnjoyCodeX/MedLang-13B/MedLang-13B"</span>, use_fast=<span class="hljs-literal">False</span>, trust_remote_code=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">"EnjoyCodeX/MedLang-13B/MedLang-13B"</span>, device_map=<span class="hljs-string">"auto"</span>, torch_dtype=torch.float16, trust_remote_code=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.generation_config = GenerationConfig.from_pretrained(<span class="hljs-string">"EnjoyCodeX/MedLang-13B/MedLang-13B"</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>messages = []
<span class="hljs-meta">&gt;&gt;&gt; </span>messages.append({<span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: <span class="hljs-string">"我感觉自己颈椎非常不舒服，每天睡醒都会头痛"</span>})
<span class="hljs-meta">&gt;&gt;&gt; </span>response = model.chat(tokenizer, messages)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(response)
</code></pre></div>

## Training Details

### Training Data

<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->

MedDialog,cMedQA-v2,MedMCQA,DrugDB,Alpaca-GPT4-zh

<!-- ### Training Procedure

<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->

<!-- #### Preprocessing [optional]

[More Information Needed] --> 

<!-- #### Training Hyperparameters -->

<!-- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->

<!-- #### Speeds, Sizes, Times [optional] -->

<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->

<!-- [More Information Needed] -->

## Evaluation

<!-- This section describes the evaluation protocols and provides the results. -->

<!-- ### Testing Data, Factors & Metrics

#### Testing Data

<!-- This should link to a Dataset Card if possible. -->

<!-- [More Information Needed] --> 

MLEC-QA-Few-shot
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6460f814051604bda02b8f11/O4jLFn9DzgdWgtQ9V63aX.png)

MLEC-QA-Zero-shot
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6460f814051604bda02b8f11/0AqpVKlQAyeszfPMCx7Xv.png)

CMB
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6460f814051604bda02b8f11/-RB0wPZYoR99HnUCe8Aii.png)

CMD
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6460f814051604bda02b8f11/6VGxnqmuhuS0XYLwvxEj7.png)

CMID
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6460f814051604bda02b8f11/x0mxfNyP97kLT9RX_7S3w.png)

<!-- #### Factors -->

<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->

<!-- [More Information Needed] -->

<!-- #### Metrics -->

<!-- These are the evaluation metrics being used, ideally with a description of why. -->

<!-- [More Information Needed] -->

<!-- ### Results

[More Information Needed] -->

### Model Architecture
The overall architecture of MedLang-13B is based on the standard Transformer decoder, employing the same model design as LLaMA. <br>
In terms of details, MedLang-13B adopts the following approaches:<br> 
(1) Using RoPE as the positional encoding, which is widely adopted in most models at this stage and exhibits excellent scalability; <br>
(2) Setting the context window length to 4096;<br> 
(3) Utilizing SwiGLU as the activation function, which excels in handling complex semantic relationships and long-dependency issues in language modeling, hence widely used in large language models including MedLang-13B; <br>
(4) Setting the hidden layer size to 11008 in the feedforward network; <br>
(5) Adopting Pre-Normalization based on RMSNorm as layer normalization.<br>

### Recommendations

<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
Although MedLang-13B performs well on both single-turn and multi-turn QA medical datasets, 
the high demands of reliability and safety in the medical field, especially concerning patient health and life, 
render the current MedLang-13B unsuitable for deployment in practical medical applications. 
I solemnly declare that this model is designed solely for the research and testing purposes of individual groups.
Users are strongly advised to critically evaluate any information or medical advice provided by the model.

<!-- #### Summary -->



<!-- ## Model Examination [optional] -->

<!-- Relevant interpretability work for the model goes here -->

<!-- [More Information Needed] -->

<!-- ## Environmental Impact -->

<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->

<!-- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).

- **Hardware Type:** [More Information Needed]
- **Hours used:** [More Information Needed]
- **Cloud Provider:** [More Information Needed]
- **Compute Region:** [More Information Needed]
- **Carbon Emitted:** [More Information Needed] -->

<!-- ## Technical Specifications [optional] -->



<!-- [More Information Needed]
 -->
<!-- ### Compute Infrastructure -->

<!-- [More Information Needed]
 -->
#### GPU
<table style="undefined;table-layout: fixed; width: 442px" class="tg">
<colgroup>
<col style="width: 204.428571px">
<col style="width: 135.428571px">
<col style="width: 102.428571px">
</colgroup>
<thead>
  <tr>
    <th rowspan="2" class="tg-9wq8"><br>Precision</th>
    <th rowspan="2" class="tg-9wq8"><br>GPU Mem (GB)</th>
  </tr>
  <tr>
  </tr>
</thead>
<tbody>
  <tr>
    <td class="tg-9wq8">bf16 / fp16</td>
    <td class="tg-9wq8">26.0</td>
  </tr>
  <tr>
    <td class="tg-9wq8">int8</td>
    <td class="tg-c3ow">15.8</td>
  </tr>
  <tr>
    <td class="tg-9wq8">int4</td>
    <td class="tg-c3ow">9.7</td>
  </tr>
</tbody>
</table>
<!-- [More Information Needed] -->

<!-- #### Software
 -->
<!-- [More Information Needed] -->

<!-- ## Citation [optional] -->

<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
<!-- 
**BibTeX:**

[More Information Needed] -->

<!-- **APA:**

[More Information Needed] -->

<!-- ## Glossary [optional] -->

<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->

<!-- [More Information Needed]

## More Information [optional]

[More Information Needed]

## Model Card Authors [optional]

[More Information Needed] -->

<!-- ## Model Card Contact

[More Information Needed] -->