Best Practices for Custom Model Tuning, Deployment, and Evaluation

更新时间:
复制 MD 格式

To align large language model (LLM) capabilities more closely with your business needs, this topic walks you through best practices for creating custom models in Alibaba Cloud Model Studio. Even without deep technical knowledge of LLMs, you can follow these steps to build an effective custom model and easily add LLM capabilities to your business scenarios.

Overview of Custom Models

A custom large language model is an LLM built on a general-purpose foundation model and fine-tuned or trained to better serve specific domains or tasks.

Why choose a custom model?

  1. Improve accuracy in specific domains: General-purpose LLMs are powerful but may underperform on domain-specific tasks due to limited domain knowledge. Custom LLMs, retrained on domain-specific data, significantly improve performance and accuracy in that domain.

  2. Increase model applicability: You can fine-tune custom LLMs to match the requirements of specific application scenarios. For example, in customer service, a custom model can better understand and respond to customer questions—improving satisfaction.

  3. Save development time and cost: Customizing an existing LLM is faster and less expensive than building one from scratch. You can deploy your custom model quickly to meet business needs.

Workflow for Creating a Custom Model

Creating a custom model involves three main steps: Model Fine-tuning, Deployments, and Evaluation. It also includes three supporting steps: training data preparation, evaluation template design, and training strategy adjustment.

  1. Model Fine-tuning phase: The model “learns” language patterns from large volumes of training data to understand and generate natural language. Before starting model tuning, prepare your training data by collecting, cleaning, and splitting it into training and validation sets. Then use the Train New Model wizard to configure Model Fine-tuning. Alibaba Cloud Model Studio automatically trains your selected prebuilt model using the hyperparameters you set—such as learning rate and number of iterations. In most cases, training runs automatically with no further action needed.

  2. Deployments phase: Deploy your custom model to a dedicated instance, then invoke or evaluate it. Use the Deploy New Model wizard to configure Deployments. Alibaba Cloud Model Studio calculates an estimated price based on your selected model specifications and resource configuration. After you confirm the price, deployment starts automatically—usually with no intervention required. Once complete, you can configure your custom model in code or evaluation tools.

  3. Evaluation phase: Evaluate your deployed custom model. Use the Create Evaluation Task wizard to configure Evaluation. Custom models do not require evaluation template design. Alibaba Cloud Model Studio automatically runs the evaluation based on your selected method, data, and dimensions—typically with no intervention needed.

Note

If you’re not satisfied with the evaluation results, adjust your training strategy—such as choosing a different prebuilt model as the base model, expanding your training dataset, or changing hyperparameter settings—then repeat training, deployment, and evaluation. Repeat the full workflow until results meet your expectations.

Note

In Alibaba Cloud Model Studio, a tuned model must be deployed before you can invoke or evaluate it. So deploy your model first, then proceed to evaluation.

image

Prerequisites

Background knowledge

You may benefit from understanding basic concepts in machine learning, deep learning, and natural language processing. If you’re unfamiliar with them, you can still follow this guide to complete the entire process.

Tools and resources

You need an active account for the Alibaba Cloud Model Studio platform and sufficient account balance to create custom models.

Billing information

Creating a custom model may incur charges for model tuning, model deployment, and model evaluation. For details, see Billing items.

Prepare Training Data

Before training begins, prepare your training data. This includes collecting representative business data from your target scenario and converting it into question-and-answer pairs (data collection); uploading training, evaluation, and validation data (data upload); and using Alibaba Cloud Model Studio’s data cleaning and data augmentation tools to improve data quality.

1. Collect data

Gather high-value business data from various sources and organize it into a structured format. When collecting data, consider these strategies:

  • Diversify sources: Collect data from books, academic papers, news articles, and professional websites. This helps your model handle diverse questions and phrasings.

  • Control quality: Data quality directly affects model quality. High-quality, abundant data helps your model learn better and perform well.

  • Maintain balance: Ensure even distribution across question types, difficulty levels, and answer formats. This prevents bias toward any single data type during training.

In Alibaba Cloud Model Studio, format your collected data as ChatML-style messages in a multi-turn structure (jsonl file) so the platform can parse and train on it. For format details, see the data format section in the model tuning introduction. To maximize training efficiency, prepare at least 500 training samples. Follow these guidelines:

  • Split long text: Break long documents into smaller segments. Each training sample should focus on a single, clear topic to help the model learn effectively.

  • Remove sensitive content: Strip out personally identifiable information, sensitive words, or inappropriate material to ensure compliance and security.

Note

Tip: Collecting data for chatbots

Suppose you want to build a smart chatbot that answers customer questions.

Your goal in data collection is to gather learning material for the chatbot.

Sources:

  • User chat logs: For example, live chat transcripts from your website.

  • FAQ documents: Common questions and answers listed on your company website.

  • Customer service emails: Questions from customers and replies from your support team.

Sample data:

  • User chat logs: Export chat records from your live chat system, including customer questions and agent replies. Example:

    Customer: What is your return policy?
    Agent: Our return policy allows unconditional returns within 30 days of purchase.
  • FAQ documents: Gather common questions and answers from your website. Example:

    Q: How do I change my password?
    A: Click Settings, then select Change Password.
  • Customer service emails: Export email exchanges between customers and your team. Example:

    Customer email: I haven’t received my order. What should I do?
    Agent reply: We’re sorry. Please provide your order number, and we’ll resolve this right away.

Data orchestration:

Prompt

Completion

What is your return policy?

Our return policy allows unconditional returns within 30 days of purchase.

How do I change my password?

Click Settings, then select Change Password.

I haven’t received my order. What should I do?

We’re sorry. Please provide your order number, and we’ll resolve this right away.

2. Upload data

Upload your prepared data to Alibaba Cloud Model Studio for cleaning, augmentation, or direct use in model tuning. The platform automatically checks formatting and performs basic data quality validation to ensure your data meets training requirements.

Alibaba Cloud Model Studio supports multiple dataset types—including training and evaluation datasets—and offers multi-version data management. After publishing, you can use datasets in model tuning or evaluation. Built-in tools let you tag, filter, and manage versions—supporting iterative training and performance tracking.

Procedure

  1. Go to the Data Management page. This shows all uploaded datasets. From here, you can manage them—including View, Export, Publish, and Delete.

  2. Click Add Dataset and fill in the form below to create a Training Set and an Evaluation Set:

    1. Dataset Name: A descriptive name for your dataset. Create it as needed.

    2. Dataset Type: Choose either Training Set or Evaluation Set. You can select only one type per dataset. A Training Set contains one or more rounds of Prompt+Completion data. An Evaluation Set contains only Prompt data. Create both separately.

    3. Storage Location: Defaults to Platform OSS Storage.

    4. Import Method: Defaults to Upload Local File.

    5. Data import: Upload your training data by opening your file browser or dragging files into the upload area. Alibaba Cloud Model Studio supports batch uploads—up to 10 files at once—and provides templates for common data formats.

    6. After confirming your settings, click Confirm to finish configuring the upload.

  3. Alibaba Cloud Model Studio automatically completes the upload. After upload finishes, click Publish. Only published datasets can be used for training.

Note

Tip: Iterate and improve

Data preparation is iterative. Your initial dataset does not need to be perfect. As you tune your model, refine and expand your data based on training feedback to gradually improve model performance.

3. Clean and augment data (Optional)

Data cleaning checks and fixes collected data to ensure quality, completeness, and consistency. This step greatly improves training effectiveness and prediction capability. Data augmentation increases diversity and expands the scale of your training data.

Alibaba Cloud Model Studio supports versioned data management. Each time you clean or augment data, a new version is created automatically. The new version is saved separately and does not overwrite your source data.

Important

Skip this step if your data type is unsuitable for cleaning or augmentation—such as legal documents, medical records, literary works, dialect collections, user reviews, or technical manuals.

Clean your data before augmenting it. This ensures augmentation happens on clean, high-quality data—and avoids amplifying errors or noise in low-quality data.

Data Cleansing procedure

  1. Go to the Data Management page and select the Data Flow tab.

  2. In the Data Flows tab, click Create Data Flow to create and publish a data cleansing data flow.

  3. If you already have data ready for cleaning, go to the Tasks tab and click Create Task from Data Flow List. Select your published data cleansing data flow and fill in the following fields to create a cleaning task:

    1. Task Name: A descriptive name for your cleaning task. Create it as needed.

    2. Data Source: Defaults to Model Data. Here, select the dataset (and version) you want to clean—and manage your existing datasets.

    3. Task Template Preview: Preview the configuration of your selected data flow. To edit it, click Manage.

  4. Click Created. The cleaning task starts automatically. Check its status in the Tasks tab. After completion, Alibaba Cloud Model Studio creates a new dataset version. Be sure to use the correct version when working with your data.

  5. After the cleaning task ends, go to the Tasks tab. Click Actions next to your cleaning task, then click Results to view detailed cleaning results.

Data Augmentation procedure

  1. Go to the Data Management page and select the Data Flow tab.

  2. In the Data Flows tab, click Create Data Flow to create and publish a data enhancement data flow.

  3. If you already have data ready for augmentation, go to the Tasks tab and click Create Task from Data Flow List. Select your published data augmentation data flow and fill in the following fields to create an augmentation task:

    1. Task Name: A descriptive name for your augmentation task. Create it as needed.

    2. Data Source: Defaults to Model Data. Here, select the dataset (and version) you want to augment—and manage your existing datasets.

    3. Task Template Preview: Preview the configuration of your selected data flow. To edit it, click Manage.

  4. Click Created. The augmentation task starts automatically. Check its status in the Tasks tab. After completion, Alibaba Cloud Model Studio creates a new dataset version. Be sure to use the correct version when working with your data.

  5. After the augmentation task ends, go to the Tasks tab. Click Actions next to your augmentation task, then click Results to view detailed augmentation results.

Note

Tip: Precision and diversity

Data cleaning and data augmentation are key to improving data quality and diversity. To make both steps effective and reasonable, follow these recommendations:

  • Clean in stages: Perform cleaning in phases—each targeting one operation, such as removing duplicates or handling missing values. This makes it easier to detect and fix errors—and improves data cleanliness and consistency.

  • Verify cleaning results: After each cleaning step, sample your data to ensure integrity and authenticity remain intact.

  • Keep tasks relevant: During augmentation, ensure generated data closely matches your target task. Avoid irrelevant variants—and preserve context and semantics.

  • Use diverse strategies: Apply multiple augmentation techniques—such as synonym replacement, random sampling, and translation—to maximize data diversity. This improves model generalization.

  • Balance augmentation: Ensure augmented data stays balanced across categories, difficulty levels, and structures. This prevents overfitting—and keeps data distributions realistic.

Model Tuning

After preparing your training data, start model tuning. Model tuning means training a model using your training and validation datasets.

Alibaba Cloud Model Studio supports fine-tuning and lets you adjust many parameters to optimize results for your business needs. Below are instructions for creating new and linked training tasks:

Create a new training task

On the Model Tuning page, click Create Training Task to set training parameters. Follow these steps:

  1. Go to the Model Tuning page. This shows all tuning tasks.

  2. Click Create Training Task. Alibaba Cloud Model Studio guides you through parameter configuration:

    1. Select a model training method: Alibaba Cloud Model Studio supports three methods: Supervised Fine-tuning (SFT), Direct Preference Optimization (DPO), and Continued Pre-training (CPT). Choose based on your needs:

      Training method

      Key features

      Best for

      SFT fine-tuning

      Supervised fine-tuning that improves instruction-following ability. Supports full-parameter and efficient training.

      When your model must master domain-specific Q&A or fixed-format outputs.

      DPO preference training

      Uses negative feedback to reduce hallucinations and align outputs with human preferences.

      When output quality and factual accuracy are critical.

      CPT continued training

      Unsupervised continued pre-training on unlabeled data to strengthen or add domain-specific capabilities.

      You need to build a model for a professional domain to equip it with expert-level knowledge.

    2. Select Model: Alibaba Cloud Model Studio supports tuning based on prebuilt or custom models.

      If this is your first model training, choose a prebuilt model. If you’ve adjusted your training strategy and want to retrain from an existing model, choose a custom model.

      Alibaba Cloud Model Studio offers many tunable prebuilt models. See Model invocation for model details.

    3. Training Method: Alibaba Cloud Model Studio supports Full Parameter Training and Efficient Training. Choose based on your needs:

      Training method

      Pros

      Cons

      Full-parameter training

      • Maximum flexibility: Adjusts all parameters to adapt to new data and tasks.

      • High performance: Can achieve top performance because all parameters are optimized for your task.

      • Time-intensive: Takes longer—especially on large datasets.

      • Risk of overfitting: May overfit if training data is insufficient or imbalanced.

      Efficient training

      • Faster training: Ideal for rapid iteration and prototyping.

      • Lower overfitting risk: Fine-tunes only part of the model.

      • Potentially lower performance: May lag behind full-parameter training on some tasks.

      • Limited scope: May fail to transfer knowledge effectively if your task differs greatly from the pretraining task.

      Efficient training balances speed and results well. We recommend it for most use cases.

    4. Select Training Data: Choose the dataset to use for training. Pick a training set from your uploaded list.

      Note

      If you cleaned or augmented your data, double-check the dataset name and version to avoid selecting raw, unprocessed data.

    5. Select Validation Data: Choose the dataset to validate training performance. You can pick Automatic Splitting or select a Select Validation Set from your list.

      If you have not prepared a validation set, we recommend selecting Automatic Splitting. Alibaba Cloud Model Studio will split a portion of the selected training set to use as the validation set. Conversely, we recommend selecting a validation set from the data list.Select Validation Set.

      Note

      If you cleaned or augmented your data, double-check the dataset name and version to avoid selecting raw, unprocessed data.

    6. Mixed Training: To preserve base model capabilities and boost training results, Alibaba Cloud Model Studio lets you mix your own training data with prebuilt generic data. Adjust the ratio between your data and the prebuilt data. Set all prebuilt data ratios to zero to skip prebuilt data entirely.

    7. Configure hyperparameters: Hyperparameters strongly influence tuning results. Configure them based on your experience—or use Alibaba Cloud Model Studio’s default settings, which are based on extensive testing.

    8. Start Training: This screen shows all your settings. Alibaba Cloud Model Studio calculates an estimated training cost (you can also view cost details later in the training task list—the final bill reflects actual usage). Confirm your settings and price before starting.

  3. After training starts, check progress, estimated costs, and other actions in the Model Fine-tuning list. For billing details, see Billing items.

Note

Tip: Getting started with model training

If you’re new to LLM training, try these simple, practical tips to get started and improve results:

  • Optimize learning rate:

    • Simple explanation: Learning rate controls how far the model adjusts in each step. Start from the platform-recommended defaults (around 1e-4 for efficient training, and around 1e-5 for full-parameter or CPT training), then adjust based on training results.

    • How to adjust: If validation performance stalls, try adjusting the learning rate—often scaling up or down by 10× works well.

  • Choose the right batch size:

    • Simple explanation: Batch size is the number of samples used to update the model in each step. Larger batches often speed up training.

    • Recommended: Common batch sizes are 8, 16, or 32. Default is 16.

  • Monitor loss and accuracy:

    • Simple explanation: Loss measures error on training data. Accuracy measures performance. If loss drops and accuracy rises, training is going well.

    • How to monitor: Go to the training task details page to watch real-time loss and accuracy changes. Validation loss helps decide whether to adjust hyperparameters.

  • Try simple data augmentation:

    • Simple explanation: Augmentation adds diversity and improves generalization—e.g., synonym replacement or random masking.

    • How to apply: Add synonym replacement or other text enhancements during preprocessing.

Manage training tasks

After launching training, your new task appears in the Model Tuning list with status Training. Click View to open the task details page and review settings and metrics. Click View Estimation to see estimated costs. Click Terminate Training anytime to stop the task.

Three key metrics reflect training effectiveness. If you’re unfamiliar with them, wait until training finishes and use Alibaba Cloud Model Studio’s model evaluation tool instead.

Metric

Description

Training Loss

Measures how well the model fits the training data. The curve usually trends downward. Lower loss means better fit—but too-low loss risks overfitting. Judge based on your training behavior.

Validation Loss

Measures how well the model fits the validation set. The curve usually falls, then rises. Lower loss means better fit. Peak performance often occurs at the lowest Validation Loss point.

Validation Token Accuracy

Measures accuracy on the validation set. The curve usually trends upward—then drops if overfitting occurs. Peak performance often occurs at the highest Validation Token Accuracy point.

Training typically takes 2–3 hours for datasets under 1,000 samples. Due to platform capacity limits, tasks may queue. When training finishes, the status changes to Trained.. You now have a Custom Model ready for deployment. Click Deployments to go straight to the deployment page.

Model Deployment

After you get a Custom Model, deploy it to computing resources before invoking it.

Alibaba Cloud Model Studio provides various resource configuration methods. You can select them as needed. To evaluate the training performance of a model, you must first deploy a Custom Model and then use Evaluation to assess the training performance of the Custom Model.

Create a new deployment task

  1. Go to the Model Deployment page. Or, after training finishes on the Model Fine-tuning page, click Deployments. This page shows all deployment tasks.

  2. Click Deploy New Model and follow the wizard:

    1. Select Model: Alibaba Cloud Model Studio offers two deployable model types. Choose your previously trained Custom Model.

    2. Select billing method: Alibaba Cloud Model Studio offers two billing methods. Subscription means buying compute resources monthly. Different Monthly Resources versions offer different deployment capacities. Pay-as-you-go means paying only for actual usage time. You can buy a set number of instances—or adjust that number later. To run Evaluation and assess training results, we recommend Pay-as-you-go.

    3. Deploy: This screen shows all your settings and estimated costs. Confirm everything before starting.

  3. After deployment starts, check progress, estimated costs, and other actions in the Deployments list. For billing details, see Billing items.

Deployment usually takes minutes to hours. Due to Alibaba Cloud Model Studio resource limits, tasks may queue. When done, the status changes to Running. Running models can be invoked—for evaluation or application use.

Note

Tip: Instance management and performance optimization

What is an instance?

  • Simple definition: An instance is an independent computing unit that runs your model and processes requests—such as a server, GPU, or container in a containerized environment.

  • Instance purpose: Instances load your model into memory, accept user requests, run inference tasks (like text generation or classification), and return results.

How instance count affects performance:

  • Response time: More instances spread the load—reducing per-instance request time and improving overall response speed.

  • Concurrent processing: More instances handle more requests in parallel—boosting system concurrency.

  • Cost-effectiveness: More instances improve performance and user experience—but raise costs. Balance carefully.

Manage deployment tasks

After launching deployment, your new task appears in the Model Deployment list with status Deploying. Click View to review settings. Click Scaling to adjust compute resource usage. Click Deactivate anytime to end deployment.

After deployment finishes, the status changes to Running. Your custom model can now run inference. Click Try Now to test inference on the Playground page. Then use Evaluation to assess your custom model.

Model Evaluation

After you complete Deployments, you can evaluate your model's performance in Evaluation. For the Custom Model described in this topic, Alibaba Cloud Model Studio provides Baseline Evaluation. Baseline Evaluation includes preconfigured capability evaluation sets and evaluation scripts that automatically assess multiple basic model capabilities.

Create a new evaluation task

  1. Go to the Model Evaluation page. This shows all Evaluation tasks.

  2. Click Create Evaluation Task and follow the wizard:

    1. Evaluation Method: Alibaba Cloud Model Studio offers several methods. For custom models, choose baseline evaluation.

    2. Select Model: Choose your deployed target model from the dropdown.

    3. Select evaluation data: Alibaba Cloud Model Studio includes baseline evaluation datasets—such as C-Eval and CMMLU—to automatically test fundamental model capabilities. Choose any dataset to build your full evaluation set.

    4. Evaluate: This screen shows all your settings and estimated costs. Confirm everything before starting.

  3. After evaluation starts, check progress, estimated costs, and other actions in the Evaluation list. For billing details, see Billing items.

Manage evaluation tasks

When evaluation starts, its status becomes Running or Queuing. Click Abort anytime to stop it. After completion, click Results to view detailed results. Click Delete to remove an evaluation task.

What to do next

This topic covers the full lifecycle management of custom model tuning, deployment, and evaluation. After reading it, you can build and invoke a custom model in your business scenarios.

To integrate your custom model into a custom application in Alibaba Cloud Model Studio, see Application types to choose and build your app.

For all billing details covered in this topic, see Product billing.