Commit
•
420002c
1
Parent(s):
00f4601
uploaded readme
Browse files
README.md
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Quantization made by Richard Erkhov.
|
2 |
+
|
3 |
+
[Github](https://github.com/RichardErkhov)
|
4 |
+
|
5 |
+
[Discord](https://discord.gg/pvy7H8DZMG)
|
6 |
+
|
7 |
+
[Request more models](https://github.com/RichardErkhov/quant_request)
|
8 |
+
|
9 |
+
|
10 |
+
BART_news_summarizer - bnb 4bits
|
11 |
+
- Model creator: https://huggingface.co/JordiAb/
|
12 |
+
- Original model: https://huggingface.co/JordiAb/BART_news_summarizer/
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
Original model description:
|
18 |
+
---
|
19 |
+
language:
|
20 |
+
- en
|
21 |
+
pipeline_tag: summarization
|
22 |
+
---
|
23 |
+
News articles teacher-student abstractive summarizer model fine-tuned from BART-large and which used `StableBeluga-7B` as teacher.
|
24 |
+
|
25 |
+
DataSet consists of 295,174 news articles scrapped from a Mexican Newspaper, along with its summary. For simplicity, the Spanish news articles were translated to English using `Helsinki-NLP/opus-mt-es-en` NLP model.
|
26 |
+
|
27 |
+
Summaries teacher observations were created using `StableBeluga-7B`. The teacher observations are then used for fine tuning a BART lightweight model.
|
28 |
+
|
29 |
+
The objective for this is to have a lightweight model that can perform summarization as good as `StableBeluga-7B`, much faster and with much less computing resources.
|
30 |
+
|
31 |
+
We achieved very similar summary results (.66 ROUGE1 and .90 cosine similarity) on a validation DataSet with the lightweight BART model, 3x faster predictions and considerably less GPU memory usage.
|
32 |
+
|
33 |
+
How to use:
|
34 |
+
|
35 |
+
|
36 |
+
```python
|
37 |
+
# Load the Model
|
38 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("JordiAb/BART_news_summarizer")
|
39 |
+
tokenizer = AutoTokenizer.from_pretrained("JordiAb/BART_news_summarizer")
|
40 |
+
|
41 |
+
# News article text
|
42 |
+
article_text = """
|
43 |
+
Los Angeles Lakers will have more time than anticipated. The four-time NBA Most Valuable Player (MVP) extended his contract for two years and $85 million, keeping him in California until 2023. In 2018, The King had already signed for 153 mdd and, in his second campaign in the quintet, led the championship in the Orlando bubble. With 35 years of life – he turns 36 on December 30 – and 17 campaigns of experience, LeBron is still considered one of the best (or the best) NBA players. You can read: "Mercedes found Lewis Hamilton\'s substitute" James just took the Lakers to his first NBA title since 2010 and was named MVP of the Finals; he led the League in assists per game (10.2) for the first time in his career, while adding 25.3 points and 7.8 rebounds per performance, during the last campaign. James has adapted to life in Hollywood, as he will be part of the sequel to Space Jam, to be released next year.
|
44 |
+
"""
|
45 |
+
|
46 |
+
# tokenize text
|
47 |
+
inputs = tokenizer(article_text, return_tensors='pt')
|
48 |
+
# generate summary
|
49 |
+
with torch.no_grad():
|
50 |
+
summary_ids = model.generate(
|
51 |
+
inputs['input_ids'],
|
52 |
+
num_beams=4,
|
53 |
+
max_length=250,
|
54 |
+
early_stopping=True
|
55 |
+
)
|
56 |
+
# decode summary
|
57 |
+
summary = tokenizer.decode(
|
58 |
+
summary_ids[0],
|
59 |
+
skip_special_tokens=True
|
60 |
+
)
|
61 |
+
```
|
62 |
+
|