# Use\_auth\_token and revision with the class ORTModelFor SequenceClassification?

**URL:** <https://discuss.huggingface.co/t/use-auth-token-and-revision-with-the-class-ortmodelfor-sequenceclassification/19979>\
**Category:** 🤗Optimum\
**Created:** [July 4, 2022, 4:12pm UTC](https://discuss.huggingface.co/t/use-auth-token-and-revision-with-the-class-ortmodelfor-sequenceclassification/19979 "2022-07-04T16:12:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pierreguillou](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pierreguillou/32/19626_2.png) [@pierreguillou](https://discuss.huggingface.co/u/pierreguillou)\
**Post date:** [July 4, 2022, 4:12pm UTC](https://discuss.huggingface.co/t/use-auth-token-and-revision-with-the-class-ortmodelfor-sequenceclassification/19979/1 "2022-07-04T16:12:01Z")

</div>

Hi @echarlaix,

I’m trying to download a private model from the hub through `ORTModelForSequenceClassification` but it gives error messages (but the download works well with `Transformers` as showed at the bottom of the post).

Do you know what is the problem between `ORTModelForSequenceClassification` and `revision` and `use_auth_token`? Thank you.

### error with revision

```auto
# install onnxruntime for optimum
!python -m pip install git+https://github.com/huggingface/optimum.git#egg=optimum[onnxruntime]

# parameters
API_TOKEN = "xxxx" 
model_checkpoint = "orga/xxxx"
revision = 'v1.1'

# Load a model from transformers and export it through the ONNX format
from optimum.onnxruntime import ORTModelForSequenceClassification
model = ORTModelForSequenceClassification.from_pretrained(
model_checkpoint, 
use_auth_token=API_TOKEN, 
revision=revision, 
from_transformers=True)

```

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

### error with use\_auth\_token

```auto
# install onnxruntime for optimum
!python -m pip install git+https://github.com/huggingface/optimum.git#egg=optimum[onnxruntime]

# parameters
API_TOKEN = "xxxx" 
model_checkpoint = "orga/xxxx"
revision = 'v1.1'

# Load a model from transformers and export it through the ONNX format
from optimum.onnxruntime import ORTModelForSequenceClassification
model = ORTModelForSequenceClassification.from_pretrained(
model_checkpoint, 
use_auth_token=API_TOKEN, 
from_transformers=True)

```

 ![pb](https://us1.discourse-cdn.com/hellohellohello/original/2X/c/c43a74325d9cb2559d4f4da6d6a04a8633bf6b22.png)

### without error with the Transformers library

In order to check if the error came from my private model, I did run the following code without error.

```auto
# install transformers
!pip install transformers

# parameters
API_TOKEN = "xxxx" 
model_checkpoint = "orga/xxxx"
revision = 'v1.1'

from transformers import AutoModelForSequenceClassification

model = AutoModelForSequenceClassification.from_pretrained(
model_checkpoint, 
revision=revision, 
use_auth_token=API_TOKEN)

```

---

<div class="post-metadata">

**Author:** ![echarlaix](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/echarlaix/32/21754_2.png) [@echarlaix](https://discuss.huggingface.co/u/echarlaix)\
**Post date:** [July 5, 2022, 8:03am UTC](https://discuss.huggingface.co/t/use-auth-token-and-revision-with-the-class-ortmodelfor-sequenceclassification/19979/2 "2022-07-05T08:03:45Z")

</div>

Hi @pierreguillou,

When `from_transformers=True`, the model will be loaded and exported to the ONNX format using `transformers.onnx`, which doesn’t yet support private models when loading models (currently the model as well as its onnx configuration are loaded using [`FeaturesManager`](https://github.com/huggingface/optimum/blob/main/optimum/onnxruntime/modeling_ort.py#L263)). We plan to enable this feature in the future. In the meantime, a solution you can do is to [export](https://github.com/huggingface/optimum/blob/main/optimum/onnxruntime/modeling_ort.py#L268) your model beforehand, allowing you to set `from_transformers` to `False`.
