Giter VIP home page Giter VIP logo

nlp_scripts's Introduction

NLP scripts

Hi,

This repo contains notebooks related to various transformers based models for different nlp based tasks. I will be adding more notebooks in this repo with time.

I am open for collabarations as well. If you want to contribute, create a new pull request after adding new scripts. Will merge them if they are usable.

nlp_scripts's People

Contributors

dhavaltaunk08 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nlp_scripts's Issues

getting 38% hamming score using this code for multilabel classification of my 24000 dataset into 26 classes. please suggest something so that casn go upto 90%

i am using this code only for multilabel classification of text into 26 labels but getting only 38% hamming score and 28% flat_score.
please suggest some changes in my cod so that can achieve above 90%

0it [00:00, ?it/s]
Epoch: 0, Loss: 0.607304036617279
102it [01:51, 1.04s/it]
Epoch: 0, Loss: 0.42913737893104553
202it [03:40, 1.04s/it]
Epoch: 0, Loss: 0.31689316034317017
278it [05:05, 1.10s/it]
0it [00:00, ?it/s]
Epoch: 1, Loss: 0.25217771530151367
102it [01:52, 1.04s/it]
Epoch: 1, Loss: 0.2359163910150528
202it [03:41, 1.04s/it]
Epoch: 1, Loss: 0.20691940188407898
278it [05:06, 1.10s/it]
0it [00:00, ?it/s]
Epoch: 2, Loss: 0.18726885318756104
102it [01:52, 1.05s/it]
Epoch: 2, Loss: 0.18049341440200806
202it [03:41, 1.05s/it]
Epoch: 2, Loss: 0.1675453633069992
278it [05:06, 1.10s/it]
0it [00:00, ?it/s]
Epoch: 3, Loss: 0.1804620772600174

loss is not descreasing no matter how much i increase the epochs and i also tried increasing my batch size to 64 also with 2 gpu support but not getting very good accuracy.

The test score on Kaggle seems quiet low

I modify it and then predict the test.tsv and submit to kaggle sentiment competition. The score is quite low, much lower than BERT, so how much epoch will be better. For Bert, I just use 3 epoch, but increase epoch in this roberta seems not work.

Why text = " ".join(text.split()) in __getitem__ in Transformers_multilabel_distilbert?

The code I'm referring to is in cell 8 in https://github.com/DhavalTaunk08/NLP_scripts/blob/master/Transformers_multilabel_distilbert.ipynb
I tried to print before and after this line, and I see no difference.

print(text)
print(repr(text))
text = " ".join(text.split())
print(text)
print(repr(text))

Output:

proving there is no cure for stupidity.
'proving there is no cure for stupidity.'
proving there is no cure for stupidity.
'proving there is no cure for stupidity.'

Maybe it makes a difference in certain cases? Or can I just remove this line?

How to load the fine-tuned model after save it local.

I noticed the fine-tuned roberta script saved the fine-tuned model locally by

model_to_save = model
torch.save(model_to_save, output_model_file)
tokenizer.save_vocabulary(output_vocab_file)

How to load this model from the local folder?
I try this:

from transformers import RobertaModel, RobertaTokenizer
# from the local folder
roberta_model = RobertaModel.from_pretrained("./")
roberta_tokenizer = RobertaTokenizer.from_pretrained('./', truncation=True, do_lower_case=True)

But failed with error: OSError: does not appear to have a file named config.json. Checkout 'https://huggingface.co/.//main' for available files.

about inference

To make predictions, how to load the model which were saved during the training process?
After load model, we can inference testing data.
thank you :)

Multi-gpu support

The current code is unable to support multi-GPU environment.

I parallelized the model using torch.nn.DataParallel(model).cuda()

I got this error when I try :
16032841374066409239620202407970

When shall clearing gradients happen?

Thank you. In the Transformers multilabel distillbert, in the function "train(epoch)", you clear gradients after the model feed-forward operation and before loss backward calculation, and you uses "optimizer.zero_grad()" twice. Will this clear the gradients that the backward calculation needs? Shall it be like this where we only need to clear gradients once before model feed-forward operation:

    optimizer.zero_grad()
    outputs = model(ids, mask, token_type_ids)

    loss = loss_fn(outputs, targets)
    if _%5000==0:
        print(f'Epoch: {epoch}, Loss:  {loss.item()}')

    loss.backward()
    optimizer.step()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.