Transformers: unable to import from utils_squad

Created on 2 Nov 2019  路  6Comments  路  Source: huggingface/transformers

Hi,
I am using BertForQuestionAnswering on colab and I have installed
!pip install transformers !pip install pytorch-transformers
when I import

from utils_squad import (read_squad_examples, convert_examples_to_features)

I get the following error:

ModuleNotFoundError: No module named 'utils_squad'

any solution to this?
Greetings!

Most helpful comment

try this

```
%%bash
rm -r hugging-face-squad
mkdir hugging-face-squad
echo > hugging-face-squad/__init__.py
cd hugging-face-squad
wget 'https://raw.githubusercontent.com/huggingface/pytorch-transformers/master/examples/run_squad.py'
wget 'https://raw.githubusercontent.com/huggingface/pytorch-transformers/master/examples/utils_squad.py'
wget 'https://raw.githubusercontent.com/huggingface/pytorch-transformers/master/examples/utils_squad_evaluate.py'
sed -i 's/utils_squad_evaluate/.utils_squad_evaluate/g' utils_squad.py
sed -i 's/utils_squad/.utils_squad/g' run_squad.py

import importlib
hfs = importlib.import_module('.run_squad', package='hugging-face-squad')

examples = hfs.read_squad_examples(input_file="train-v2.0.json",
is_training=True,
version_2_with_negative=True)

@manishiitg ...For this also getting errors....utils_squad.py, & utils_squad_evaluate.py, was not found.

All 6 comments

try this

%%bash
rm -r hugging-face-squad
mkdir hugging-face-squad
echo > hugging-face-squad/__init__.py
cd hugging-face-squad
wget 'https://raw.githubusercontent.com/huggingface/pytorch-transformers/master/examples/run_squad.py'
wget 'https://raw.githubusercontent.com/huggingface/pytorch-transformers/master/examples/utils_squad.py'
wget 'https://raw.githubusercontent.com/huggingface/pytorch-transformers/master/examples/utils_squad_evaluate.py'
sed -i 's/utils_squad_evaluate/.utils_squad_evaluate/g' utils_squad.py
sed -i 's/utils_squad/.utils_squad/g' run_squad.py

import importlib
hfs = importlib.import_module('.run_squad', package='hugging-face-squad')

examples = hfs.read_squad_examples(input_file="train-v2.0.json",
                                                is_training=True,
                                                version_2_with_negative=True)



For me, just adding

!wget 'https://raw.githubusercontent.com/huggingface/transformers/master/examples/run_squad.py'
!wget 'https://raw.githubusercontent.com/huggingface/pytorch-transformers/master/examples/utils_squad.py'
!wget 'https://raw.githubusercontent.com/huggingface/pytorch-transformers/master/examples/utils_squad_evaluate.py'

In the same directory as my script worked

try this

```
%%bash
rm -r hugging-face-squad
mkdir hugging-face-squad
echo > hugging-face-squad/__init__.py
cd hugging-face-squad
wget 'https://raw.githubusercontent.com/huggingface/pytorch-transformers/master/examples/run_squad.py'
wget 'https://raw.githubusercontent.com/huggingface/pytorch-transformers/master/examples/utils_squad.py'
wget 'https://raw.githubusercontent.com/huggingface/pytorch-transformers/master/examples/utils_squad_evaluate.py'
sed -i 's/utils_squad_evaluate/.utils_squad_evaluate/g' utils_squad.py
sed -i 's/utils_squad/.utils_squad/g' run_squad.py

import importlib
hfs = importlib.import_module('.run_squad', package='hugging-face-squad')

examples = hfs.read_squad_examples(input_file="train-v2.0.json",
is_training=True,
version_2_with_negative=True)

@manishiitg ...For this also getting errors....utils_squad.py, & utils_squad_evaluate.py, was not found.

Hi, when I was trying to wget the scripts, it says 404 not found... Probably it is been removed somewhere?

!wget 'https://raw.githubusercontent.com/huggingface/transformers/master/examples/run_squad.py'
Proxy request sent, awaiting response... 404 Not Found 2020-05-21 20:18:30 ERROR 404: Not Found.

I believe the code has been refactored a while ago, maybe try the Dec version of transformers, or update your code to get the location of the new data processors

Hi, did you solve the problem ? For me it is the same issue and I just cant find a solution how to get the proper python scripts ? It would be super kind if you could help me :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lcswillems picture lcswillems  路  3Comments

rsanjaykamath picture rsanjaykamath  路  3Comments

0x01h picture 0x01h  路  3Comments

lemonhu picture lemonhu  路  3Comments

fyubang picture fyubang  路  3Comments