fanolabs / IntentBert

20 stars 4 forks source link

inference #2

Open Moeinh77 opened 1 year ago

Moeinh77 commented 1 year ago

Hi, I have been trying to get your model to work for inference but it has been challenging. I want your model to do few-shot learning on a couple of samples that I provide e.g. with labels L1 and L2. After the few-shot learning, I want to do inference and see if it can predict unseen samples correctly and assign them to L1 and L2. I'd appreciate it if you help me out.

zhang-yu-wei commented 1 year ago

Hi, thank you very much for your interest to our work!

As far as I understand your question correctly, you want to do binary classification task with few-shot training data.

IntentBERT is pre-trained with source domain data and then we only keep the backbones. We then produce embeddings on few-shot training and testing data with normalization. These normalized embeddings will be used to train classifiers like SVM and logistic regression. Please take a look at this function here: fewShotPredict.

Let me know if this helps!

Moeinh77 commented 1 year ago

Hi, thanks for replying. Yes, I have seen that function, but I was confused about its arguments. In inference time, what should I pass to that function as supportX?

hdzhang-code commented 1 year ago

Hi, @Moeinh77 ,

SupportX contains the 'few-shot' data, i.e. the few annotated data for classification. For example, it contains 25 data in total, if we have 5 labeled data per class and 5 classes to classify. The data structure SupportX is generated here: https://github.com/fanolabs/IntentBert/blob/main/utils/Evaluator.py#L67C17-L68C95

As for the details, sorry to say that I also forget. I suggest you set a break point at the aforementioned line and check everything there. To run to that line, you can run the script for evaluation, following the Evaluation part of README.md: https://github.com/fanolabs/IntentBert/tree/main#evaluation

Best Regards, Haode