thuiar / TEXTOIR

TEXTOIR is the first opensource toolkit for text open intent recognition. (ACL 2021)
https://github.com/thuiar/TEXTOIR
MIT License
195 stars 30 forks source link

Running inference on a trained model #36

Closed abal6725 closed 1 year ago

abal6725 commented 2 years ago

Hello,

First of thank you so much for developing and open-sourcing this. I have used DeepAligned on the Banking dataset to train and save a model. Now I would like to use this model to run inference on another set of data. How can I do this? Thanks!

HanleiZhang commented 2 years ago

First, the data need to be in the same format as in Banking. Second, you can just load the pre-trained model for inference (It should predict intent labels for each utterance). If you encounter any problems during inference, please notify us and we will fix the bugs.

abal6725 commented 2 years ago

Hi,

I have used the following command to train a model on the banking dataset:

!python TEXTOIR/open_intent_discovery/run.py --dataset banking --method 'DeepAligned' --setting 'semi_supervised' --known_cls_ratio 0.75 --seed 1 --backbone 'bert' --config_file_name 'DeepAligned' --train --save_model --save_results --results_file_name 'results_DeepAligned.csv' --output_dir output

My model is saved in the following directory:

image

I would now like to use this model to run inference on a sample of data that does not exist in the banking77 dataset and see what labels this model predicts. How can I set this up? Should I create a new folder within the data folder and set my data in a test.tsv? Also what is the exact command that I need to run so that it picks up this trained model and point it to my new data?

Thanks in advance for the help!

mrFocusXin commented 2 years ago

The first thing you need to do is create a new directory in your data file, which is structured like banking. Then configure your data set information in /dataloaders/init.py. Then you can configure the trained model directory with '--model_output_dir' and set '-- train 'to False. To load the trained model and specify the dataset you want to predict with the 'dataset' parameter, perform label prediction.