rivercold / bert-unsupervised-ood Goto Github PK
View Code? Open in Web Editor NEWCode for ACL 2021 paper "Unsupervised Out-of-Domain Detection via Pre-trained Transformers"
License: MIT License
Code for ACL 2021 paper "Unsupervised Out-of-Domain Detection via Pre-trained Transformers"
License: MIT License
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
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
Hi,
I wonder how can I train a full model for different datasets.
I want to test your approach on different setups :)
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
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
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!
Hi, can I get the BERT pre-trained model?
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?
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
Thanks a lot.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.