nielsr HF staff commited on
Commit
6d60e92
1 Parent(s): 5481f4b

Update code example

Browse files
Files changed (1) hide show
  1. README.md +2 -5
README.md CHANGED
@@ -26,11 +26,9 @@ You can use this model for text summarization.
26
  Here is how to use this model with the [pipeline API](https://huggingface.co/transformers/main_classes/pipelines.html):
27
 
28
  ```python
29
- from transformers import BartTokenizer, BartForConditionalGeneration, pipeline
30
 
31
- tokenizer = BartTokenizer.from_pretrained("facebook/bart-large-cnn")
32
- model = BartForConditionalGeneration.from_pretrained("facebook/bart-large-cnn")
33
- summarizer = pipeline("summarization", model=model, tokenizer=tokenizer)
34
 
35
  ARTICLE = """ New York (CNN)When Liana Barrientos was 23 years old, she got married in Westchester County, New York.
36
  A year later, she got married again in Westchester County, but to a different man and without divorcing her first husband.
@@ -50,7 +48,6 @@ Investigation Division. Seven of the men are from so-called "red-flagged" countr
50
  Her eighth husband, Rashid Rajput, was deported in 2006 to his native Pakistan after an investigation by the Joint Terrorism Task Force.
51
  If convicted, Barrientos faces up to four years in prison. Her next court appearance is scheduled for May 18.
52
  """
53
-
54
  print(summarizer(ARTICLE, max_length=130, min_length=30, do_sample=False))
55
  >>> [{'summary_text': 'Liana Barrientos, 39, is charged with two counts of "offering a false instrument for filing in the first degree" In total, she has been married 10 times, with nine of her marriages occurring between 1999 and 2002. She is believed to still be married to four men.'}]
56
  ```
26
  Here is how to use this model with the [pipeline API](https://huggingface.co/transformers/main_classes/pipelines.html):
27
 
28
  ```python
29
+ from transformers import pipeline
30
 
31
+ summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
 
 
32
 
33
  ARTICLE = """ New York (CNN)When Liana Barrientos was 23 years old, she got married in Westchester County, New York.
34
  A year later, she got married again in Westchester County, but to a different man and without divorcing her first husband.
48
  Her eighth husband, Rashid Rajput, was deported in 2006 to his native Pakistan after an investigation by the Joint Terrorism Task Force.
49
  If convicted, Barrientos faces up to four years in prison. Her next court appearance is scheduled for May 18.
50
  """
 
51
  print(summarizer(ARTICLE, max_length=130, min_length=30, do_sample=False))
52
  >>> [{'summary_text': 'Liana Barrientos, 39, is charged with two counts of "offering a false instrument for filing in the first degree" In total, she has been married 10 times, with nine of her marriages occurring between 1999 and 2002. She is believed to still be married to four men.'}]
53
  ```