Coder Social home page Coder Social logo

bert-unsupervised-ood's People

Contributors

rivercold 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

Watchers

 avatar  avatar

Forkers

mxnno ajshawn

bert-unsupervised-ood's Issues

Index Error

I got the following error when I tried to run

python ood_main.py --method MDF --data_type clinic --model_class bert

Error:

batch_all_features = self.get_hidden_features(**inputs, use_cls=use_cls)
all_hidden_feats = outputs[1]   # list (13) of bs x length x hidden
IndexError: tuple index out of range

Could you help me to solve this error?

I have installed all the requirements as you specified

FileNotFoundError: [Errno 2] No such file or directory: './outputs/clinic_bert_bert-base-uncased.pkl'

Hi guys,

when I ran:

!python ood_main.py
--method MDF
--data_type clinic
--model_class bert

I'm getting this error:

Work on different intents
train 15000 test 4500 ood 1000
---------- Use AVG embebeddings to represent sequence ----------
INFO:simpletransformers.classification.classification_model: Converting to features started. Cache is not used.
INFO:simpletransformers.classification.classification_model: Converting to features started. Cache is not used.
INFO:simpletransformers.classification.classification_model: Converting to features started. Cache is not used.
INFO:simpletransformers.classification.classification_model: Converting to features started. Cache is not used.
running ---: kernel: linear nuu: 1e-09
running ---: kernel: linear nuu: 1e-07
running ---: kernel: linear nuu: 1e-05
running ---: kernel: linear nuu: 0.001
running ---: kernel: linear nuu: 0.01
running ---: kernel: linear nuu: 0.1
running ---: kernel: linear nuu: 0.2
running ---: kernel: linear nuu: 0.5
AUROC DTACC AUIN AUOUT
76.72 71.11 93.41 38.19
best hyper linear-0.5
saving data for plotting
Traceback (most recent call last):
File "ood_main.py", line 506, in
main(args)
File "ood_main.py", line 484, in main
MDF_OOD_detect(args) # our method
File "ood_main.py", line 381, in MDF_OOD_detect
with open("./outputs/{}{}{}.pkl".format(data_type, args.model_class, load_path.split("/")[-1]), "wb") as f:
FileNotFoundError: [Errno 2] No such file or directory: './outputs/clinic_bert_bert-base-uncased.pkl'

Any idea how I can resolve this issue?

Many thanks in advance,
Min

Error when running roberta with our own finetuned data

Hello,
We are trying to run roberta model with our finetuned output data (we are using our own data set) with the following:

!python ood_main.py
--method MDF
--data_type clinic
--model_class roberta
--load_path ./model/bert_clinic_ft_MLM_binary_intent_outputs_7500

and get the following error:

---------- Use AVG embebeddings to represent sequence ----------
INFO:simpletransformers.classification.classification_model: Converting to features started. Cache is not used.
Traceback (most recent call last):
File "ood_main.py", line 506, in
main(args)
File "ood_main.py", line 484, in main
MDF_OOD_detect(args) # our method
File "ood_main.py", line 326, in MDF_OOD_detect
mean_list, precision_list = model.sample_X_estimator(train_df['text'].values.tolist(), use_cls)
File "/home/ec2-user/SageMaker/BERT-unsupervised-OOD/our_model.py", line 115, in sample_X_estimator
eval_examples, evaluate=True, multi_label=False, no_cache=True
File "/home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages/simpletransformers/classification/classification_model.py", line 757, in load_and_cache_examples
all_input_ids = torch.tensor([f.input_ids for f in features], dtype=torch.long)
TypeError: an integer is required (got type NoneType)

Any idea what might be wrong?

Before, we had to modify the our_model.py fragment:

from:

self.tokenizer = tokenizer_class.from_pretrained(model_name, do_lower_case=self.args["do_lower_case"], **kwargs)

to:

self.tokenizer = tokenizer_class.from_pretrained(model_name, vocab_file="./models/bert_clinic_ft_MLM_binary_intent_outputs_7500/checkpoint-2000/vocab.json", merges_file="./models/bert_clinic_ft_MLM_binary_intent_outputs_7500/checkpoint-2000/merges.txt", do_lower_case=self.args["do_lower_case"], **kwargs)

this was needed because the method was unable to find vocab and merges files. Those files where nowhere to be seen (except the vocab.txt file which seems to be wrong) in the given folder, so we got it from :
https://huggingface.co/roberta-base/resolve/main/vocab.json
https://huggingface.co/roberta-base/resolve/main/merges.txt
hope it is still ok :)

Anyway, any help about this "TypeError: an integer is required (got type NoneType)" would be much appreciated! thanks!
Pawel

data file structure: clinc150_test & clinc150_val

Hi OP,

Could you please tell me the purpose of the file (and also appearing in the JSON file): clinc150_val.

Also, just to double check - clinic150_test is 4500 lines of unseen in-domain data right? How is this different from clinc150_val?

Once again, many thanks in advance,
Min

Transformer model

Hello!
Is it possible to use another model like CamemBERT using load_path argument? or it is only for fine-tuned Bert and Roberta model?
Thanks in advance!

How can I generate the pretrained model file "bert_clinic_ft_IMLM_BCAD" by myself?

Hello, I'm interested in your work and try to compare with other OOD methods. I find that there are two independent parts of IMLM and BCAD but the best performance can be achieved with both strategies. So I'm wondering how to arrange IMLM and BCAD strategies at the same time. Besides, in the code of IMLM and BCAD parts, the pretrained models are LanguageModelingModel and ClassificationModel while BertForSequenceClassification is used for OOD task, so how can I solve the problem of model parameter mismatch?

A question about gaussian_score in the code

Hi, I have read this wonderful paper. When I look at the code, I have a question.
https://github.com/rivercold/BERT-unsupervised-OOD/blob/main/our_model.py#L181
In the our_model.py line 181,you define the gaussian score that:
gaussian_score = -0.5 * ((zero_f @ precision[i]) @ zero_f.t()).diag()
But in your paper, I gauss this gaussian_score is the $M_{l}(x_{i})$, But I wonder why you don't use the inverse of a matrix precision[i] in the code. I also wonder why there is a -0.5 before this equation.
Thanks a lot.

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.