question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

optimum inference for summarization

See original GitHub issue

With reference to the blog: https://huggingface.co/blog/optimum-inference, I am able to do this:

from transformers import AutoTokenizer, pipeline
-from transformers import AutoModelForQuestionAnswering
+from optimum.onnxruntime import ORTModelForQuestionAnswering

-model = AutoModelForQuestionAnswering.from_pretrained("deepset/roberta-base-squad2") # pytorch checkpoint
+model = ORTModelForQuestionAnswering.from_pretrained("optimum/roberta-base-squad2") # onnx checkpoint
tokenizer = AutoTokenizer.from_pretrained("deepset/roberta-base-squad2")

optimum_qa = pipeline("question-answering", model=model, tokenizer=tokenizer)

question = "What's my name?"
context = "My name is Philipp and I live in Nuremberg."
pred = optimum_qa(question, context)

I need to do similar inference for summarization, for the following code:

from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("sshleifer/distilbart-cnn-12-6")
model = AutoModelForSeq2SeqLM.from_pretrained("sshleifer/distilbart-cnn-12-6")

I get the following error:

>>> from optimum.onnxruntime import ORTModelForSeq2SeqLM
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'ORTModelForSeq2SeqLM' from 'optimum.onnxruntime' (/datadrive/shilpa/work/virtual_environments/venv_hf_optimum/lib/python3.9/site-packages/optimum/onnxruntime/__init__.py)

https://huggingface.co/docs/optimum/main/en/pipelines - mentions “text-generation” as one of the supported tasks, “summarization” i assumed comes under this category. Am I right?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
philschmidcommented, May 19, 2022

@Ierezell sorry not yet. I ll try to update this issue if we have a concrete timeline for it.

2reactions
echarlaixcommented, Jun 28, 2022

@ShilpaSangappa @Ierezell the text2text-generation, summarization and translation pipelines are finally supported as we merged #199

Read more comments on GitHub >

github_iconTop Results From Across the Web

Accelerated Inference with Optimum and Transformers Pipelines
Inference has landed in Optimum with support for Hugging Face Transformers pipelines, including text-generation using ONNX Runtime.
Read more >
Text summarization with Amazon SageMaker and Hugging Face
These tools provide you with faster implementation and testing of ML models to achieve your optimal outcomes. From the SageMaker Hugging Face  ......
Read more >
Setting up a Text Summarisation Project - Towards Data Science
The idea is to teach the model what summaries for abstracts of research papers look like by showing it many examples. Over time...
Read more >
Looking Beyond Sentence-Level Natural Language Inference ...
In this work, we use the multiple-choice reading comprehension. (MCRC) and checking factual correctness of textual summarization (CFCS) tasks to ...
Read more >
Inference Summary | Coursera
Inference : Summary ... Probabilistic Graphical Models 2: Inference ... algorithm relative to the optimum answer even if we can't get to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found