Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrating ONNX runtime (ORT) in Spark NLP 5.0.0 馃帀 #13857

Merged
merged 33 commits into from
Jul 1, 2023

Conversation

maziyarpanahi
Copy link
Member

@maziyarpanahi maziyarpanahi commented Jun 15, 2023

Overview

This pull request (PR) aims to enhance the capabilities of Spark NLP by introducing the integration of the ONNX runtime ORT for 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, and pytorch. 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, and DeBertaEmbeddings. 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

  • BERT (for Word Embeddings)
  • DistilBERT (for Word Embeddings)
  • DeBERTa (for Word Embeddings)
  • RoBERTa (for Word Embeddings)

Tested platforms

  • Test CPU (normal, optimized, and quantized)
    • Colab
    • EMR
    • Glue 3/4
    • AWS ECS Fargate
    • Databricks
  • Test GPU/NVIDIA (normal, optimized, and quantized)
    • Colab
    • EMR
    • Glue 3/4
    • Databricks

@maziyarpanahi maziyarpanahi added documentation new-feature Introducing a new feature new model DON'T MERGE Do not merge this PR labels Jun 15, 2023
@maziyarpanahi maziyarpanahi self-assigned this Jun 15, 2023
@maziyarpanahi maziyarpanahi changed the base branch from master to release/500-release-candidate June 19, 2023 06:51
@coveralls
Copy link

coveralls commented Jun 19, 2023

Pull Request Test Coverage Report for Build 5388321371

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.008%) to 65.887%

Totals Coverage Status
Change from base Build 5308728546: 0.008%
Covered Lines: 8647
Relevant Lines: 13124

馃挍 - Coveralls

@maziyarpanahi maziyarpanahi merged commit c2dd80d into release/500-release-candidate Jul 1, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation DON'T MERGE Do not merge this PR new model new-feature Introducing a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants