Are there any ML models or APIs that can be used to classify a sentence into one of the four types of sentences; i.e. declarative (statement), imperative (command), interrogative (question) and exclamatory (exclamation).

P.S. A web rest api would be ideal. Alternatively, if it exists, please recommend an algorithm that solves this problem.


You can use bart-large-mnli model open-sourced by facebook and is available here

Once you download all the files you can create a microservice and expose it as an API or alternatively run it in batch processing model

  • $\begingroup$ thanks for the recommendation. It does a pretty good job with most sentences $\endgroup$
    – NSCoder
    Jan 8 at 9:21
  • $\begingroup$ Also, please explore the distilled libraries of the same model. They claim to give almost same performance with double speed $\endgroup$ Jan 14 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.