# Export bigbird model to onnx

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fexport-bigbird-model-to-onnx%2F17080%3E%5C
**Category:** Beginners\
**Created:** [April 22, 2022, 8:31am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fexport-bigbird-model-to-onnx%2F17080 "2022-04-22T08:31:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sypark](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@sypark](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsypark)%5C
**Post date:** [April 22, 2022, 8:31am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fexport-bigbird-model-to-onnx%2F17080%2F1 "2022-04-22T08:31:17Z")

</div>

When I tried to export bigbird model to onnx using the script below,

```auto
class BigBirdForMaskedLMOnnxConfig(OnnxConfig):
    @property
    def inputs(self) -> Mapping[str, Mapping[int, str]]:
        return OrderedDict(
            [
                ("input_ids", {0: "batch", 1: "sequence"}),
                ("attention_mask", {0: "batch", 1: "sequence"}),
            ]
        )

config = AutoConfig.from_pretrained("./model_save_point")
onnx_config = BigBirdForMaskedLMOnnxConfig(config, task="masked-lm")
onnx_path = Path("./model_save_point/model.onnx")
model_ckpt = "./model_save_point"
base_model = BigBirdForMaskedLM.from_pretrained(model_ckpt)
tokenizer = BigBirdTokenizerFast.from_pretrained(model_ckpt)
onnx_inputs, onnx_outputs = export(tokenizer, base_model, onnx_config, onnx_config.default_onnx_opset, onnx_path)

```

I got the following warning.

/home/sypark/anaconda3/lib/python3.8/site-packages/transformers/models/big\_bird/modeling\_big\_bird.py:2063: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can’t record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!  
if self.attention\_type == “block\_sparse” and seq\_length \<= max\_tokens\_to\_attend:  
Attention type ‘block\_sparse’ is not possible if sequence\_length: 8 \<= num global tokens: 2 \* config.block\_size + min. num sliding tokens: 3 \* config.block\_size + config.num\_random\_blocks \* config.block\_size + additional buffer: config.num\_random\_blocks \* config.block\_size = 704 with config.block\_size = 64, config.num\_random\_blocks = 3. Changing attention type to ‘original\_full’…

Also, the output values were quite different from those of the pytorch model.

How can I solve this problem ?

Thanks in advance for your help.
