Update README.md
Browse files
README.md
CHANGED
|
@@ -1,202 +1,87 @@
|
|
| 1 |
---
|
| 2 |
base_model: google/flan-t5-large
|
| 3 |
library_name: peft
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
| 9 |
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
### Model
|
| 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 |
-
### Model Sources [optional]
|
| 29 |
-
|
| 30 |
-
<!-- Provide the basic links for the model. -->
|
| 31 |
-
|
| 32 |
-
- **Repository:** [More Information Needed]
|
| 33 |
-
- **Paper [optional]:** [More Information Needed]
|
| 34 |
-
- **Demo [optional]:** [More Information Needed]
|
| 35 |
|
| 36 |
## Uses
|
| 37 |
|
| 38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 39 |
-
|
| 40 |
### Direct Use
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
#### Training Hyperparameters
|
| 94 |
-
|
| 95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
-
|
| 103 |
-
## Evaluation
|
| 104 |
-
|
| 105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 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 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
-
|
| 141 |
-
## Environmental Impact
|
| 142 |
-
|
| 143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 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 |
-
- **Hardware Type:** [More Information Needed]
|
| 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 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 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 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
-
|
| 199 |
-
[More Information Needed]
|
| 200 |
-
### Framework versions
|
| 201 |
-
|
| 202 |
-
- PEFT 0.15.2
|
|
|
|
| 1 |
---
|
| 2 |
base_model: google/flan-t5-large
|
| 3 |
library_name: peft
|
| 4 |
+
tags:
|
| 5 |
+
- text-generation
|
| 6 |
+
- question-answering
|
| 7 |
+
- bias-mitigation
|
| 8 |
+
- flan-t5
|
| 9 |
+
- lora
|
| 10 |
+
- peft
|
| 11 |
+
- disability-rights
|
| 12 |
+
- accessibility
|
| 13 |
+
- social-impact
|
| 14 |
---
|
| 15 |
|
| 16 |
+
# Flan-T5-Large LoRA Adapter for Disability Q&A and Mitigating Disability Biases
|
| 17 |
|
| 18 |
+
## Model Description
|
| 19 |
|
| 20 |
+
This repository contains a LoRA (Low-Rank Adaptation) adapter fine-tuned on the `google/flan-t5-large` base model. The adapter is specifically trained for **improving question-answering capabilities related to disability information and actively reducing harmful biases and stereotypes concerning people with disabilities in generated text.**
|
| 21 |
|
| 22 |
+
This model leverages the PEFT (Parameter-Efficient Fine-Tuning) library to efficiently adapt the large Flan-T5 model to this specialized domain without requiring full model retraining, making it more resource-efficient and deployable.
|
| 23 |
|
| 24 |
+
- **Developed by:** omark807
|
| 25 |
+
- **Finetuned from model:** `google/flan-t5-large`
|
| 26 |
+
- **Model type:** Adapter (LoRA) for Sequence-to-Sequence Language Model
|
| 27 |
+
- **Language(s) (NLP):** English
|
| 28 |
+
- **License:** GPL
|
| 29 |
|
| 30 |
+
### Base Model Details (`google/flan-t5-large`)
|
| 31 |
|
| 32 |
+
Flan-T5 is an instruction-tuned variant of the T5 text-to-text transformer model. It has been fine-tuned on a collection of datasets expressed as natural language instructions. The "large" version has approximately 770 million parameters. This adapter builds upon its strong instruction-following capabilities.
|
| 33 |
|
| 34 |
+
* **Original Model Card:** [https://huggingface.co/google/flan-t5-large](https://huggingface.co/google/flan-t5-large)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
## Uses
|
| 37 |
|
|
|
|
|
|
|
| 38 |
### Direct Use
|
| 39 |
|
| 40 |
+
This adapter is intended to be loaded alongside the `google/flan-t5-large` model using the PEFT library. It can then be used for:
|
| 41 |
+
|
| 42 |
+
* **Answering questions** related to various aspects of disability, accessibility, disability rights, legislation, and common challenges.
|
| 43 |
+
* **Generating responses** that are more inclusive, respectful, and free from common disability biases and stereotypes.
|
| 44 |
+
* **Providing information** in a neutral and empathetic tone when discussing disability-related topics.
|
| 45 |
+
|
| 46 |
+
**Example Inference for Q&A:**
|
| 47 |
+
```python
|
| 48 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
| 49 |
+
from peft import PeftModel, PeftConfig
|
| 50 |
+
import torch
|
| 51 |
+
|
| 52 |
+
# Load the base model
|
| 53 |
+
model_name = "google/flan-t5-large"
|
| 54 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 55 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
| 56 |
+
|
| 57 |
+
# Load your adapter
|
| 58 |
+
# Replace "your-huggingface-username/your-repo-name" with your actual model ID
|
| 59 |
+
adapter_model_id = "[your-huggingface-username]/[your-repo-name]"
|
| 60 |
+
model = PeftModel.from_pretrained(model, adapter_model_id)
|
| 61 |
+
model.eval() # Set model to evaluation mode
|
| 62 |
+
|
| 63 |
+
# Example inference for Q&A
|
| 64 |
+
# Input: "What is the Americans with Disabilities Act (ADA)?"
|
| 65 |
+
# Expected Output: A concise explanation of the ADA.
|
| 66 |
+
input_text_qa = "question: What is the Americans with Disabilities Act (ADA)?"
|
| 67 |
+
input_ids_qa = tokenizer(input_text_qa, return_tensors="pt").input_ids
|
| 68 |
+
|
| 69 |
+
with torch.no_grad():
|
| 70 |
+
outputs_qa = model.generate(input_ids_qa, max_new_tokens=100, num_beams=5, early_stopping=True)
|
| 71 |
+
|
| 72 |
+
decoded_output_qa = tokenizer.decode(outputs_qa[0], skip_special_tokens=True)
|
| 73 |
+
print(f"Input (Q&A): {input_text_qa}")
|
| 74 |
+
print(f"Output (Q&A): {decoded_output_qa}")
|
| 75 |
+
|
| 76 |
+
# Example inference for Bias Mitigation/Instruction Following
|
| 77 |
+
# Input: "Rewrite the following sentence to remove any ableist language: 'He was confined to a wheelchair.'"
|
| 78 |
+
# Expected Output: "He used a wheelchair." or similar respectful phrasing.
|
| 79 |
+
input_text_bias = "instruction: Rewrite the following sentence to remove any ableist language: 'He was confined to a wheelchair.'"
|
| 80 |
+
input_ids_bias = tokenizer(input_text_bias, return_tensors="pt").input_ids
|
| 81 |
+
|
| 82 |
+
with torch.no_grad():
|
| 83 |
+
outputs_bias = model.generate(input_ids_bias, max_new_tokens=50, num_beams=5, early_stopping=True)
|
| 84 |
+
|
| 85 |
+
decoded_output_bias = tokenizer.decode(outputs_bias[0], skip_special_tokens=True)
|
| 86 |
+
print(f"Input (Bias Mitigation): {input_text_bias}")
|
| 87 |
+
print(f"Output (Bias Mitigation): {decoded_output_bias}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|