Part 2 Lesson 10 wiki

(Stefan) #495

@jeremy Is there a documentation available of the exact preprocessing and training steps for the language model (WikiText-103). I looked at the Hindi repository, but I’m not sure, if the “t_up” trick is used there?

So it would be great to have a kind of reference implementation/documentation for the WikiText-103 language model :slight_smile:

(Jeremy Howard) #496

This is the script we used:


Interesting, this comes with the freezing of layers. The model trains without error if you unfreeze it completely, I don’t know where this one comes from.
I’ll try to look into it.


Hi all. I’m using Google Colaboratory and I’m getting an AttributeError when trying to install scipy sparse - module ‘scipy’ has no attribute ‘sparse’. I’ve searched the forums and notice others having the same issue.

Not a problem but, just wondering if anyone has found a patch…

I have installed scipy-1.1.0 and also imported it directly using - from scipy import sparse as sp

Any help would be greatly appreciated!

AttributeError Traceback (most recent call last)
in ()
----> 1 from fastai.text import *
2 import html

/usr/local/lib/python3.6/dist-packages/fastai/ in ()
----> 1 from .core import *
2 from .learner import *
3 from .lm_rnn import *
4 from import Sampler
5 import spacy

/usr/local/lib/python3.6/dist-packages/fastai/ in ()
----> 1 from .imports import *
2 from .torch_imports import *
4 def sum_geom(a,r,n): return an if r==1 else math.ceil(a(1-r**n)/(1-r))

/usr/local/lib/python3.6/dist-packages/fastai/ in ()
3 import pandas as pd, pickle, sys, itertools, string, sys, re, datetime, time, shutil, copy
4 import seaborn as sns, matplotlib
----> 5 import IPython, graphviz, sklearn_pandas, sklearn, warnings, pdb
6 import contextlib
7 from abc import abstractmethod

/usr/local/lib/python3.6/dist-packages/sklearn_pandas/ in ()
1 version = ‘1.6.0’
----> 3 from .dataframe_mapper import DataFrameMapper # NOQA
4 from .cross_validation import cross_val_score, GridSearchCV, RandomizedSearchCV # NOQA
5 from .categorical_imputer import CategoricalImputer # NOQA

/usr/local/lib/python3.6/dist-packages/sklearn_pandas/ in ()
5 import numpy as np
6 from scipy import sparse
----> 7 from sklearn.base import BaseEstimator, TransformerMixin
9 from .cross_validation import DataWrapper

/usr/local/lib/python3.6/dist-packages/sklearn/ in ()
132 else:
133 from . import __check_build
–> 134 from .base import clone
135 __check_build # avoid flakes unused variable error

/usr/local/lib/python3.6/dist-packages/sklearn/ in ()
11 from scipy import sparse
12 from .externals import six
—> 13 from .utils.fixes import signature
14 from . import version

/usr/local/lib/python3.6/dist-packages/sklearn/utils/ in ()
10 from .murmurhash import murmurhash3_32
—> 11 from .validation import (as_float_array,
12 assert_all_finite,
13 check_random_state, column_or_1d, check_array,

/usr/local/lib/python3.6/dist-packages/sklearn/utils/ in ()
14 import numpy as np
—> 15 import scipy.sparse as sp
17 from …externals import six

AttributeError: module ‘scipy’ has no attribute ‘sparse’

(Erik Chan) #499

Is it me or the files are no longer existing at

(Emil) #500

To me, the files are still there.

(Erik Chan) #501

Thanks they’re back online now

(WG) #502

Is there a definitive answer to this question anywhere?

Based on the ULMFiT paper, the recommendation is to fine-tune “only the last layer” (section 3.2) before unfreezing and applying discriminative learning rates to the other layers. As such, why is there the line learner.unfreeze() immediately before fitting the model begins? It seems that it should be learner.freeze(-1) unless I’m missing something (which is typically the case :slight_smile: )

(Even Oldridge) #503

Hey Christine, I’m starting to take a look at something similar and I’m curious what your results were here?

(adrian) #504

I thought it was a typo but didn’t get round to reporting it, i do the same with just unfreezing final layer

(Erik Chan) #505

Did you have any luck with this? Can you not simply add more classes?

(Christine) #506

Hi - Unfortunately I wasn’t able to get better results with the different losses. (I got everything up and running, but the accuracy was always less good.) I’m sure I didn’t exhaust every possibility though, so let me know if you have better success than I did!

(Gavin Francis) #507

Reading Universal Language Model Fine-tuning for Text Classification
Not sure if anyone has commented on this before, but in @jeremy and Sebastian’s excellent paper, there seems to be an error in the STLR formula (3) for p when t>cut. In order to match the figure, it should be something like (T-t)/(T-cut)

(gram) #509

I understand why this is much better than word embeddings but with this model is there a way to use the words (in the context of the corpus you fed the model) like you would with word embeddings?
For example: the King - man + woman = queen equation?
What exactly does implementing the transfer learned, trained model look like? What can it do besides classifying?
I know chatbots use LSTMs. Maybe someone can point me in the direction to how this model would work in a chatbot? How does one glom meaning from new text run through the trained model? How it would work with translation? How it works with a GAN? How it works with a search? How it works as a Q and A? This would help me understand what exactly is happening with the whole process. Please?

(If someone just wants to give an answer to one of these that’d be appreciated. I know no one person will answer all of this.)

(Thomas) #510

It’s a bit handwavy, but I thought about this a bit (actually the second half).
One thing the LM does over word vectors is keep quite a bit more context - as we are looking at LSTM states.
As such I would expect the equivalent of King - Man + Woman = Queen to be a relatively poor use of such a model.
For chatbots, QA, MT, I think using the encoder (or in the latter encoder + decoder) will be beneficial, as for those the history is natural.

(gram) #511

Thanks for the answer. I’d like to make a Q and A ‘bot’ with this but I feel I don’t know which direction to go to learn how to make one.
Maybe I can just take a chatbot using word embeddings and modify it to use this lesson’s model instead? I’m too new at this. Sometimes the steps to progress are too high to climb.

(Shubham Gupta) #512

Hey guys, have written a blog on Generating your own music using RNNs. Hope you enjoy it.

(gram) #513

Oh, now I see lesson 11 is a translator.
Lesson 11 used to be about a CNN with pictures of fish at the beginning.

(I ripped the videos to my hard drive to play on my other devices and hadn’t seen the switch-a-roo)

(Dusten) #514

the robots.txt file is a file that would live on the root or any sub-dir of the root. The goal is to inform web-crawlers to not index or index on the connected site.

I don’t think it’s used much anymore but still a hold over of a earlier version of the internet.

(Francisco Rodes) #515

Hello everyone!

I have been reading the paper and investigating the ULMFiT model. Does anybody know what is exactly test? In the paper there are some tables that make reference to Test error and others to Validation error. Are they the same?

As I understand, in IMDb model, the validation set is the only test set that is used. Am I wrong and there is another one? Thanks!