Integrating ONNX runtime (ORT) in Spark NLP 5.0.0 🎉 #13857
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Overview
This pull request (PR) aims to enhance the capabilities of Spark NLP by introducing the integration of the ONNX runtime
ORTfor Java. This integration will enable the users to import Transformers and LLM (Language Model) models in ONNX format into Spark NLP. 🎉In the upcoming release of Spark NLP 5.0.0, users can work with models in both TensorFlow and ONNX formats. However, our team's default provision of pretrained models will be in ONNX format. This choice is driven by the fact that the ONNX models yield significantly better inference results, ranging from 3x to 5x, even without any optimization or quantization techniques on CPUs.
The integration of ORT in Spark NLP empowers users to further enhance the performance of their models. When exporting models to ONNX, users can leverage built-in features provided by libraries such as
onnx-runtime,transformers,optimum, andpytorch. These features include optimization and quantization capabilities, which come ready to use out of the box.Initial Annotators/Features to support ONNX Runtime
In the realm of Vector Databases, the quest for faster and more efficient Embeddings models has become an imperative pursuit. Models like BERT, DistilBERT, and DeBERTa have revolutionized natural language processing tasks by capturing intricate semantic relationships between words. However, their computational demands and slow inference times pose significant challenges in the game of Vector Databases.
In Vector Databases, the speed at which queries are processed and embeddings are retrieved directly impacts the overall performance and responsiveness of the system. As these databases store vast amounts of vectorized data, such as documents, sentences, or entities, swiftly retrieving relevant embeddings becomes paramount. It enables real-time applications like search engines, recommendation systems, sentiment analysis, and chat/instruct-like products similar to ChatGPT to deliver timely and accurate results, ensuring a seamless user experience.
With that in mind, we have started with the following annotators:
BertEmbeddings,DistilBertEmebeddings, andDeBertaEmbeddings. We will identify all the existing models for these annotators on our Models Hub, re-exporting them in ONNX format, and re-uploading them with the same name to have a seamless transition for our community starting Spark NLP 5.0.0. (stuff will just get faster with each release starting Spark NLP 5.0.0 🚀)Models converted to ONNX
Tested platforms