sample code update
Browse files
README.md
CHANGED
@@ -60,6 +60,7 @@ model_id = "Rahmat82/t5-small-finetuned-summarization-xsum"
|
|
60 |
|
61 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
|
62 |
tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=True)
|
|
|
63 |
|
64 |
text_to_summarize = """
|
65 |
The koala is regarded as the epitome of cuddliness. However, animal lovers
|
@@ -73,8 +74,8 @@ within a decade. That is a shockingly fast decline." He added that koalas risk
|
|
73 |
"sliding toward extinction"
|
74 |
"""
|
75 |
|
76 |
-
|
77 |
-
print(
|
78 |
```
|
79 |
### Use model with optimum/onnxruntime - super fast:
|
80 |
```python
|
@@ -89,7 +90,8 @@ model_name = "Rahmat82/t5-small-finetuned-summarization-xsum"
|
|
89 |
|
90 |
model = ORTModelForSeq2SeqLM.from_pretrained(model_name, export=True)
|
91 |
tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=True)
|
92 |
-
summarizer = pipeline("summarization", model=model,
|
|
|
93 |
|
94 |
text_to_summarize = """
|
95 |
The koala is regarded as the epitome of cuddliness. However, animal lovers
|
|
|
60 |
|
61 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
|
62 |
tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=True)
|
63 |
+
summarizer = pipeline("summarization",model = model, tokenizer=tokenizer)
|
64 |
|
65 |
text_to_summarize = """
|
66 |
The koala is regarded as the epitome of cuddliness. However, animal lovers
|
|
|
74 |
"sliding toward extinction"
|
75 |
"""
|
76 |
|
77 |
+
|
78 |
+
print(summarizer(text_to_summarize)[0]["summary_text"])
|
79 |
```
|
80 |
### Use model with optimum/onnxruntime - super fast:
|
81 |
```python
|
|
|
90 |
|
91 |
model = ORTModelForSeq2SeqLM.from_pretrained(model_name, export=True)
|
92 |
tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=True)
|
93 |
+
summarizer = pipeline("summarization", model=model, tokenizer=tokenizer,
|
94 |
+
device_map="auto", batch_size=12)
|
95 |
|
96 |
text_to_summarize = """
|
97 |
The koala is regarded as the epitome of cuddliness. However, animal lovers
|