×
Community Blog Generative AI on Alibaba Cloud - Part 3: MaaS

Generative AI on Alibaba Cloud - Part 3: MaaS

The third part of this three-part series introduces PaaS genAI deployments using Platform for AI (PAI).

By JV Roig

Welcome to part 3 in this series of generative AI deployment approaches on Alibaba Cloud.

In part 1 of this series, we tackled IaaS (Infrastructure as a Service) genAI deployments, using Elastic Compute Service (ECS)

In part 2, we tackled PaaS (Platform as a Service) genAI deployments, using Platform for AI (PAI). Compared to the entire journey in part 1, PAI provided a much easier (and faster!) experience getting a usable generative AI endpoint – and immediately production-grade as well.

Today, we’ll tackle the MaaS (Model as a Service) approach, using Alibaba Cloud Model Studio.

Getting Started with Model Studio

Log in to your Alibaba Cloud web console, and then search for Model Studio. Click the result that appears (Alibaba Cloud Model Studio).

1. Activate Model Studio

If this is your first time, just go ahead and activate Model Studio. Follow the on-screen instructions that will appear when you first enter the Model Studio console.

2. Create API Key

On the upper right-hand corner, hover over the user icon, then click API-KEY in the pop-up menu that appears:

1

Click the Create API Key button:

2

A new API Key will be added to the table. Click View under the Actions column to display the API Key in full in order to copy-paste it to your application or environment variable.

It is good practice to keep your API key secret. If your API key is accidentally leaked (e.g., you left it in public code), you should DELETE that API key and create a new one. 

3. Test a Model through the Console

Go back to the Model Studio home page. Click “Model Gallery” on the left sidebar.

3

The available models will be listed in the Model Gallery. For this example, let’s choose Qwen-Max. Under Qwen-Max, click Try.

4

The Model Experience page will open. You can add another model to try beside Qwen-Max. For this test, choose Qwen-Plus:

5

(Above: Qwen-Max and Qwen-Plus both checked)

Type a message into the chat box and press enter. You’ll see both models answer simultaneously, with Qwen-Max being slower (because it is much bigger) than Qwen-Plus:

6

4. Integrate a Model Studio Model into Your Application through the API

You will need your API key from earlier.

In the Model Gallery page, there is an API Call Example link under each model, which will display sample code to help you use the model in your own applications:

7

At the top right you’ll also see an API Call Documentation button that will open the official API documentation for Model Studio models.

5. Sample Code

Just like that, we’re already ready to start integrating genAI features into our applications through Model Studio.

First, we need to install the Alibaba Cloud Model Studio SDK. We’ll use Python in our example, so let’s install the Alibaba Cloud Model Studio SDK for Python through pip:

pip install dashscope

Here’s sample code I created, also from the samples and documentation directly provided in the Model Studio console:

8

It’s the same inference example we’ve been using since Part 1! And here’s sample output when I run that Python code:

9

As we’d expect by now, our LLM responds like a pirate thanks to our system prompt, and is giving us suggestions for our sailing-based vacation thanks to our question.

Wrap Up

And that’s it! That’s how easy and simple it is to get started with generative AI using Model Studio.

The best part? Everything is immediately production-grade, and performance and scalability isn’t our problem. All of that is handled by Model Studio for us.

And unique to Model Studio, unlike our IaaS and PaaS genAI deployments, we now enjoy per-token billing. Instead of paying a per-hour rate for the instances we deploy in ECS or PAI, we just pay for the actual tokens we consume. For the actual pricing, consult the official documentation here: https://www.alibabacloud.com/help/en/model-studio/developer-reference/billing-for-tongyiqianwen

ABOUT THE AUTHOR: JV is a Senior Solutions Architect in Alibaba Cloud PH, and leads the team's data and generative AI strategy. If you think anything in this article is relevant to some of your current business problems, please reach out to JV at jv.roig@alibaba-inc.com.

1 2 0
Share on

You may also like

Comments

Santhakumar Munuswamy August 26, 2024 at 5:11 am

Thank for sharing

Related Products