Update README.md
Browse files
README.md
CHANGED
@@ -1,207 +1,74 @@
|
|
1 |
---
|
2 |
library_name: peft
|
3 |
-
|
|
|
|
|
|
|
4 |
---
|
5 |
|
6 |
-
|
7 |
|
8 |
-
|
|
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
12 |
-
|
13 |
|
14 |
-
|
15 |
|
16 |
-
|
17 |
|
|
|
|
|
|
|
|
|
18 |
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
26 |
|
27 |
-
|
|
|
|
|
|
|
28 |
|
29 |
-
|
|
|
|
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
-
|
|
|
|
|
|
|
36 |
|
37 |
-
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
|
40 |
|
41 |
-
|
42 |
|
43 |
-
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
48 |
-
|
49 |
-
[More Information Needed]
|
50 |
-
|
51 |
-
### Out-of-Scope Use
|
52 |
-
|
53 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
54 |
-
|
55 |
-
[More Information Needed]
|
56 |
-
|
57 |
-
## Bias, Risks, and Limitations
|
58 |
-
|
59 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
60 |
-
|
61 |
-
[More Information Needed]
|
62 |
-
|
63 |
-
### Recommendations
|
64 |
-
|
65 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
66 |
-
|
67 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
68 |
-
|
69 |
-
## How to Get Started with the Model
|
70 |
-
|
71 |
-
Use the code below to get started with the model.
|
72 |
-
|
73 |
-
[More Information Needed]
|
74 |
-
|
75 |
-
## Training Details
|
76 |
-
|
77 |
-
### Training Data
|
78 |
-
|
79 |
-
<!-- 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. -->
|
80 |
-
|
81 |
-
[More Information Needed]
|
82 |
-
|
83 |
-
### Training Procedure
|
84 |
-
|
85 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
86 |
-
|
87 |
-
#### Preprocessing [optional]
|
88 |
-
|
89 |
-
[More Information Needed]
|
90 |
-
|
91 |
-
|
92 |
-
#### Training Hyperparameters
|
93 |
-
|
94 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
95 |
-
|
96 |
-
#### Speeds, Sizes, Times [optional]
|
97 |
-
|
98 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
99 |
-
|
100 |
-
[More Information Needed]
|
101 |
-
|
102 |
-
## Evaluation
|
103 |
-
|
104 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
105 |
-
|
106 |
-
### Testing Data, Factors & Metrics
|
107 |
-
|
108 |
-
#### Testing Data
|
109 |
-
|
110 |
-
<!-- This should link to a Data Card if possible. -->
|
111 |
-
|
112 |
-
[More Information Needed]
|
113 |
-
|
114 |
-
#### Factors
|
115 |
-
|
116 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
117 |
-
|
118 |
-
[More Information Needed]
|
119 |
-
|
120 |
-
#### Metrics
|
121 |
-
|
122 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
123 |
-
|
124 |
-
[More Information Needed]
|
125 |
-
|
126 |
-
### Results
|
127 |
-
|
128 |
-
[More Information Needed]
|
129 |
-
|
130 |
-
#### Summary
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
## Model Examination [optional]
|
135 |
-
|
136 |
-
<!-- Relevant interpretability work for the model goes here -->
|
137 |
-
|
138 |
-
[More Information Needed]
|
139 |
-
|
140 |
-
## Environmental Impact
|
141 |
-
|
142 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
143 |
-
|
144 |
-
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).
|
145 |
-
|
146 |
-
- **Hardware Type:** [More Information Needed]
|
147 |
-
- **Hours used:** [More Information Needed]
|
148 |
-
- **Cloud Provider:** [More Information Needed]
|
149 |
-
- **Compute Region:** [More Information Needed]
|
150 |
-
- **Carbon Emitted:** [More Information Needed]
|
151 |
-
|
152 |
-
## Technical Specifications [optional]
|
153 |
-
|
154 |
-
### Model Architecture and Objective
|
155 |
-
|
156 |
-
[More Information Needed]
|
157 |
-
|
158 |
-
### Compute Infrastructure
|
159 |
-
|
160 |
-
[More Information Needed]
|
161 |
-
|
162 |
-
#### Hardware
|
163 |
-
|
164 |
-
[More Information Needed]
|
165 |
-
|
166 |
-
#### Software
|
167 |
-
|
168 |
-
[More Information Needed]
|
169 |
-
|
170 |
-
## Citation [optional]
|
171 |
-
|
172 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
173 |
-
|
174 |
-
**BibTeX:**
|
175 |
-
|
176 |
-
[More Information Needed]
|
177 |
-
|
178 |
-
**APA:**
|
179 |
-
|
180 |
-
[More Information Needed]
|
181 |
-
|
182 |
-
## Glossary [optional]
|
183 |
-
|
184 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
185 |
-
|
186 |
-
[More Information Needed]
|
187 |
-
|
188 |
-
## More Information [optional]
|
189 |
-
|
190 |
-
[More Information Needed]
|
191 |
-
|
192 |
-
## Model Card Authors [optional]
|
193 |
-
|
194 |
-
[More Information Needed]
|
195 |
-
|
196 |
-
## Model Card Contact
|
197 |
-
|
198 |
-
[More Information Needed]
|
199 |
-
|
200 |
-
|
201 |
-
## Training procedure
|
202 |
-
|
203 |
-
|
204 |
-
### Framework versions
|
205 |
-
|
206 |
-
|
207 |
-
- PEFT 0.7.0.dev0
|
|
|
1 |
---
|
2 |
library_name: peft
|
3 |
+
license: mit
|
4 |
+
language:
|
5 |
+
- en
|
6 |
+
pipeline_tag: text-generation
|
7 |
---
|
8 |
|
9 |
+
## BioGPT-Large-Natural-Products-RE-Diversity-1000-synt-v1.1
|
10 |
|
11 |
+
Natural products represent a large pool of bioactive compounds of high interest in drug-discovery. However, these relationships are sparsely distributed across organisms and a growing part
|
12 |
+
of the literature remains unannotated. This volume necessitates the development of a machine assistant to boost the completion of existing resources. Framing the task as an
|
13 |
+
end-to-end Relation Extraction (RE), we propose a BioGPT model fined-tuned on synthetic data. See details about this procedure in the join [article](https://arxiv.org/abs/2311.06364).
|
14 |
|
15 |
+
The model is a derived from [microsoft/BioGPT-Large](hhttps://huggingface.co/microsoft/BioGPT-Large) and was trained on a synthetic dataset generated with [Vicuna-13b-v1.5](https://huggingface.co/lmsys/vicuna-13b-v1.5), derived from LLaMA2.
|
16 |
|
17 |
+
The dataset is available on zenodo.
|
18 |
|
19 |
+
Dataset: [](zenodo/url)
|
20 |
|
21 |
+
You can use the model directly as:
|
22 |
|
23 |
+
## Example
|
24 |
|
25 |
+
```python
|
26 |
+
import torch
|
27 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, AutoTokenizer
|
28 |
+
from peft import PeftModel
|
29 |
|
30 |
+
model_hf = "microsoft/BioGPT-Large"
|
31 |
+
lora_adapters = "mdelmas/BioGPT-Large-Natural-Products-RE-Extended-synt-v1.0"
|
32 |
|
33 |
+
# Load model and plug adapters using peft
|
34 |
+
model = AutoModelForCausalLM.from_pretrained(model_hf)
|
35 |
+
model = PeftModel.from_pretrained(model, lora_adapters)
|
36 |
+
model = model.merge_and_unload()
|
37 |
+
tokenizer = AutoTokenizer.from_pretrained(model_hf)
|
|
|
38 |
|
39 |
+
# Example from PubMed article 24048364
|
40 |
+
title_text = "Producers and important dietary sources of ochratoxin A and citrinin."
|
41 |
+
abstract_text = "Ochratoxin A (OTA) is a very important mycotoxin, and its research is focused right now on the new findings of OTA, like being a complete carcinogen, information about OTA producers and new exposure sources of OTA. Citrinin (CIT) is another important mycotoxin, too, and its research turns towards nephrotoxicity. Both additive and synergistic effects have been described in combination with OTA. OTA is produced in foodstuffs by Aspergillus Section Circumdati (Aspergillus ochraceus, A. westerdijkiae, A. steynii) and Aspergillus Section Nigri (Aspergillus carbonarius, A. foetidus, A. lacticoffeatus, A. niger, A. sclerotioniger, A. tubingensis), mostly in subtropical and tropical areas. OTA is produced in foodstuffs by Penicillium verrucosum and P. nordicum, notably in temperate and colder zones. CIT is produced in foodstuffs by Monascus species (Monascus purpureus, M. ruber) and Penicillium species (Penicillium citrinum, P. expansum, P. radicicola, P. verrucosum). OTA was frequently found in foodstuffs of both plant origin (e.g., cereal products, coffee, vegetable, liquorice, raisins, wine) and animal origin (e.g., pork/poultry). CIT was also found in foodstuffs of vegetable origin (e.g., cereals, pomaceous fruits, black olive, roasted nuts, spices), food supplements based on rice fermented with red microfungi Monascus purpureus and in foodstuffs of animal origin (e.g., cheese)."
|
42 |
+
text = title_text + " " + abstract_text
|
43 |
|
44 |
+
# Tokenization
|
45 |
+
input_text = text + tokenizer.eos_token + tokenizer.bos_token
|
46 |
+
input_tokens = tokenizer(input_text, return_tensors='pt')
|
47 |
|
48 |
+
# Decoding parameters
|
49 |
+
EVAL_GENERATION_ARGS = {"max_length": 1024,
|
50 |
+
"do_sample": False,
|
51 |
+
"forced_eos_token_id": tokenizer.eos_token_id,
|
52 |
+
"num_beams": 3,
|
53 |
+
"early_stopping": "never",
|
54 |
+
"length_penalty": 1.5,
|
55 |
+
"temperature": 0}
|
56 |
|
57 |
+
# Generation
|
58 |
+
with torch.no_grad():
|
59 |
+
beam_output = model.generate(**input_tokens, **EVAL_GENERATION_ARGS)
|
60 |
+
output = tokenizer.decode(beam_output[0][len(input_tokens["input_ids"][0]):], skip_special_tokens=True)
|
61 |
|
62 |
+
# Parse and print
|
63 |
+
rels = output.strip().split("; ")
|
64 |
+
for rel in rels:
|
65 |
+
print("- " + rel)
|
66 |
+
```
|
67 |
|
68 |
+
## Citation
|
69 |
|
70 |
+
If you find this model useful, please cite:
|
71 |
|
72 |
+
```latex
|
73 |
|
74 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|