ailm commited on
Commit
cb3502e
1 Parent(s): fdf7880

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +12 -1
README.md CHANGED
@@ -19,13 +19,24 @@ This model can be used to generate concise summaries of input text, particularly
19
  ### How to Use
20
  You can use this model with the Hugging Face transformers library. Below is an example code snippet:
21
 
 
 
22
  from transformers import PegasusForConditionalGeneration, PegasusTokenizer
23
 
 
24
  model_name = "ailm/pegsus-text-summarization"
25
  model = PegasusForConditionalGeneration.from_pretrained(model_name)
26
  tokenizer = PegasusTokenizer.from_pretrained(model_name)
27
 
 
28
  text = "Your input text here"
 
 
29
  tokens = tokenizer(text, truncation=True, padding="longest", return_tensors="pt")
 
 
30
  summary = model.generate(**tokens)
31
- print(tokenizer.decode(summary[0], skip_special_tokens=True))
 
 
 
 
19
  ### How to Use
20
  You can use this model with the Hugging Face transformers library. Below is an example code snippet:
21
 
22
+ ```bash
23
+
24
  from transformers import PegasusForConditionalGeneration, PegasusTokenizer
25
 
26
+ # Load the pre-trained model and tokenizer
27
  model_name = "ailm/pegsus-text-summarization"
28
  model = PegasusForConditionalGeneration.from_pretrained(model_name)
29
  tokenizer = PegasusTokenizer.from_pretrained(model_name)
30
 
31
+ # Define the input text
32
  text = "Your input text here"
33
+
34
+ # Tokenize the input text
35
  tokens = tokenizer(text, truncation=True, padding="longest", return_tensors="pt")
36
+
37
+ # Generate the summary
38
  summary = model.generate(**tokens)
39
+
40
+ # Decode and print the summary
41
+ print(tokenizer.decode(summary[0], skip_special_tokens=True))
42
+