How does transformers.pipeline works for NLI?
I am applying pretrained NLI models such asroberta-large-mnlito my own sentence pairs. However, I am slightly confused by how to separate the promise and hypothesis sentences. By checking through the models available on Huggingface and the examples they show on hosted inference API, some use</s></s>between sentences, some use[CLS] ... [SEP] ... [SEP], and some such as your ownmodeldo not add any placeholdersI just want to know more about howpipeline(task="sentiment-analysis", model="xxx-nli")works under-the-hood. I assume it feeds each sentence pair separately intotokenizer.encode_pluslike what is donehere. But whatmax_lengthdoes the model though?Any information would be really appreciated! Thanks!
2021-05-04T15:39:44Z
Hi@bwang482,You are perfectly correct, the responsability of chosing the proper layout for this task goes to thetokenizerpart (encode_plusor justencode).What do you mean withmax_length? I am not sure what you are referring to.Cheers,Nicolas
2021-05-04T18:34:36Z
Thanks very much for your reply@Narsil!!Bymax_length, I meant themax_lengthparameter inencode_plus, because I saw the author of theAdversarial NLImodel actually used this parameter. But now I think about this again, it might be best just leave it unset.Just to confirm, so if I want to use the correct notations for separation for the model, I should first check out what its (Hosted Inference API) example looks like onHugging Face – The AI community building the future., and then use the same separation tokens (e.g.</s></s>or[CLS] ... [SEP] ... [SEP])? It seems the models don’t usually use the same notations.
2021-05-05T08:03:44Z
Yes, the README of models should include snippets of how to use. If they don’t however you will have to dive into the model to see how it behaves or usepipelines:Pipelines — transformers 4.5.0.dev0 documentation
2021-05-05T13:51:52Z
Many thanks@Narsil!I find most models do not have such information in their README. For example, this huggingfacemodeldoesn’t have a README at all. It’s also difficult to get any information from itsvocabfile. By “dive into the model” do you mean just try a bunch of examples? That’d be tricky I think. Even for the models which instructed to use SEPARATION tokens, you can even get somewhat reasonable results w/o using them as it seems. For examples, using thismodel, if you remove</s></s>the inference API still returns similar results…