# Zero shot classification and Onnx

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fzero-shot-classification-and-onnx%2F15007%3E%5C
**Category:** Intermediate\
**Created:** [February 22, 2022, 7:22am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fzero-shot-classification-and-onnx%2F15007 "2022-02-22T07:22:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShieldHero](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/shieldhero/32/4451_2.png) [@ShieldHero](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FShieldHero)%5C
**Post date:** [February 22, 2022, 7:22am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fzero-shot-classification-and-onnx%2F15007%2F1 "2022-02-22T07:22:35Z")

</div>

I want to speed up the inference on zero-shot-classification. I am planning to use `facebook/bart-large-mnli` model. I want to use onnx to speed it up. The official docs all contain examples on some ‘bert’ model and [onnx\_transformers](https://github.com/patil-suraj/onnx_transformers) is not longer upto date.

When i tried to export the model according to this [article](https://huggingface.co/docs/transformers/serialization), I used the following code

```auto
python -m transformers.onnx --model=facebook/bart-large-mnli --features=sequence-classification --atol=1e-4 onnx_zer_shot/

```

Now the problem is in giving the inputs to session.run – when i manually run HF model – without using pipeline, i use the following input

```auto
x = tokenizer.encode(premise, hypothesis, return_tensors='pt', truncation_strategy="only_first")

```

But this is not working for onnx session run – it expects a dictionary with [‘attention\_mask’, ‘input\_ids’] keys – which is the same as the HF model but HF model works with the encoded string anyway.  
NOTE: nli\_model is `nli_model = AutoModelForSequenceClassification.from_pretrained("facebook/bart-large-mnli")`

 ![image](https://us1.discourse-cdn.com/hellohellohello/original/2X/4/46fd5ba4ff2aff809eb9fb96559a0eaba235bf90.png)

Any help is apreciated

---

<div class="post-metadata">

**Author:** ![ShieldHero](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/shieldhero/32/4451_2.png) [@ShieldHero](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FShieldHero)%5C
**Post date:** [February 22, 2022, 7:38am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fzero-shot-classification-and-onnx%2F15007%2F2 "2022-02-22T07:38:31Z")

</div>

@lysandre @joeddav pls help

---

<div class="post-metadata">

**Author:** ![aermak](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@aermak](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Faermak)%5C
**Post date:** [April 27, 2022, 2:55pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fzero-shot-classification-and-onnx%2F15007%2F3 "2022-04-27T14:55:18Z")

</div>

I have same question.
