Value error : Connection error

I am new in this forum and Hugging face models. Could someone help with this:
I want to use model ‘Helsinki-NLP/opus-mt-en-sla’. I am using code from the site:

from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

tokenizer = AutoTokenizer.from_pretrained(“Helsinki-NLP/opus-mt-en-sla”)

model = AutoModelForSeq2SeqLM.from_pretrained(“Helsinki-NLP/opus-mt-en-sla”)

but I get this error: ValueError: Connection error, and we cannot find the requested files in the cached path. Please try again or make sure your Internet connection is on.

I have installed all necessary libraries and my internet connection is good…could someone help with this?

Hello @Katarina, I was able to run your code snippet without any problems on my machine, so I wonder whether there is some firewall / proxy you need to configure on your end?

A simple test that your connection is fine would be to spin up a Google Colab notebook and see if your code works there. Alternatively, you could try upgrading to the latest version of transformers just to be sure it’s not an old bug that got fixed recently.

Hi Lewis, thank you on answer. I checked on Google Colab and there is working fine.
I am traying from Watson Studio, so probably then I have some blockades. Do you maybe know how is possible to incorporate that part - defining a proxy into this code?

1 Like

Hmm I am not familiar with Watson Studio so perhaps you need to do some special login to establish a connection?

If you’re running on a Linux machine, you can edit the no_proxy environment variable in the same shell that you’re running your code from, e.g. bash - Set a network range in the no_proxy environment variable - Unix & Linux Stack Exchange

However, my guess is that you might have more luck getting in touch with the IBM support to help you solve the problem :slight_smile:

Ok, I will try first with no proxy ev…thank you very much! Many regards…:slight_smile:

1 Like

Hi, I just have update on this topic…I found a solution. See code below:
import os

#proxy = ‘http://:@:’
proxy = “https://x.x.xx.x:xxxx”

os.environ[‘http_proxy’] = proxy
os.environ[‘HTTP_PROXY’] = proxy
os.environ[‘https_proxy’] = proxy
os.environ[‘HTTPS_PROXY’] = proxy

1 Like