Yes you can. The idea is to train the model as an NLI task. Then you can pass this custom model that you have trained into the pipeline.


You can also do sentiment analysis using the zero shot text classification pipeline. But if you have sufficient data and the domain your targeting for sentiment analysis is pretty niche, you could train a transformer (or any other model for that matter) based on the data you have.


Hope this makes sense and is helpful.