Embedding as a Service(EaaS) vs. Model as a Service(MaaS)
In GPT(Generative Pre-Trained Transformer), there are two main ways to get access to pre-trained models: Embedding as a Service (EaaS) and Model as a Service (MaaS). They are also the two most popular deployment options to deploy models to the applications. I originally wrote the ways to deploy the different models in here.
In the above post, I mostly did a comparison for traditional model serving and deployment options for those models. However, it was back in 2018-2019, ChatGPT has not taken over the industry both in terms of model accuracy, but also overall deployment options. Further, pre-trained model weight sharing was not such a big lever as the models were more specifically built for certain tasks and generally either the infrastructure or the ROI did not meet the bar for very large models and LLMs were not something that entered into our deep learning lexicon.
Both EaaS and MaaS have their own advantages and disadvantages, in this post, I will give first the motivations/definitions for both of them and then do a comparison between two deployment options.
Embedding as a Service
EaaS provides access to pre-trained embeddings, which are vector representations of words or concepts. Embeddings can be used for a variety of tasks in different downstream applications, such as natural language processing (NLP), recommendation systems, and search engines.
The main advantage of EaaS is that it is very easy to use. You simply need to select the embeddings that you want to use, and then you can start using them in your own applications. EaaS is also very scalable, so you can easily add more embeddings as your needs grow.
The main disadvantage of EaaS is that you are limited to the embeddings that are provided by the model or service that provides the embeddings. If you need a specific embedding that is not available, you will need to train your own model. Because of that, it is not very customizable for further downstream applications and tasks for further customization and use cases.
Model as a Service
MaaS provides access to pre-trained models, which are whole deep learning models that can be used for a variety of tasks. MaaS is a good choice if you need a model that can be used for a specific task, such as image classification or fraud detection.
The main advantage of MaaS is that it provides you with a full model that you can use right away. You don't need to worry about training the model yourself, and you can be confident that the model has been trained on a large dataset and that has good model accuracy and performance characteristics.
The main disadvantage of MaaS is that it can be more expensive than EaaS as some of the pricing is through per request basis.
EaaS Advantages over MaaS
Ease of use: EaaS is typically much easier to use than MaaS. This is because embeddings are simpler to use than models as you can plug the embeddings to your applications right away and does not require any deployment and other types of infrastructure/maintenance that you need to do with Models.
Cost: EaaS is typically more cost-effective than MaaS. This is because embeddings are a simpler data format, and they require less computing power to use.
No lock-in: EaaS gives embeddings as a service and because of that you do not need to use the rest of the ecosystem that EaaS is built. This means that you are not locked into a larger infrastructure and maintenance of that infrastructure. This can give you the flexibility to switch EaaS provider to another company if you are not satisfied with the service or if you find a better option.
MaaS Advantages over EaaS
Accuracy: MaaS models can be more accurate than EaaS embeddings. This is because MaaS models are typically trained on larger datasets and has a higher model accuracy than a model that has been trained for specific task dataset.
Interpretability: MaaS models may be more interpretable than EaaS embeddings. This means that it may be easier to understand how the model makes decisions. This can be important for some applications, such as fraud detection, where it is important to be able to explain why a transaction was flagged as fraudulent.
Transparency: MaaS can be considered more transparent than EaaS . This means that you may be able to get more information about how the model was trained and how it makes decisions. This can be important for some applications, such as healthcare, where it is important to be able to trust the models that are being used.
Time to market: MaaS can help you get your machine learning project to market faster. This is because you don't need to spend time and resources on training your own model. You can simply use a pre-trained model off-shelf and get started a good model accuracy and performance.
Scalability: MaaS can help you scale your machine learning project as your needs grow. This is because they have the infrastructure and resources to support large-scale deployments.
Up-to-date models: MaaS is constantly updating their models with the latest data and algorithms. This means that you can be sure that you are using the most accurate and up-to-date models available.
No need to manage infrastructure: MaaS handles all of the infrastructure requirements for you. This means that you don't need to worry about setting up and maintaining servers or managing cloud computing resources.
Pay-as-you-go pricing: MaaS providers typically offer pay-as-you-go pricing. This means that you only pay for the resources that you use. This can save you money if you only need to use machine learning for a short period of time.
Ease of use: MaaS providers typically make it easy to get started. They typically have a user-friendly interface and they offer documentation and support. This can make it easy for businesses to get started with machine learning even if they do not have a lot of experience.
Wide range of models: MaaS providers typically offer a wide range of models. This means that you can find a model that is right for your specific needs. This can save you time and effort in the model selection process.
For recommendation use cases:
Real-time recommendations: MaaS can provide real-time recommendations, which means that users can see recommendations as soon as they interact with the system. This can improve the user experience and make it more likely that users will click on the recommendations.
Personalized recommendations: MaaS can personalize recommendations, which means that the recommendations are tailored to the individual user's interests. This can improve the relevance of the recommendations and make it more likely that users will find something that they like.
Contextual recommendations: MaaS can provide contextual recommendations, which means that the recommendations are tailored to the user's current context. For example, if a user is browsing a website for shoes, the recommendations might be for shoes that are similar to the ones that the user is currently looking at.
Continuous learning: MaaS models can continuously learn from the data that they collect. This means that the downstream tasks/recommendations can be improved over time as the provider learns more about the users' preferences and item understandings. This would allow continuous learning and all of the downstream tasks and applications can benefit from the continuous learning as time goes by since upstream model is going to be refreshed on an ongoing basis.
Embedding as a Service Examples
Google Cloud Embedding API: This API provides access to pre-trained embeddings for a variety of tasks, such as natural language processing (NLP), recommendation systems, and search engines. The API can be accessed from here.
Amazon Web Services (AWS) Lex: This service provides a natural language interface for building conversational applications. It uses pre-trained embeddings to help understand user input. The API can be accessed from here.
Azure Cognitive Services: This suite of services provides access to a variety of AI capabilities, including pre-trained embeddings for NLP tasks. The API can be accessed from here.
OpenAI has the folllowing embedding API available with different performance and cost characteristics.
Model As A Service Examples
Google Cloud AutoML Vision: This service provides access to pre-trained models for image classification, object detection, and scene understanding.
Amazon Rekognition: This service provides access to pre-trained models for image and video analysis, including facial recognition, object detection, and scene understanding.
Microsoft Azure Computer Vision: This service provides access to pre-trained models for image and video analysis, including facial recognition, object detection, and scene understanding.
Conclusion
Ok, but how do we make a choice?
Good EaaS Use Case
If you have an application where the embedding layer is a separate layer and can be plugged in right away, EaaS can be an easy way for you to try out the embedding as a service easily. This would also allow you to do plug-in play where you do not have to change the rest of the model serving and training as much depending on the use case.
Good MaaS Use Case
If you have an application that you need to do fine-tune the pre-trained model for your use case because:
You are not satisfied with the original model accuracy and performance
You have a more specific use case where pre-trained model’s prediction task does not satisfy your need completely.
You cannot leverage the embeddings provided by another service or you need to fine-tune the embeddings for your use case significantly.