Update README.md
Browse files
README.md
CHANGED
@@ -54,18 +54,15 @@ This model is suitable for rapid prototyping and practical applications in autom
|
|
54 |
```python
|
55 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
56 |
|
57 |
-
# Load the tokenizer and the model
|
58 |
tokenizer = AutoTokenizer.from_pretrained("your_username/model_name")
|
59 |
model = AutoModelForSeq2SeqLM.from_pretrained("your_username/model_name")
|
60 |
|
61 |
-
# Example text to summarize
|
62 |
text = "Your long text that needs summarizing."
|
63 |
|
64 |
-
#
|
65 |
input_text = "summarize: " + text
|
66 |
inputs = tokenizer(input_text, return_tensors="pt", max_length=512, truncation=True)
|
67 |
|
68 |
-
# Generate the summary
|
69 |
summary_ids = model.generate(inputs["input_ids"], max_length=150, num_beams=4, early_stopping=True)
|
70 |
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
71 |
|
|
|
54 |
```python
|
55 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
56 |
|
|
|
57 |
tokenizer = AutoTokenizer.from_pretrained("your_username/model_name")
|
58 |
model = AutoModelForSeq2SeqLM.from_pretrained("your_username/model_name")
|
59 |
|
|
|
60 |
text = "Your long text that needs summarizing."
|
61 |
|
62 |
+
# "summarize: " prefix
|
63 |
input_text = "summarize: " + text
|
64 |
inputs = tokenizer(input_text, return_tensors="pt", max_length=512, truncation=True)
|
65 |
|
|
|
66 |
summary_ids = model.generate(inputs["input_ids"], max_length=150, num_beams=4, early_stopping=True)
|
67 |
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
68 |
|