preliminary clean up of model card from old example
Browse files
README.md
CHANGED
|
@@ -1,37 +1,51 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
library_name: transformers
|
| 3 |
-
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
# Model Card for Model ID
|
| 7 |
|
| 8 |
-
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
## Model Details
|
| 13 |
|
| 14 |
-
### Model Description
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
- **Developed by:** [More Information Needed]
|
| 21 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 22 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
<!-- Provide the basic links for the model. -->
|
| 31 |
|
| 32 |
-
- **Repository:**
|
| 33 |
-
- **Paper [optional]:** [More Information Needed]
|
| 34 |
-
- **Demo [optional]:** [More Information Needed]
|
| 35 |
|
| 36 |
## Uses
|
| 37 |
|
|
@@ -39,161 +53,128 @@ This is the model card of a 🤗 transformers model that has been pushed on the
|
|
| 39 |
|
| 40 |
### Direct Use
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
[More Information Needed]
|
| 45 |
|
| 46 |
-
|
| 47 |
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
-
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
| 53 |
|
| 54 |
-
|
|
|
|
| 55 |
|
| 56 |
-
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
|
|
|
|
| 59 |
|
| 60 |
-
|
| 61 |
|
| 62 |
-
|
| 63 |
|
| 64 |
-
|
|
|
|
|
|
|
| 65 |
|
| 66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 67 |
-
|
| 68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
-
|
| 70 |
-
## How to Get Started with the Model
|
| 71 |
-
|
| 72 |
-
Use the code below to get started with the model.
|
| 73 |
-
|
| 74 |
-
[More Information Needed]
|
| 75 |
|
| 76 |
## Training Details
|
| 77 |
|
| 78 |
-
### Training Data
|
| 79 |
-
|
| 80 |
-
<!-- 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. -->
|
| 81 |
|
| 82 |
-
[
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
### Training Procedure
|
| 85 |
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
#### Preprocessing [optional]
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
|
| 92 |
|
| 93 |
#### Training Hyperparameters
|
| 94 |
|
| 95 |
-
- **
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
-
|
| 98 |
|
| 99 |
-
|
|
|
|
|
|
|
| 100 |
|
| 101 |
-
[
|
| 102 |
|
| 103 |
-
|
| 104 |
|
| 105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
|
| 107 |
### Testing Data, Factors & Metrics
|
| 108 |
|
| 109 |
#### Testing Data
|
| 110 |
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
-
|
| 115 |
-
#### Factors
|
| 116 |
-
|
| 117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
|
| 127 |
### Results
|
| 128 |
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
|
| 139 |
-
|
|
|
|
|
|
|
| 140 |
|
| 141 |
## Environmental Impact
|
| 142 |
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
| 145 |
-
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).
|
| 146 |
|
| 147 |
-
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
|
| 153 |
-
|
| 154 |
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
|
| 163 |
#### Hardware
|
| 164 |
|
| 165 |
-
|
| 166 |
|
| 167 |
#### Software
|
| 168 |
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
-
|
| 173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
-
|
| 175 |
-
**BibTeX:**
|
| 176 |
-
|
| 177 |
-
[More Information Needed]
|
| 178 |
-
|
| 179 |
-
**APA:**
|
| 180 |
-
|
| 181 |
-
[More Information Needed]
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
|
| 195 |
-
|
| 196 |
|
| 197 |
-
## Model Card Contact
|
| 198 |
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
base_model:
|
| 3 |
+
- google/flan-t5-large
|
| 4 |
+
datasets:
|
| 5 |
+
- deepmind/math_dataset
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
library_name: transformers
|
| 9 |
+
metrics:
|
| 10 |
+
- exact_match
|
| 11 |
---
|
| 12 |
|
| 13 |
# Model Card for Model ID
|
| 14 |
|
| 15 |
+
Welcome to the 🤖🧮CyberSolve LinAlg 1.2🧠📐 model card!
|
| 16 |
|
| 17 |
+
We introduce **CyberSolve LinAlg 1.2**, a sequence-to-sequence large language model trained to solve linear equations. Specifically, *CyberSolve LingAlg 1.2* is a downstream version of the *FLAN-T5 large*
|
| 18 |
+
model, [Google/FLAN-T5-large](https://huggingface.co/google/flan-t5-large), fine-tuned on the one-dimensional linear algebra split of the Google DeepMind mathematics dataset.
|
| 19 |
+
The model weights of *CyberSolve LinAlg 1.2* are a further downstream checkpoint from the original *CyberSolve LinAlg 1.1* checkpoint, trained for additional epochs to improve model capability.
|
| 20 |
+
|
| 21 |
+
**Note**: This is currently the most capable version of CyberSolve LinAlg. See this model demoed in the [CyberSolve LinAlg 1.2 🤖 Space](https://huggingface.co/spaces/MarioBarbeque/CyberSolveLingAlg1.2).
|
| 22 |
|
| 23 |
|
| 24 |
## Model Details
|
| 25 |
|
| 26 |
+
### Model Description and Overview
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
To construct **CyberSolve LinAlg 1.2**, the *FLAN-T5 large* model is fined-tuned using a custom PyTorch training loop optimized for multiple GPUs. We supervise a training of *FLAN-T5 large* on the *algebra__linear_1d* split of the [deepmind/math_dataset](https://huggingface.co/datasets/deepmind/math_dataset), an open source
|
| 30 |
+
dateset from Google DeepMind available through the 🤗 hub [deepmind/math_dataset](https://huggingface.co/datasets/deepmind/math_dataset). This large dataset consists of code generating mathematical problems and their solutions to a variety of tasks across unique mathematical disciplines.
|
| 31 |
|
| 32 |
+
In this preliminary family of CyberSolve models, we are specifically interested in understanding the ability of neural models to solve non-trivial mathematical tasks. As such, the CyberSolve **LinAlg 1.x** family of models are trained on a set of 2M simpler, one-dimension linear equations. We preprocessed the data and simulated the training process on a smaller,
|
| 33 |
+
downsampled set of the dataset before training for multiple epochs over the dataset's entirety. This model in particular has been trained for 2 additional epochs, limited only by funds, beyond the original *CyberSolve LinAlg 1.1* checkpoint.
|
| 34 |
|
| 35 |
+
Version 1.2 is the most capable version of CyberSolve LinAlg, scoring a **90.75** exact match score on the evaluation set of 10k linear equations from the DeepMind *algebra__linear_1d* split. This is a non-trivial improvement from the exact match score of **86.56** attained by *CyberSolve LinAlg 1.1*.
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
+
- **Developed by:** John Graham Reynolds
|
| 39 |
+
- **Funded by:** Vanderbilt University
|
| 40 |
+
- **Model type:** Text-to-Text Generation
|
| 41 |
+
- **Language(s) (NLP):** English
|
| 42 |
+
- **Finetuned from model:** "Google/FLAN-T5-large"
|
| 43 |
+
|
| 44 |
+
### Model Source
|
| 45 |
|
| 46 |
<!-- Provide the basic links for the model. -->
|
| 47 |
|
| 48 |
+
- **Repository:** TODO https://github.com/johngrahamreynolds/DistilBERT-DeNiro TODO
|
|
|
|
|
|
|
| 49 |
|
| 50 |
## Uses
|
| 51 |
|
|
|
|
| 53 |
|
| 54 |
### Direct Use
|
| 55 |
|
| 56 |
+
In order to effectively query the model's ability to solve linear equations, a string of the format `Solve <any one-dimensional linear equation>.` should be tokenized and passed to the model's `generate` attribute. An example input string is `input_text = "Solve 24 = 1601*c - 1605*c for c."`.
|
| 57 |
+
The model will attempt to solve the equation, outputting its prediction in a simple numeric format. See the example below.
|
|
|
|
| 58 |
|
| 59 |
+
## How to Use and Query the Model
|
| 60 |
|
| 61 |
+
Use the code below to get started with the model. Reference the Nvidia `apex` package for optimized inference. Users pass a `text` string detailing a sentence with a `[MASK]` token. The model will provide options
|
| 62 |
+
to fill the mask based on the sentence context and its background of knowledge. Note - the DistilBERT base model was trained on a very large general corpus of text.
|
| 63 |
+
In our training, we have fine-tuned the model on the large IMDB movie review dataset. That is, the model is now accustomed to filling `[MASK]` tokens with words related to
|
| 64 |
+
the domain of movies/tv/films. To see the model's afinity for cinematic lingo, it is best to be considerate in one's prompt engineering. Specifically, to most likely generate movie related text,
|
| 65 |
+
one should ideally pass a masked `text` string that could reasonably be found in someone's review of a movie. See the example below:
|
| 66 |
|
| 67 |
+
``` python
|
| 68 |
|
| 69 |
+
# import apex
|
| 70 |
+
import torch
|
| 71 |
+
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
| 72 |
|
| 73 |
+
model = T5ForConditionalGeneration.from_pretrained("MarioBarbeque/CyberSolve-LinAlg-1.2").to("cuda")
|
| 74 |
+
tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-large") # CyberSolve uses the same tokenizer as the base FLAN-T5 model
|
| 75 |
|
| 76 |
+
# Pass the model instruction to solve a linear equation in the following simple format
|
| 77 |
+
input_text = "Solve 24 = 1601*c - 1605*c for c."
|
| 78 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
|
| 79 |
|
| 80 |
+
outputs = model.generate(input_ids)
|
| 81 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 82 |
|
| 83 |
+
```
|
| 84 |
|
| 85 |
+
This code outputs the following:
|
| 86 |
|
| 87 |
+
``` python
|
| 88 |
+
-6
|
| 89 |
+
```
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
## Training Details
|
| 93 |
|
| 94 |
+
### Training Data / Preprocessing
|
|
|
|
|
|
|
| 95 |
|
| 96 |
+
The data used comes from the Stanford NLP 🤗 hub. The model card can be found [here](https://huggingface.co/datasets/stanfordnlp/imdb). This dataset is preprocessed in the
|
| 97 |
+
following way: The train and test splits are tokenized, concatenated, and chunked into chunks of 256 tokens. We subsequently load the training data into a `DataCollator` that
|
| 98 |
+
applies a custom random masking function when batching. We mask of 15% of tokens in each chunk. The evaluation data is masked in its entirety, to remove randomness when evaluating,
|
| 99 |
+
and passed to a `DataCollator` with the default collating function.
|
| 100 |
|
| 101 |
### Training Procedure
|
| 102 |
|
| 103 |
+
The model was trained locally on a single-node with one 16GB Nvidia T4 using 🤗 Transformers, 🤗 Tokenizers, and a custom PyTorch training loop that made use of 🤗 Accelerate.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
|
| 106 |
#### Training Hyperparameters
|
| 107 |
|
| 108 |
+
- **Precision:** We use FP32 precision, as follows immediately from the precision inhereted for the original "DistilBERT/distilbert-base-uncased" model.
|
| 109 |
+
- **Optimizer:** `apex.optimizers.FusedAdam`, a fused kernel version of the AdamW optimizer from Nvidia `apex`
|
| 110 |
+
- **Learning Rate:** We use a linear learing rate scheduler with an initial learning rate of 5e-5
|
| 111 |
+
- **Batch Size:** 32
|
| 112 |
+
- **Number of Training Steps**: 2877 steps over the course of 3 epochs
|
| 113 |
+
|
| 114 |
|
| 115 |
+
## Evaluation / Metrics
|
| 116 |
|
| 117 |
+
We evaluate our masked language model's performance using the `perplexity` metric, which has a few mathematical defitions. We define the perplexity as the exponential of the cross-entropy.
|
| 118 |
+
To remove randomness in our metrics, we premask our evaluation dataset with a single masking function. This ensures we are evaluating with respect to the same set of labels each epoch.
|
| 119 |
+
See the wikipedia links for perplexity and cross-entropy below for more a detailed discussion and various other definitions.
|
| 120 |
|
| 121 |
+
Cross-entropy: [https://en.wikipedia.org/wiki/Cross-entropy](https://en.wikipedia.org/wiki/Cross-entropy)
|
| 122 |
|
| 123 |
+
Perplexity: [https://en.wikipedia.org/wiki/Perplexity](https://en.wikipedia.org/wiki/Perplexity)
|
| 124 |
|
|
|
|
| 125 |
|
| 126 |
### Testing Data, Factors & Metrics
|
| 127 |
|
| 128 |
#### Testing Data
|
| 129 |
|
| 130 |
+
The IMDB dataset from Stanford NLP comes pre-split into training and testing data of 25k reviews each. Our preprocessing, which included the chunking of concatenated, tokenized inputs
|
| 131 |
+
into chunks of 256 tokens, increased these respective splits by approximately ~5k records each. We apply a single masking function to the evaluation dataset before testing as mentioned above.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
### Results
|
| 134 |
|
| 135 |
+
We find the following perplexity metrics over 3 training epochs:
|
|
|
|
|
|
|
|
|
|
| 136 |
|
| 137 |
+
| epoch | perplexity |
|
| 138 |
+
|-------|------------|
|
| 139 |
+
|0 | 17.38 |
|
| 140 |
+
|1 | 16.28 |
|
| 141 |
+
|2 | 15.78 |
|
| 142 |
|
| 143 |
+
#### Summary
|
|
|
|
|
|
|
| 144 |
|
| 145 |
+
We train this model for the purpose of attempting a local training of a masked language model using both the 🤗 ecosystem and a custom PyTorch training and evaluation loop.
|
| 146 |
+
We look forward to further fine-tuning this model on more film/actor/cinema related data in order to further improve the model's knowledge and ability in this domain -
|
| 147 |
+
indeed cinema is one of the author's favorite things.
|
| 148 |
|
| 149 |
## Environmental Impact
|
| 150 |
|
| 151 |
+
- **Hardware Type:** Nvidia Tesla T4 16GB
|
| 152 |
+
- **Hours used:** 1.2
|
| 153 |
+
- **Cloud Provider:** Microsoft Azure
|
| 154 |
+
- **Compute Region:** EastUS
|
| 155 |
+
- **Carbon Emitted:** 0.03 kgCO2
|
| 156 |
|
|
|
|
| 157 |
|
| 158 |
+
Experiments were conducted using Azure in region eastus, which has a carbon efficiency of 0.37 kgCO$_2$eq/kWh. A cumulative of 1.2 hours of computation was performed on hardware of type T4 (TDP of 70W).
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
|
| 160 |
+
Total emissions are estimated to be 0.03 kgCO$_2$eq of which 100 percents were directly offset by the cloud provider.
|
| 161 |
|
| 162 |
+
Estimations were conducted using the MachineLearning Impact calculator presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
#### Hardware
|
| 165 |
|
| 166 |
+
The model was trained locally in an Azure Databricks workspace using a single node with 1 16GB Nvidia T4 GPU for 1.2 GPU Hours.
|
| 167 |
|
| 168 |
#### Software
|
| 169 |
|
| 170 |
+
Training utilized PyTorch, 🤗 Transformers, 🤗 Tokenizers, 🤗 Datasets, 🤗 Accelerate, and more in an Azure Databricks execution environment.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
|
| 172 |
+
#### Citations
|
| 173 |
|
|
|
|
| 174 |
|
| 175 |
+
@article{lacoste2019quantifying,
|
| 176 |
+
title={Quantifying the Carbon Emissions of Machine Learning},
|
| 177 |
+
author={Lacoste, Alexandre and Luccioni, Alexandra and Schmidt, Victor and Dandres, Thomas},
|
| 178 |
+
journal={arXiv preprint arXiv:1910.09700},
|
| 179 |
+
year={2019}
|
| 180 |
+
}
|