requirements.txt

#2
by Marburps - opened

Trying to run the model in a jupyter notebook, I get an error, most likely depending on the specific versions of some of the imported libraries.
Would it be possible to provide a requirements.txt with the exact versions of all the libraries, so I could create a virtual environment that works with your implementation?

image.png

European Parliament org

Hello Stijn,

Indeed, you need to provide the number of classes, and you can find it in the mlb.pickle file, it's an instance of sklearn.preprocessing.MultiLabelBinarizer

You can be inspired by the handler.py file :

        self.mlb = pickle.load(open(f"{path}/mlb.pickle", "rb"))

        self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
        self.model = EurovocTagger.from_pretrained(path,
                                                   bert_model_name=BERT_MODEL_NAME,
                                                   n_classes=len(self.mlb.classes_),
                                                   map_location=self.device)

Let me know if it fixes your problem,

Sébastien

PS: A new version must be trained and updated very soon.

Yes, very helpful, thx.
It works now, e.g.

[{'label': 'financial market', 'score': 0.3247576057910919}, {'label': 'financial legislation', 'score': 0.22198404371738434}, {'label': 'information technology', 'score': 0.1853564977645874}, {'label': 'consumer protection', 'score': 0.1850746124982834}, {'label': 'digital technology', 'score': 0.18489210307598114}, {'label': 'financial services', 'score': 0.1705697476863861}]

European Parliament org
edited Apr 19

Hi,
I'm trying to run the model locally; I'm getting error with pickle file!


from eurovoc import EurovocTagger
import pickle

mlb = pickle.load(open(f"mlb.pickle", "rb"))
n_classes=len(mlb.classes_)

model = EurovocTagger.from_pretrained("EuropeanParliament/eurovoc_eu",n_classes)

Error

Traceback (most recent call last):
File "/root/eurovoc_eu/run.py", line 4, in
mlb = pickle.load(open(f"mlb.pickle", "rb"))
_pickle.UnpicklingError: invalid load key, 'v'.

European Parliament org

I managed to solve the issue by installing git-lfs to properly download model files.
Now, I'm facing another issue: when I run the test_handler.py for testing, I get:

FileNotFoundError: No such file or directory: "./model.safetensors"

European Parliament org

EUBERT config and model file where missing, I've downloaded them to main directory; and all issues are solved.
Thanks.

Sign up or log in to comment