How Text-to-Image Models Trained on Alternative Compute Solve the Text Rendering Challenge
While diffusion and autoregressive models have significantly advanced AI image generation, accurately rendering text remains a major hurdle. This article explores the challenges of text rendering, particularly for complex characters like Chinese, and discusses the engineering obstacles of training multimodal models on alternative compute platforms outside the mainstream GPU ecosystem. It also covers common text rendering techniques, evaluation metrics for text quality, and provides a pseudocode example for developers to integrate these models via API.
I. The Text Rendering Challenge in AI Image Generation
Image generation technologies based on diffusion models and autoregressive architectures have developed rapidly. The composition, lighting, and texture of generated images are now approaching professional design levels. However, text rendering remains a noticeable weakness. Text within images typically suffers from three types of problems:
- Missing Strokes: Chinese characters have many strokes and complex structures. Models often omit key strokes, resulting in characters that look almost correct but are actually flawed.
- Gibberish Characters: Models may generate non-existent glyphs that look like Chinese characters but cannot be read or pronounced by humans.
- Disordered Sequences: Individual characters might be recognizable, but the overall sequence or line breaks are chaotic, making the sentence unreadable.
The root cause lies in the training approach. Traditional image generation models learn text as regular texture without explicitly modeling the structure and semantics of characters. The information density of Chinese is higher than that of English. In the same sized area, Chinese requires rendering more characters with more complex stroke structures, making the difficulty significantly higher.
II. Challenges of Training Multimodal Models on Alternative Compute
2.1 Implications of Full-Stack Alternative Chip Training
Large model training has long relied on a specific type of high-end GPU software ecosystem. Frameworks, operator libraries, and communication libraries are mostly built around this ecosystem. Completing the training of a large multimodal model on other hardware typically requires solving three categories of engineering problems:
- Operator Adaptation and Precision Alignment: Diffusion models contain many custom operators, such as efficient attention implementations, VAE encoding/decoding, and sampling schedulers. These operators must be reimplemented on the new hardware and aligned with the numerical results of the reference implementation.
- Hybrid Parallel Strategies: Multimodal models have large parameter counts and high training data throughput. Teams must combine data parallelism, tensor parallelism, and pipeline parallelism, which places high demands on interconnect bandwidth and communication libraries.
- Training Stability: Loss spikes and gradient explosions are common during long-term training. Common countermeasures include gradient clipping, mixed precision strategy tuning, and checkpoint-based resume training.
For enterprise users, having the compute infrastructure and model capabilities locally means stronger control over data retention, cost, and supply chain. However, the specific degree of “full-stack autonomy” depends on the actual composition of each component. Readers should refer to the technical reports published by the model providers and should not directly accept purely marketing claims.
2.2 Common Approaches to Text Rendering
The industry has explored text rendering mainly through the following paths:
- Explicit Text Condition Injection: In addition to semantic-level text encoders, character-oriented encoders are introduced so the model directly receives the character sequence to be rendered.
- Character-Level Supervision Signals: Constructing a large number of aligned image-text samples and annotating the locations and content of text regions. This allows the model to learn strokes, radicals, and structural layouts during training.
- Multi-Resolution Rendering: Small-sized text is highly sensitive to resolution. A common practice is to perform fine-grained generation on a high-resolution branch.
- Post-Processing Correction: After generation, an OCR model reads the text regions, and local areas are redrawn if errors are detected.
The specific structures of various models differ. To understand which method a particular model uses, one should consult the corresponding paper or technical documentation.
III. How to Evaluate Text Rendering Quality
The following metrics are commonly used to evaluate the text capabilities of AI image generation.
| Metric | Calculation | Direction | Applicable Scenarios | Limitations |
|---|---|---|---|---|
| Word Accuracy | Proportion of OCR recognition results that exactly match the target text | Higher is better, 0 to 1 | Scenarios requiring exact whole-word matches like titles or short phrases | A single incorrect character marks the whole word as wrong; insensitive to “almost correct” results |
| NED (Normalized Edit Distance) | Edit distance divided by the length of the longer string | Lower is better, 0 means exact match | Long text, multi-line text | Need to clarify whether a “1 minus NED” similarity metric was used |
| Character-level Accuracy | Character-by-character comparison, counting the proportion of correct characters | Higher is better | Chinese scenarios, especially content with rare characters | Does not consider character order and line breaks |
| Layout Consistency | Evaluates the reasonableness of line breaks, line spacing, and character spacing | No unified formula, mostly manual scoring or layout detection | Long infographics, handwritten-style posters | Highly subjective, difficult to compare across teams |
There are two points to note. First, evaluation results depend on the OCR engine. When the OCR itself misreads, the image generation model might be falsely judged as a failure, or vice versa. When reporting results, the OCR engine and version used should be clearly stated. Second, Word Accuracy and NED complement each other. The former measures “whether it can be written completely correctly,” while the latter measures “how far it is from being correct.” Reporting only one will omit important information.
IV. Developer Integration (Pseudocode Example)
The code below only demonstrates the invocation process. The API endpoint, parameter names, and authentication method must be based on the official documentation of the service provider. No real addresses or keys are included in the example.
# Pseudocode: Only demonstrates the invocation flow.# API endpoint, parameter names, and authentication method are subject to the official documentation.import osimport timeimport requestsAPI_BASE_URL = os.environ["IMAGE_API_BASE_URL"] # Read from environment variables, not hardcodedAPI_KEY = os.environ["IMAGE_API_KEY"]def generate_image(prompt, max_retries=3, timeout=60):headers = {"Authorization": f"Bearer {API_KEY}"} # Authentication method subject to official docspayload = {"prompt": prompt, "size": "1024x1024"} # Parameter names subject to official docsfor attempt in range(1, max_retries + 1):try:response = requests.post(API_BASE_URL, json=payload, headers=headers, timeout=timeout)response.raise_for_status()return response.json()except requests.exceptions.RequestException as e:if attempt == max_retries:raisetime.sleep(2 ** attempt)
