LLMs After Reinforcement Learning: Capability Changes and Cloud Deployment Guide

    This guide explores how reinforcement learning post-training alters large language model behavior, detailing improvements in instruction adherence, reasoning, and code generation. It also provides practical advice on evaluating aesthetic and coding tasks, calculating total API costs, and building a robust cloud deployment architecture using Baidu AI Cloud components.

    How Does Reinforcement Learning Post-Training Change Model Behavior?

    Pre-training equips models with extensive language knowledge, but whether the output is stable and follows instructions usually depends on subsequent fine-tuning and alignment. Reinforcement learning (RL) is a common approach for this, including methods like RLHF and RLAIF. During training, the scores provided by the reward model guide the policy model in adjusting its output.

    According to public technical reports, models trained with these methods generally perform better in three aspects. First, they are more sensitive to implicit constraints in instructions, such as formatting requirements, word limits, and tone. Second, intermediate steps during multi-step reasoning are more complete, with some evaluations showing a decrease in error rates. Third, the ranking of some open-source models in comprehensive evaluations has improved, approaching closed-source models in certain dimensions. For specific values, please refer to the evaluation reports from the model developers, as results from different evaluation sets cannot be directly compared.

    How to Handle Visual Understanding and Aesthetic Tasks?

    There are three common scenarios for multimodal models: image content recognition, chart and document parsing, and image-based design suggestions. After reinforcement learning, models provide more specific descriptions of composition, color matching, and layout hierarchy, and their modification suggestions are closer to how designers express themselves.

    Aesthetic judgment is subjective, so model output should be used as auxiliary advice. Before launching, it is recommended to prepare a set of internal samples, ask designers to score the model’s suggestions, and then decide whether to adopt them. UI prototypes, marketing posters, and chart parsing are three types of tasks suitable for small-scale initial trials.

    How to Evaluate Code Generation Capabilities?

    The improvement in code capabilities is mainly reflected in three points: maintaining an understanding of project structure in longer contexts; breaking complex tasks into sub-modules before implementing them step-by-step; and reducing hallucinations when calling framework APIs. These changes are practically helpful for developers, but claims of “significant breakthroughs” lack unified testing criteria.

    For evaluation, it is recommended to use real tasks from your own projects to form a test set, recording the proportion of unit tests passed, the number of lines requiring manual modification, and the average time taken. These metrics reflect business realities better than public leaderboards.

    How to Calculate Total Cost After API Price Reductions?

    Although API pricing for some open-source models has decreased, price cuts are only one part of the cost. The actual total cost includes the following four components:

    1. API Call Fees: Billed based on input and output tokens. Long contexts and image inputs will significantly increase the token count.
    2. Storage and Traffic: Images, logs, and intermediate results saved in object storage require calculating storage capacity and public network traffic.
    3. Private Deployment Compute: If you deploy GPU models yourself, the cost depends on node specifications, utilization, and idle time.
    4. Operations and Troubleshooting: Retries, rate limiting, and alert configurations all require manual maintenance.

    When calculating costs, you can multiply a week’s actual request volume by the unit price, and then add storage and traffic fees. If the number of tokens per request exceeds expectations, the actual cost will be higher than the estimate.

    How to Build a Call Architecture Based on Baidu AI Cloud?

    A stable large model call chain usually consists of the following components:

    1. Qianfan Large Model Platform: Provides the API entry point for large models. Before calling, create an API Key in the console and confirm that the selected model supports image input. The API Key should be stored in environment variables or a key management service, not hard-coded in the source.
    2. Message Queue: Receives inference requests from the frontend and smooths out peak traffic. Consumers pull tasks based on their own processing capacity, preventing traffic spikes from hitting the model interface directly.
    3. Object Storage BOS: Stores user-uploaded images. The queue message only passes a temporary access link for the image, not the image content itself. The validity period of the temporary link should be set to a few minutes, with read-only permissions granted.
    4. Cloud Container Engine CCE: Deploys the consumer service. If you need to privately deploy an open-source model, you can configure elastic scaling for the GPU node pool in CCE. The scaling thresholds need to be determined based on stress testing results; for example, scale up when GPU utilization remains consistently above 70%, and scale down when it drops below 20% for 15 minutes.
    5. Log Service BLS and Cloud Monitor: Records the duration, status code, and token usage of each call, and sets alerts for error rates and latency. Sensitive information such as image content and user identifiers should not be recorded in the logs.

    The following example demonstrates the core logic of the consumer service. The model name is configured via environment variables and should be replaced with a model that supports image input from the console. The receive and acknowledge interfaces of the queue vary by product; they are marked with comments in the example and should be replaced according to your queue product’s documentation in actual use.

    1. import os
    2. import requests
    3. from requests.adapters import HTTPAdapter
    4. from urllib3.util.retry import Retry
    5. QIANFAN_URL = "https://qianfan.baidubce.com/v2/chat/completions"
    6. API_KEY = os.environ["QIANFAN_API_KEY"]
    7. MODEL = os.environ["QIANFAN_VISION_MODEL"]
    8. session = requests.Session()
    9. retry = Retry(
    10. total=3,
    11. backoff_factor=1,
    12. status_forcelist=[429, 500, 502, 503, 504],
    13. allowed_methods=["POST"],
    14. )
    15. session.mount("https://", HTTPAdapter(max_retries=retry))