J38 commited on
Commit
0a0cf47
2 Parent(s): 9ccd482 a3e5fb6

Merge branch 'main' of https://huggingface.co/stanford-crfm/pubmedgpt into main

Browse files
Files changed (1) hide show
  1. README.md +144 -0
README.md ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: openrail
3
+ ---
4
+
5
+ # Model Card for Pubmed GPT 2.7B
6
+
7
+ PubMed GPT 2.7B is new language model trained exclusively on biomedical abstracts and papers from [The Pile](https://pile.eleuther.ai/). This GPT-style model can achieve strong results on a variety of biomedical NLP tasks, including a new state of the art performance of 50.3% accuracy on the MedQA biomedical question answering task.
8
+
9
+ As an autoregressive language model, PubMed GPT 2.7B is also capable of natural language generation. However, we have only begun to explore the generation capabilities and limitations of this model, and we emphasize that this model’s generation capabilities are for research purposes only and not suitable for production. In releasing this model, we hope to advance both the development of biomedical NLP applications and best practices for responsibly training and utilizing domain-specific language models; issues of reliability, truthfulness, and explainability are top of mind for us.
10
+
11
+ This model was a joint collaboration of [Stanford CRFM](https://crfm.stanford.edu/) and [MosaicML](https://www.mosaicml.com/).
12
+
13
+ # Table of Contents
14
+
15
+ - [Model Card for Pubmed GPT 2.7B](#model-card-for--model_id-)
16
+ - [Table of Contents](#table-of-contents)
17
+ - [Model Details](#model-details)
18
+ - [Model Description](#model-description)
19
+ - [Uses](#uses)
20
+ - [Downstream Use](#downstream-use)
21
+ - [Out-of-Scope Use](#out-of-scope-use)
22
+ - [Bias, Risks, and Limitations](#bias-risks-and-limitations)
23
+ - [Recommendations](#recommendations)
24
+ - [Training Details](#training-details)
25
+ - [Training Data](#training-data)
26
+ - [Training Procedure](#training-procedure)
27
+ - [Preprocessing](#preprocessing)
28
+ - [Environmental Impact](#environmental-impact)
29
+ - [Technical Specifications](#technical-specifications)
30
+ - [Model Architecture and Objective](#model-architecture-and-objective)
31
+ - [Compute Infrastructure](#compute-infrastructure)
32
+
33
+ # Model Details
34
+
35
+ ## Model Description
36
+
37
+ <!-- Provide a longer summary of what this model is/does. -->
38
+ PubMed GPT 2.7B is new language model trained exclusively on biomedical abstracts and papers from [The Pile](https://pile.eleuther.ai/). This GPT-style model can achieve strong results on a variety of biomedical NLP tasks, including a new state of the art performance of 50.3% accuracy on the MedQA biomedical question answering task.
39
+
40
+ As an autoregressive language model, PubMed GPT 2.7B is also capable of natural language generation. However, we have only begun to explore the generation capabilities and limitations of this model, and we emphasize that this model’s generation capabilities are for research purposes only and not suitable for production. In releasing this model, we hope to advance both the development of biomedical NLP applications and best practices for responsibly training and utilizing domain-specific language models; issues of reliability, truthfulness, and explainability are top of mind for us.
41
+
42
+ This model was a joint collaboration of [Stanford CRFM](https://crfm.stanford.edu/) and [MosaicML](https://www.mosaicml.com/).
43
+
44
+
45
+ - **Developed by:** Stanford CRFM, MosaicML
46
+ - **Shared by:** Stanford CRFM
47
+ - **Model type:** Language model
48
+ - **Language(s) (NLP):** en
49
+ - **License:** openrail
50
+
51
+ # Uses
52
+
53
+ ## Direct Use
54
+
55
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
56
+ <!-- If the user enters content, print that. If not, but they enter a task in the list, use that. If neither, say "more info needed." -->
57
+ It is possible to use this model to generate text, which is useful for experimentation and understanding its capabilities. It should not be directly used for production or work that may directly impact people.
58
+
59
+ ## Downstream Use
60
+
61
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
62
+ The main way we have used this model is finetuning for downstream question answering tasks, and we recommend using this model that way.
63
+
64
+ ## Out-of-Scope Use
65
+
66
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
67
+ We do not recommend using this model for natural language generation in a production environment, finetuned or otherwise.
68
+
69
+ # Bias, Risks, and Limitations
70
+
71
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
72
+ Significant research has explored bias and fairness issues with language models (see, e.g., [Sheng et al. (2021)](https://aclanthology.org/2021.acl-long.330.pdf) and [Bender et al. (2021)](https://dl.acm.org/doi/pdf/10.1145/3442188.3445922)). Predictions generated by the model may include disturbing and harmful stereotypes across protected classes; identity characteristics; and sensitive, social, and occupational groups.
73
+
74
+ ## Recommendations
75
+
76
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
77
+ While this model is capable of generating natural language text, we have only begun to explore this capability and its limitations. Understanding these limitations is especially important in a domain like medicine. Therefore, **we strongly recommend against using this model in production for natural language generation.**
78
+
79
+ # Training Details
80
+
81
+ ## Training Data
82
+
83
+ <!-- This should link to a Data 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. -->
84
+
85
+ This model was trained on the Pubmed Abstracts and Full Text from [The Pile](https://pile.eleuther.ai/).
86
+
87
+ ## Training Procedure
88
+
89
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
90
+
91
+ The model was trained on [MosaicML Cloud](https://www.mosaicml.com/cloud), a platform designed for large workloads like LLMs. Using the [Composer](https://github.com/mosaicml/composer) training library and [PyTorch FSDP](https://pytorch.org/docs/stable/fsdp.html), it was easy to enable multi-node training across 128 A100-40GB GPUs, and the total run was completed in ~6.25 days. The model was trained with batch size=1024 and sequence length=1024 for 300B tokens using Decoupled AdamW with the following settings:
92
+
93
+ | | |
94
+ | --- | ------ |
95
+ | lr | 1.6e-4 |
96
+ | eps | 1e-8 |
97
+ | betas | \[0.9, 0.95\] |
98
+ | weight decay | 1.6e-5 |
99
+
100
+ The training process was very smooth and did not suffer from any divergences.
101
+
102
+ As we were preparing the training run, we were unsure of the benefits of training out to 300B tokens for language model perplexity and downstream task performance. While most models of this scale (e.g. GPT Neo 2.7B) are trained to 300-400B tokens, the datasets those models use are vastly larger than PubMed. For instance, The Pile is 8x the size of its PubMed subcorpora.
103
+
104
+ Fortunately, we did continue to see steady perplexity improvements on the validation and training sets for the entirety of training, and preliminary experiments showed improved downstream task performance as we trained out to the full 300B tokens. Our takeaway from this was that it was indeed worth it to train for the full 300B tokens, even though this represented dramatically more passes through the data than comparable models.
105
+
106
+ ### Preprocessing
107
+
108
+ The model uses a custom tokenizer trained on the PubMed Abstracts. When building domain specific models we have found it important to use a tokenizer trained on in-domain text to maximize performance on downstream tasks. A key benefit is that common biomedical terms are represented as entire tokens.
109
+
110
+ For instance, all of these following terms are tokenized into single tokens by the biomedical tokenizer and multiple tokens by the standard GPT-2 tokenizer:
111
+
112
+ | | |
113
+ | --- | --- |
114
+ | chromatography | chrom/atography |
115
+ | cytotoxicity | cyt/ot/oxicity |
116
+ | Immunohistochemistry | Immun/oh/ist/ochemistry |
117
+ | photosynthesis | photos/ynthesis |
118
+ | probiotic | prob/iotic |
119
+
120
+ This allows the model to encode information about these concepts in their individual token representations rather than spread out across subword tokens like “oh” shared with many other terms.
121
+
122
+ # Environmental Impact
123
+
124
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
125
+
126
+ 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).
127
+
128
+ # Technical Specifications
129
+
130
+ ## Model Architecture and Objective
131
+
132
+ Pubmed GPT 2.7B is a standard GPT-2 implementation (trained with Flash Attention) with the following hyperparameters:
133
+
134
+ | | |
135
+ | ----------- | ----- |
136
+ | hidden size | 2560 |
137
+ | heads | 20 |
138
+ | layers | 32 |
139
+ | vocab size | 28896 |
140
+ | sequence length| 1024 |
141
+
142
+ ## Compute Infrastructure
143
+
144
+ The model was trained on [MosaicML Cloud](https://www.mosaicml.com/cloud), a platform designed for large workloads like LLMs. Using the [Composer](https://github.com/mosaicml/composer) training library and [PyTorch FSDP](https://pytorch.org/docs/stable/fsdp.html), it was easy to enable multi-node training across 128 A100-40GB GPUs, and the total run was completed in ~6.25 days.