Multilingual ULMFiT


Hi, thanks for the response.
I tried langdetect but as my dataset consists from descriptions which are not very long, it found ‘wrong’ languages with very high probability.
So having the fact that I cant detect language, I am thinking of training a new model from scratch based on French and English wiki and would like to get an advise.


(Piotr Czapla) #89

you would have to fill all the hyper params then. It is easier to train the LM with LMHyperParams then load it using CLSHyperParams.from_lm(dataset_path, base_lm_path). So in your case:

exp = LMHyperParams(dataset_path='data/wiki/ru-100/', qrnn=False, tokenizer='v', lang='ru', name='russian')
exp = CLSHyperParams.from_lm('data/my_class_task_data', 'data/wiki/ru-100/models/v70k/lstm_russian.m', name='russian') # get the exact name of your model from execution of LMHyperParams

This part isn’t ready yet you would have to modify this file:

Can you suggest something and make a PR, I would love to incorporate Russion into the ulmfit-multilingual.
I would based it on the load_cls_data_imdb.

Russian is a bit like Polish meaning that both languages have rich morphology so I would use sentencepiece tokenizer with 25k tokens.

Here is how I would train russian LM:

python -m ulmfit lm --dataset-path data/wiki/ru-100 --bidir=False --qrnn=False --tokenizer=sp --name 'bs40'  -  train 20 ---bs=40 

(Piotr Czapla) #90

Having Dutch in ulmfit-multilingual would be awesome is your dataset public?

If you may want to use a merged wikipedia’s, to train this kind of LM. @eisenjulian is working on very similar task maybe he has some code to share.

You may as well think about using LASER it was released 5 days ago.


(Alexey) #91

Thank you @piotr.czapla. As for now i’m working on the level of fastai abstraction to make it more simple (for me) to understand all the logic. I’m trying to work on upstream classification tasks and get near the best results (in comparison with current benchmark -
Next I’ll try to increase the amount of domainspecific (twiter) data for LM finetuning to see if it helps on upstream classification task.
Later I’ll experiment with different tokenizers and try to addapt to my data.


(Piotr Czapla) #92

@ademyanchuk Perfect ! Can you create a “ULMFiT - Russian” page and put it on the top page of Language Model Zoo? @ppleskov was working on the Russian model in the past but I don’t think he managed to beat the SOTA Russian Sentiment Analysies, He was using the following benchmark:


(Alexey) #93

Shure. I’m not currently best on this one

But i actuallty did some experiments on

and it turned out to be easy task to classify, i get near .98 f1. Check my solution twice on any bugs, but cant find something. So I believe ruSentEval is beaten.

I create thread for ULMFit - Russian ULMFiT - Russian



I just posted about a German topic classification dataset to the ‘ULMFiT German’-page. The dataset might be useful for some of you here.


(Benjamin van der Burgh) #95

I’m very happy to share the Dutch dataset and the weights of the trained language model!

However, for the former, I’m not sure whether I can publish it, since the contents are scraped. I’ve read the website’s disclaimer and there’s nothing in it that forbids it, but I’m still not quite sure about legal issues :sweat_smile:

For language model weights, do you have pointers how I can best package and describe it? I’ve never shared network weights before.


(Jeremy Howard (Admin)) #96

I believe that in most jurisdictions scraping is allowed, unless it is explicitly restricted by the TOS of the site.


(Benjamin van der Burgh) #97

@jeremy That sounds promising!

I still wanted to give credits to the owners of the website and its reviewers, so I’ve sent them an email to see if they’re open for this kind of publication. I’ve already tidied up my code and the dataset itself, so it’s ready for publication. I’m just waiting for a response from them now… Fingers crossed! :crossed_fingers:

1 Like


Please take note of this breaking change coming in v1.0.43

1 Like

(Benjamin van der Burgh) #99

@sgugger: thanks for the heads-up!

@piotr.czapla: considering recent developments in the FastAI library, what’s the status of ulmfit-multilingual? I’ve used slightly edited versions of those scripts to generate a language model for Dutch. Is this still the way to go?


(Piotr Czapla) #100

@benjaminvdb, Good work, and on time so we can add it to the paper that summarise multilingual ULMFiT.

Recently @mkardas made ulmfit-multlingual compatible with the fastai, we have it in a separate branch that I’m looking in to merging to master tomorrow.


ULMFit - Portuguese
ULMFiT - Japanese
(Piotr Czapla) #101

Gals & Guys we are summarising the work on ulmfit-multilingual, and @sebastianruder is writing a short paper.
I’m going through the forum threads and I’m adding ppl that contributed some interesting tests to a private thread, but there is a chance I’ve missed something. If you feel you should be added please let me know.

You can check if you are in the thread by following this link. If I missed you please let me know on private message or thread @ mention me in your language that shows the results.

The paper has a deadline soon (end of Feb). If you would like your results to be added we need to have a pull request by next week that includes:

  • the code to download your dataset
  • the “.md” with the results
  • and links to pretrained LM weights.

So we can run the classification task to double check the results are reproducible without need to train the full LM. If you happen to contribute to the language covered by MLDoc the LM’s won’t be necessery as we will have both lstm and qrnn based one.


(Sebastian Ruder) #102

Just to chip in, everyone who contributed a dataset and achieved good results that we can reproduce on the data will be included on the paper. Please provide additionally the following information in the PR so that it will be easier to attribute the work:

  • your first name and last name;
  • your preferred affiliation;
  • your email address.

Thanks for your efforts!


(Charin) #103

Finalizing results for Thai to use fastai 1.0.38 and above (previous results and datasets are based on 1.0.22). Do you have a hard deadline for the pull request? @sebastianruder

Edit: sorry I think I saw this 12 days too late :frowning:


(Yury Kashnitskiy) #104

Hi all!

I’m DS @ KPN, NLP practitioner and leader of
Currently doing SSL in parallel with English (amazon product reviews) and Dutch texts. Have tried a lot of models and approaches, and currently ULMFiT works best for reviews in English.

@benjaminvdb thanks a lot for sharing the pretrained Dutch model!
I only regret that found this thread so late. If any contribution from my side needed - I’m open.

1 Like

(Alexey) #105

As far as I know, the fastai library is open to any kind of useful contribution. See the link.
Best regards))

1 Like

(Fred Guth) #106

Hi, all!

some months ago I trained an ULMFiT model for Portuguese, but this was pre fastai v1. I want to give it a try again with v1 and in the context of the multilingual ULMFiT. I am looking for some guidance on the corpus to start with.

I noticed while doing it the first before that En Wikitext-103 text quality is much better than the pt.wikipedia articles I got in the dump. The reason is that they get it from the featured pages. There is no specific dump for featured wikipedia pages in portuguese. Moreover there are fewer featured pt pages anyway.

I wonder how have you chosen the input data. Any guidance on this issue?


(Benjamin van der Burgh) #107

@fredguth: It’s true that regular Wikipedia dumps are not as clean as Wikitext-103. However, I’ve trained a few language models on the Dutch Wikipedia and it performed pretty well, i.e., I was able to train good classifiers on very small datasets.

For example, I achieved 88% accuracy on a binary classification problem (sentiment with two polarities: neutral and positive) on only 250 examples. This can only mean that the LM was able to catch language basics pretty well and it didn’t have to learn them from the target dataset.

The question is whether you really need curated data for training your LM. It might be that instead of spending time on this, it would be more productive to use more data, e.g., CommonCrawl. I don’t know the answer to this question though.