MultiFiT_module importing

Hello everyone,

I tried to import “multifit” module as it says in the description here - https://github.com/n-waves/multifit. I want to use pretrained models that were released for 7 languages. But when I tried to import multifit I’ve got an error:
ModuleNotFoundError: No module named 'multifit’

Does anybody know how to import this module and use non-English pre-trained models?

Hi Aleksei!

Have you cloned the repository and installed it properly?
Once installed in your virtual environment you should not have problems to import multifit.

I am working with this repository now, so if you have any questions you can mention me, @Saioa.

Hi Saioa,

Thank you very much for your response.
Yes, I cloned the repository, then installed the dependencies mentioned in “requirements.txt”.
Did I miss something? :flushed:

Saioa,

I’ve got it, I made a mistake when importing it.
Thank you very much!!! It’s working now! :hugs: :hugs: :hugs:

1 Like

@Saioa, sorry for bothering you again, I’ve just realized that the module is imported, but ‘from_pretrained’ function can’t be found. It looks like the module ‘multifit’ is empty. I think it doesn’t ‘see’ my source folder.
Can you tell me please how did you install it? :grimacing:

I work in Google Colab, maybe that is why it has some problems.

I have not used much Google Colab, but I will try to help you. These are the steps that I follow:

  1. Clone the repository:
    ! git clone https://github.com/n-waves/multifit.git

  2. Install multifit:
    ! pip install multifit/

  3. Install multifit dependencies:
    ! pip install -r multifit/requirements.txt

I think it is important to follow this order, because it happened to me that if I installed the dependencies first and then multifit, it did not install well. Maybe it’s what’s happening to you.

I hope this solves your problem :slight_smile:

4 Likes

Saioa, yes, it’s working perfectly now!!
Cool, thank you very much! :hugs:

1 Like

import fire
import urllib.request
from pathlib import Path

lang_codes = [‘fr’, ‘ja’, ‘en’, ‘de’]

lang_codes = [ ‘de’]

Want to download german books & music train&test.csv from below code, Could you please share command to run this (i mean input args for url_prefix), it will be helpful

def fetch_cls(url_prefix, cls_path=“data/cls”):
“”" Fetch CLS from server using basic auth
url_prefix should point to CLS stored as follow
https://user:passwd@server/path/[en|fr|de|jp]/[dvd|music|books].[test|train|unlabeled].csv”
data/cls/de-music/models/sp15k
“”"
def fetch(url, CLS):
CLS.parent.mkdir(parents=True, exist_ok=True)
print(“fetching”, url, CLS)
urllib.request.urlretrieve(url, CLS)
for code in lang_codes:
for category in [ ‘music’]:
dir = Path(cls_path)/f’{code}-{category}’
fetch(f"{url_prefix}/{code}/{category}/train.csv", dir / f"{code}.train.csv")
fetch(f"{url_prefix}/{code}/{category}/test.csv", dir / f"{code}.test.csv")
fetch(f"{url_prefix}/{code}/{category}/unlabeled.csv", dir / f"{code}.unsup.csv")