Mahmoud Amiri
commited on
Commit
·
8039cef
1
Parent(s):
6203a0b
update readme file
Browse files
README.md
CHANGED
@@ -1,3 +1,193 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
library_name: transformers
|
5 |
+
pipeline_tag: summarization
|
6 |
+
license: apache-2.0
|
7 |
+
tags:
|
8 |
+
- chemistry
|
9 |
+
- scientific-summarization
|
10 |
+
- distilbart
|
11 |
+
- abstractive
|
12 |
+
- tldr
|
13 |
+
- knowledge-graphs
|
14 |
+
datasets:
|
15 |
+
- Bocklitz-Lab/lit2vec-tldr-bart-dataset
|
16 |
+
model-index:
|
17 |
+
- name: lit2vec-tldr-bart
|
18 |
+
results:
|
19 |
+
- task:
|
20 |
+
name: Summarization
|
21 |
+
type: summarization
|
22 |
+
dataset:
|
23 |
+
name: Lit2Vec TL;DR Chemistry Dataset
|
24 |
+
type: Bocklitz-Lab/lit2vec-tldr-bart-dataset
|
25 |
+
split: test
|
26 |
+
size: 1001
|
27 |
+
metrics:
|
28 |
+
- type: rouge1
|
29 |
+
value: 56.11
|
30 |
+
- type: rouge2
|
31 |
+
value: 30.78
|
32 |
+
- type: rougeLsum
|
33 |
+
value: 45.43
|
34 |
---
|
35 |
+
|
36 |
+
# lit2vec-tldr-bart (DistilBART fine-tuned for chemistry TL;DRs)
|
37 |
+
|
38 |
+
**lit2vec-tldr-bart** is a DistilBART model fine-tuned on **19,992** CC-BY licensed chemistry abstracts to produce **concise TL;DR-style summaries** aligned with methods → results → significance. It’s designed for scientific **abstractive summarization**, **semantic indexing**, and **knowledge-graph population** in chemistry and related fields.
|
39 |
+
|
40 |
+
- **Base model:** `sshleifer/distilbart-cnn-12-6`
|
41 |
+
- **Training data:** [`Bocklitz-Lab/lit2vec-tldr-bart-dataset`](https://huggingface.co/datasets/Bocklitz-Lab/lit2vec-tldr-bart-dataset)
|
42 |
+
- **Max input length:** 1024 tokens
|
43 |
+
- **Target length:** ~128 tokens
|
44 |
+
|
45 |
+
---
|
46 |
+
|
47 |
+
## 🧪 Evaluation (held-out test)
|
48 |
+
|
49 |
+
| Split | ROUGE-1 | ROUGE-2 | ROUGE-Lsum |
|
50 |
+
|------:|--------:|--------:|-----------:|
|
51 |
+
| Test | **56.11** | **30.78** | **45.43** |
|
52 |
+
|
53 |
+
> Validation RLsum: 46.05
|
54 |
+
> Metrics computed with `evaluate`'s `rouge` (NLTK sentence segmentation, `use_stemmer=True`).
|
55 |
+
|
56 |
+
---
|
57 |
+
|
58 |
+
## 🚀 Quickstart
|
59 |
+
|
60 |
+
```python
|
61 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, GenerationConfig
|
62 |
+
|
63 |
+
repo = "Bocklitz-Lab/lit2vec-tldr-bart"
|
64 |
+
|
65 |
+
tok = AutoTokenizer.from_pretrained(repo)
|
66 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(repo)
|
67 |
+
gen = GenerationConfig.from_pretrained(repo) # loads default decoding params
|
68 |
+
|
69 |
+
text = "Proton exchange membrane fuel cells convert chemical energy into electricity..."
|
70 |
+
inputs = tok(text, return_tensors="pt", truncation=True, max_length=1024)
|
71 |
+
|
72 |
+
summary_ids = model.generate(**inputs, **gen.to_dict())
|
73 |
+
print(tok.decode(summary_ids[0], skip_special_tokens=True))
|
74 |
+
````
|
75 |
+
|
76 |
+
### Batch inference (PyTorch)
|
77 |
+
|
78 |
+
```python
|
79 |
+
texts = [
|
80 |
+
"Abstract 1 ...",
|
81 |
+
"Abstract 2 ...",
|
82 |
+
]
|
83 |
+
batch = tok(texts, return_tensors="pt", padding=True, truncation=True, max_length=1024)
|
84 |
+
out = model.generate(**batch, **gen.to_dict())
|
85 |
+
summaries = tok.batch_decode(out, skip_special_tokens=True)
|
86 |
+
```
|
87 |
+
|
88 |
+
---
|
89 |
+
|
90 |
+
## 🔧 Default decoding (saved in `generation_config.json`)
|
91 |
+
|
92 |
+
These are the defaults saved with the model (you can override at `generate()` time):
|
93 |
+
|
94 |
+
```json
|
95 |
+
{
|
96 |
+
"max_length": 142,
|
97 |
+
"min_length": 56,
|
98 |
+
"early_stopping": true,
|
99 |
+
"num_beams": 4,
|
100 |
+
"length_penalty": 2.0,
|
101 |
+
"no_repeat_ngram_size": 3,
|
102 |
+
"forced_bos_token_id": 0,
|
103 |
+
"forced_eos_token_id": 2
|
104 |
+
}
|
105 |
+
```
|
106 |
+
|
107 |
+
---
|
108 |
+
|
109 |
+
## 📊 Training details
|
110 |
+
|
111 |
+
* **Base:** `sshleifer/distilbart-cnn-12-6` (Distilled BART)
|
112 |
+
* **Data:** 19,992 CC-BY chemistry abstracts with TL;DR summaries
|
113 |
+
* **Splits:** train=17,992 / val=999 / test=1,001
|
114 |
+
* **Max lengths:** input 1024, target 128
|
115 |
+
* **Optimizer:** AdamW, **lr=2e-5**
|
116 |
+
* **Batching:** per-device train/eval batch size 4, **gradient\_accumulation\_steps=4**
|
117 |
+
* **Epochs:** 5
|
118 |
+
* **Precision:** fp16 (when CUDA available)
|
119 |
+
* **Hardware:** single NVIDIA RTX 3090
|
120 |
+
* **Seed:** 42
|
121 |
+
* **Libraries:** 🤗 Transformers + Datasets, `evaluate` for ROUGE, NLTK for sentence splitting
|
122 |
+
|
123 |
+
---
|
124 |
+
|
125 |
+
## ✅ Intended use
|
126 |
+
|
127 |
+
* TL;DR abstractive summaries for **chemistry** and adjacent domains (materials science, chemical engineering, environmental science).
|
128 |
+
* **Semantic indexing**, **IR reranking**, and **knowledge graph** ingestion where concise method/result statements are helpful.
|
129 |
+
|
130 |
+
### Limitations & risks
|
131 |
+
|
132 |
+
* May **hallucinate** details not present in the abstract (typical for abstractive models).
|
133 |
+
* Not a substitute for expert judgment; avoid using summaries as sole evidence for scientific claims.
|
134 |
+
* Trained on CC-BY English abstracts; performance may degrade on other domains/languages.
|
135 |
+
|
136 |
+
---
|
137 |
+
|
138 |
+
## 📦 Files
|
139 |
+
|
140 |
+
This repo should include:
|
141 |
+
|
142 |
+
* `config.json`, `pytorch_model.bin` or `model.safetensors`
|
143 |
+
* `tokenizer.json`, `tokenizer_config.json`, `special_tokens_map.json`, merges/vocab as applicable
|
144 |
+
* `generation_config.json` (decoding defaults)
|
145 |
+
|
146 |
+
---
|
147 |
+
|
148 |
+
## 🔁 Reproducibility
|
149 |
+
|
150 |
+
* Dataset: [`Bocklitz-Lab/lit2vec-tldr-bart-dataset`](https://huggingface.co/datasets/Bocklitz-Lab/lit2vec-tldr-bart-dataset)
|
151 |
+
* Recommended preprocessing: truncate inputs at 1024 tokens; targets at 128.
|
152 |
+
* ROUGE evaluation: `evaluate.load("rouge")`, NLTK sentence tokenization, `use_stemmer=True`.
|
153 |
+
|
154 |
+
---
|
155 |
+
|
156 |
+
## 📚 Citation
|
157 |
+
|
158 |
+
If you use this model or dataset, please cite:
|
159 |
+
|
160 |
+
```bibtex
|
161 |
+
@software{lit2vec_tldr_bart_2025,
|
162 |
+
title = {lit2vec-tldr-bart: DistilBART fine-tuned for chemistry TL;DR summarization},
|
163 |
+
author = {Bocklitz Lab},
|
164 |
+
year = {2025},
|
165 |
+
url = {https://huggingface.co/Bocklitz-Lab/lit2vec-tldr-bart},
|
166 |
+
note = {Model trained on CC-BY chemistry abstracts; dataset at Bocklitz-Lab/lit2vec-tldr-bart-dataset}
|
167 |
+
}
|
168 |
+
```
|
169 |
+
|
170 |
+
Dataset:
|
171 |
+
|
172 |
+
```bibtex
|
173 |
+
@dataset{lit2vec_tldr_dataset_2025,
|
174 |
+
title = {Lit2Vec TL;DR Chemistry Dataset},
|
175 |
+
author = {Bocklitz Lab},
|
176 |
+
year = {2025},
|
177 |
+
url = {https://huggingface.co/datasets/Bocklitz-Lab/lit2vec-tldr-bart-dataset}
|
178 |
+
}
|
179 |
+
```
|
180 |
+
|
181 |
+
---
|
182 |
+
|
183 |
+
## 📝 License
|
184 |
+
|
185 |
+
* **Model weights & code:** Apache-2.0
|
186 |
+
* **Dataset:** CC BY 4.0 (attribution in per-record metadata)
|
187 |
+
|
188 |
+
---
|
189 |
+
|
190 |
+
## 🙌 Acknowledgements
|
191 |
+
|
192 |
+
* Base model: DistilBART (`sshleifer/distilbart-cnn-12-6`)
|
193 |
+
* Licensing and OA links curated from publisher/aggregator sources; dataset restricted to **CC-BY** content.
|