omidvaramin
commited on
Commit
•
40e95fb
1
Parent(s):
b988c16
Update README.md
Browse files
README.md
CHANGED
@@ -14,6 +14,75 @@ This model is a fine-tuned version of [prophetnet-large-uncased-cnndm](https://h
|
|
14 |
## Intended uses & limitations
|
15 |
You can use this model for headline generation task on English news articles.
|
16 |
|
|
|
|
|
|
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
|
|
|
14 |
## Intended uses & limitations
|
15 |
You can use this model for headline generation task on English news articles.
|
16 |
|
17 |
+
### Usage
|
18 |
+
```
|
19 |
+
article = """Two of the OPEC oil cartels 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.
|
20 |
|
21 |
+
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. Nigerias oil minister, Edmund Daukoru, who is president of OPEC this year, recently said the price of oil was very low.
|
22 |
+
|
23 |
+
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 OPECs 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.
|
24 |
+
|
25 |
+
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.
|
26 |
+
|
27 |
+
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.
|
28 |
+
|
29 |
+
We are not currently concerned, a delegate from one of OPECs Gulf members said. The prices are currently manageable and fair. Were not overly alarmed by the prices. It is not a cause for alarm. Its the market working.
|
30 |
+
|
31 |
+
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.
|
32 |
+
|
33 |
+
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.
|
34 |
+
|
35 |
+
Still, contradictory statements from senior OPEC representatives have sown doubt about the oil cartels 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.
|
36 |
+
|
37 |
+
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.
|
38 |
+
|
39 |
+
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.
|
40 |
+
|
41 |
+
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."""
|
42 |
+
|
43 |
+
import transformers
|
44 |
+
import os
|
45 |
+
import torch
|
46 |
+
os.environ["CUDA_VISIBLE_DEVICES"]="5"
|
47 |
+
from transformers import AutoModelWithLMHead,AutoModelForSeq2SeqLM, DataCollatorForSeq2Seq, Seq2SeqTrainingArguments, Seq2SeqTrainer, AutoTokenizer, AutoModelForSequenceClassification
|
48 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
49 |
+
print(device)
|
50 |
+
|
51 |
+
|
52 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("omidvaramin/Hprophetnet-large").to(device)
|
53 |
+
tokenizer = AutoTokenizer.from_pretrained("omidvaramin/Hprophetnet-large")
|
54 |
+
#encodign article using tokenizer
|
55 |
+
encoding = tokenizer(article
|
56 |
+
, max_length=1024
|
57 |
+
, truncation=True
|
58 |
+
,return_tensors="pt"
|
59 |
+
,padding='longest')
|
60 |
+
|
61 |
+
input_ids = encoding['input_ids']
|
62 |
+
attention_masks = encoding['attention_mask']
|
63 |
+
|
64 |
+
#transfering the data into GPU
|
65 |
+
input_ids = input_ids.to(device)
|
66 |
+
attention_masks = attention_masks.to(device)
|
67 |
+
|
68 |
+
|
69 |
+
#generate headlines using kbeam technique
|
70 |
+
beam_outputs = model.generate(
|
71 |
+
input_ids = input_ids,
|
72 |
+
attention_mask = attention_masks
|
73 |
+
,do_sample = False
|
74 |
+
,num_beams = 4
|
75 |
+
,max_length = 20
|
76 |
+
,min_length = 1
|
77 |
+
,num_return_sequences = 1
|
78 |
+
# ,top_k=0
|
79 |
+
# ,temperature=0.7
|
80 |
+
)
|
81 |
+
|
82 |
+
result = tokenizer.batch_decode(beam_outputs,
|
83 |
+
skip_special_tokens=True)
|
84 |
+
print(result[0])
|
85 |
+
|
86 |
+
```
|
87 |
|
88 |
|