omidvaramin commited on
Commit
d4cfcef
·
1 Parent(s): 698009f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +68 -165
README.md CHANGED
@@ -4,198 +4,101 @@
4
  {}
5
  ---
6
 
7
- # Model Card for Model ID
8
 
9
  <!-- Provide a quick summary of what the model is/does. -->
10
 
11
- This modelcard aims to be a base template for new models. It has been generated using [this raw template](https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/templates/modelcard_template.md?plain=1).
 
12
 
13
- ## Model Details
 
14
 
15
- ### Model Description
 
16
 
17
- <!-- Provide a longer summary of what this model is. -->
18
 
 
19
 
 
20
 
21
- - **Developed by:** [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
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
 
44
- [More Information Needed]
45
 
46
- ### Downstream Use [optional]
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
 
 
 
 
 
 
49
 
50
- [More Information Needed]
 
51
 
52
- ### Out-of-Scope Use
 
 
 
 
 
 
 
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
 
55
 
56
- [More Information Needed]
 
 
57
 
58
- ## Bias, Risks, and Limitations
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
 
 
 
 
 
 
 
 
 
 
 
61
 
62
- [More Information Needed]
 
 
63
 
64
- ### Recommendations
65
 
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- 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. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
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 Data 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
 
 
 
 
 
 
 
 
 
 
 
201
 
 
4
  {}
5
  ---
6
 
7
+ # Model Card for Hprophetnet-large
8
 
9
  <!-- Provide a quick summary of what the model is/does. -->
10
 
11
+ This model is a fine-tuned version of [bart-large-cnn](https://huggingface.co/facebook/bart-large-cnn) on Newsroom dataset to generate news headlines. To ask model to generate headliens
12
+ "Headline: " should be appended to the beginning of the article.
13
 
14
+ ## Intended uses & limitations
15
+ You can use this model for headline generation task on English news articles.
16
 
17
+ ### Usage
18
+ ```python
19
 
 
20
 
21
+ article = """Two of the OPEC oil cartel’s 11 members, Nigeria and Venezuela, said today that they would voluntarily cut production in response to declining crude oil prices, which have fallen 20 percent from their peak two months ago.
22
 
23
+ The move, which would take less than 200,000 barrels of oil a day off the market, follows days of mixed signals from some OPEC officials, who have voiced increasing concern about the rapid drop in prices. Nigeria’s oil minister, Edmund Daukoru, who is president of OPEC this year, recently said the price of oil was “very low.”
24
 
25
+ Nigeria and Venezuela, which have generally been price hawks within the group, said their decision to cut production grew out of an informal deal reached at OPEC’s last meeting, earlier this month, to pare output if prices fell steeply. Some OPEC representatives have grown anxious at the slide in the oil futures markets, where prices for benchmark contracts have fallen from a midsummer high of $77.03 a barrel.
 
 
 
 
 
26
 
27
+ But traders shrugged off the announcement of the production cuts today. On the New York Mercantile Exchange, the most widely watched contract price — light, low-sulfur crude for delivery next month — traded this afternoon at $62.30 a barrel, down 0.7 percent.
28
 
29
+ Mr. Daukoru has been in contact with other OPEC ministers to discuss prices, which on Monday briefly slipped below $60 a barrel for the first time in six months. But the Organization of the Petroleum Exporting Countries, as the cartel is formally known, denied any shift in policy.
30
 
31
+ “We are not currently concerned,” a delegate from one of OPEC’s Gulf members said. “The prices are currently manageable and fair. We’re not overly alarmed by the prices. It is not a cause for alarm. It’s the market working.”
 
 
32
 
33
+ It is not unusual for oil prices to fall after Labor Day and the conclusion of the summer travel season. Demand tends to slow in the third quarter, and refiners reduce their output for seasonal maintenance; consumption picks up again with the first winter cold in the Western Hemisphere, and prices sometimes do as well.
34
 
35
+ “We are not going to push extra oil in the market or force it down our customers’ throats, we just respond to demand,” the delegate from the Gulf said.
36
 
37
+ Still, contradictory statements from senior OPEC representatives have sown doubt about the oil cartel’s strategy. Whether OPEC countries actually reduce their output or not, the mixed messages have at least succeeded in one way: oil traders have been persuaded that OPEC is willing to step in to defend prices, and have traded on that belief, slowing the recent price decline.
38
 
39
+ “While apparently fanciful, reports of an imminent output cut reflect two hard facts: stocks are building faster than expected, and several producers have an incredibly low pain threshold when it comes to price drops,” Antoine Halff, an energy analyst with Fimat, wrote in a note to clients today. “However, more price declines will likely be needed before OPEC producers decide on any coordinated move.”
40
 
41
+ Venezuela, which pumps about 2.5 million barrels a day, said it would cut its daily output by 50,000 barrels, or about 2 percent, starting Oct. 1. Nigeria said it would trim its exports by 5 percent on the same date, a reduction of about 120,000 barrels a day from its current output of about 3.8 million barrels a day.
42
 
43
+ “They are trying to influence the psychology of the market,” said Larry Goldstein, a veteran oil analyst and the president of the Petroleum Industry Research Foundation in New York. “Although they are reacting to the reduction in demand, they are trying to convince the market that they are actually anticipating it, by making cuts ahead of the market. But they are simply reacting to it, which is how markets should operate.”"""
44
 
45
+ import transformers
46
+ import os
47
+ import torch
48
+ os.environ["CUDA_VISIBLE_DEVICES"]="5"
49
+ from transformers import AutoModelWithLMHead,AutoModelForSeq2SeqLM, DataCollatorForSeq2Seq, Seq2SeqTrainingArguments, Seq2SeqTrainer, AutoTokenizer, AutoModelForSequenceClassification
50
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
51
+ print(device)
52
 
53
+ #appending the task identifier to the beginning of input
54
+ article = "Headline: " + article
55
 
56
+ model = AutoModelForSeq2SeqLM.from_pretrained("omidvaramin/HBART").to(device)
57
+ tokenizer = AutoTokenizer.from_pretrained("omidvaramin/HBART")
58
+ #encodign article using tokenizer
59
+ encoding = tokenizer(article
60
+ , max_length=1024
61
+ , truncation=True
62
+ ,return_tensors="pt"
63
+ ,padding='longest')
64
 
65
+ input_ids = encoding['input_ids']
66
+ attention_masks = encoding['attention_mask']
67
 
68
+ #transfering the data into GPU
69
+ input_ids = input_ids.to(device)
70
+ attention_masks = attention_masks.to(device)
71
 
 
72
 
73
+ #generate headlines using kbeam technique
74
+ beam_outputs = model.generate(
75
+ input_ids = input_ids,
76
+ attention_mask = attention_masks
77
+ ,do_sample = False
78
+ ,num_beams = 4
79
+ ,max_length = 20
80
+ ,min_length = 1
81
+ ,num_return_sequences = 1
82
+ # ,top_k=0
83
+ # ,temperature=0.7
84
+ )
85
 
86
+ result = tokenizer.batch_decode(beam_outputs,
87
+ skip_special_tokens=True)
88
+ print(result[0])
89
 
90
+ ```
91
 
92
+ ### BibTeX entry and citation info
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
+ ```bibtex
95
+ @ARTICLE{10154027,
96
+ author={Omidvar, Amin and An, Aijun},
97
+ journal={IEEE Access},
98
+ title={Learning to Generate Popular Headlines},
99
+ year={2023},
100
+ volume={11},
101
+ number={},
102
+ pages={60904-60914},
103
+ doi={10.1109/ACCESS.2023.3286853}}
104