-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How should one modify the code to successfully run text classification? #43
Comments
@davidefiocco I have made the modifications in
You can refer to my question in #40 . Hope this helps. |
@lordzuko thanks! I had seen #40 and that's excellent guidance for me on how that
but this is not working as intended as of now.. |
@davidefiocco Are you getting any error? or the model is not training as intended, if you are getting an error, can you please share the error-trace, please. |
@lordzuko I have tried implementing the steps that I described in #43 (comment) (hoping they make sense...) and got
I can try to make this reproducible is to provide more code/publish a fork as I modified the current code in several parts (see my comment above for the full list) when trying to implement the head change (#43 (comment) is one of the changes). I am not very proficient in PyTorch yet though (so they may be clumsy changes), that's why the questions in #43 (comment) . Most likely, the |
Hi @davidefiocco, |
Hi @thomwolf, thanks for your reply and tip! As advertised I forked the code, and you find the result at master...davidefiocco:master and that specific edit can be found at https://github.com/davidefiocco/pytorch-openai-transformer-lm/blob/e9945725603544cdebaec91937d4a16f14db0ad8/train.py#L26 In the fork namings , I will update this issue if I manage to get it sorted, and if someone is keen on giving feedback on what needs to be changed in the code I'll be very happy to work on it. |
I had another bug, which I think I fixed with And I seem to converge and reproduce the 91+% evaluation accuracy on SST-2. I am still not sure that everything is really fine, but it seems to converge at least now! |
Hi,
I am new to PyTorch (but still more at ease with it than TF) so I thought to experiment with @thomwolf 's implementation in this repo (thanks for sharing it!!)
I would like to try out the code to perform binary text classification of text snippets, similar to the classification tasks such as the Corpus of Linguistic Acceptability (CoLA) and the Stanford Sentiment Treebank (SST-2) in the original reference.
These are the steps that I think are needed to get the code working (but I am not sure that these are correct and/or exhaustive):
snippets_val.csv
andsnippets_test.csv
containing two columns,text
(string) andclass
(an int equal to 0 or 1).datasets.py
create two new functions:_snippets
returning two listsst, y
, andsnippets
defined with different values ofn_train
andn_valid
and whose return statement looks likereturn (trX, trY), (vaX, vaY), (teX, )
train.py
, rewritetransform_roc
into atransform_snippet
that doesn't use[delimiter]
and takes only one argument in input <- somewhat tricky to me can anyone provide some guidance?train.py
, in the encoding bit and afterwards:encode_dataset
to match the output of the function ofsnippets
redefined above.encoder['_delimiter_'] = len(encoder)
n_special = 2
as we got rid of['_delimiter_']
2
and3
in their name (?) e.g. in the definition ofn_ctx
<- somewhat tricky to me can anyone provide some guidance?train.py
:dh_model
to use('classification', 2)
instead of'multiple_choice'
ClassificationLossCompute
instead ofMultipleChoiceLossCompute
analysis.py
:snippets
so to invoke_snippets
(fromdatasets.py
) and read insnippets_test.csv
and adjust its call to_snippets
so to take into account that it outputs two lists (not 4)train.py
coherently with all of the above.Does all of the above make sense as a plan, or can somebody fill missing bits or provide an alternative list of "sub-steps" ?
Also, can someone provide some guidance on how to rewrite
transform_roc
(comments on the original code would be fantastic, I am glad to annotate the original function and contribute to the repo as a result of this!)Thanks to anyone patiently reading this!
The text was updated successfully, but these errors were encountered: