Views
No views yet
1from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
2
3model = AutoModelForSeq2SeqLM.from_pretrained("PreshaJoon/flan-t5-finetuned-summarization")
4tokenizer = AutoTokenizer.from_pretrained("PrekshaJoon/flan-t5-finetuned-summarization")
5
6def generate_summary(article):
7 inputs = tokenizer("summarize: " + article, return_tensors="pt", max_length=512, truncation=True)
8 summary_ids = model.generate(inputs["input_ids"], max_length=128, num_beams=4, early_stopping=True)
9 summary = tokenizer.decode(summary_ids, skip_special_tokens=True)
10 return summary
11
12## Deploy and use the model
13
14from transformers import pipeline
15
16summarizer = pipeline("summarization", model="PrekshaJoon/flan-t5-finetuned-summarization")
17
18article = "Write your article here..."
19summary = summarizer(article, max_length=128, min_length=30, length_penalty=2.0, num_beams=4, early_stopping=True)
20
21print(summary[0]['summary_text'])
22
23### Direct Use
24
25article = "Your long article text here..."
26summary = generate_summary(article)
27print(summary)
28
29
30
31## Bias, Risks, and Limitations
32
33<!-- This section is meant to convey both technical and sociotechnical limitations. -->
34
35[More Information Needed]
36
37## How to Get Started with the Model
38
39Use the code below to get started with the model.
40
41[More Information Needed]
42
43### Training Data
44
45<!-- 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. -->
46
47[More Information Needed]
48
49### Training Procedure
50
51The training process involved:
52
531. Loading the pre-trained FLAN-T5 model
542. Preprocessing the CNN/DailyMail dataset
553. Fine-tuning the model using the Seq2SeqTrainer from Hugging Face's
56
57#### Preprocessing
58Preprocess the dataset by tokenizing it and preparing it for the FLAN-T5 model.
59
60
61#### Training Hyperparameters
62
63- **Training regime:** fp16 mixed precision
64
65### Testing Data, Factors & Metrics
66
67#### Testing Data
68
69<!-- This should link to a Dataset Card if possible. -->
70
71[More Information Needed]
72
73
74#### Metrics
75
76Use of rogue-score matric for evaluation
77
78### EvaluationResults
79
80The model was evaluated using ROUGE scores. Here are the results on the validation set:
81
82rouge1: 0.3913
83rouge2: 0.2889
84rougeL: 0.3696
85rougeLsum: 0.3696
86
87## Environmental Impact
88
89<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
90
91Carbon 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).
92
93- **Hardware Type:** A100 GPU
94- **Hours used:** 7
95- **Cloud Provider:** Google
96- **Compute Region:** [More Information Needed]
97
98
99## Technical Specifications [optional]
100
101### Model Architecture and Objective
102
103[More Information Needed]
104
105### Compute Infrastructure
106
107[More Information Needed]
108
109
110## Glossary [optional]
111
112<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
113
114[More Information Needed]
115
116
117## Model Card Contact
118Preksha.Joon@smu.ca