﻿# PixArt Sigma caption cleaning: optional dependencies can change the encoded prompt

Preserve PixArt Sigma caption cleaning, tokenizer truncation, and attention masks when comparing environments or caching text conditions for image generation.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-pixart-sigma-caption-cleaning-dependency-contract/
Language: en

## Identify the text-conditioning path

The [PixArt Sigma repository](https://github.com/PixArt-alpha/PixArt-sigma) distinguishes its text-conditioning setup from earlier PixArt configurations. A longer supported text sequence is meaningful only if preprocessing and tokenization preserve the intended content. A serving wrapper should not identify conditioning solely by a prompt string. The actual input includes any caption cleanup, tokenizer revision, truncation policy, and attention mask that determine which text representations reach the image transformer.

## Make cleaning dependencies explicit

The [pipeline documentation](https://huggingface.co/docs/diffusers/api/pipelines/pixart_sigma) states that caption cleaning depends on beautifulsoup4 and ftfy; without the required dependencies, embeddings are generated from the raw prompt. Therefore, a requested cleaning setting and a performed cleaning operation can differ across environments. Record the installed preprocessing capability and the actual cleaned text. This is especially important when prompts contain markup, unusual spacing, or text copied from a document rather than a simple manually entered caption.

## Keep truncation and masks with embeddings

The same interface exposes max_sequence_length and positive and negative attention masks for supplied embeddings. A cached tensor without its mask and tokenization context is an incomplete condition. Inspect whether an important clause near the end survived truncation before interpreting weak adherence as a generation failure. Raising a stored character limit does not establish that more tokens reached the encoder, because characters and tokenizer tokens are different units and preprocessing can change both.

## Diagnose an environment-dependent result

Imagine moving a pipeline from an author's workstation to a minimal container. The weights and visible prompt match, but the container omits a caption-cleaning dependency. Compare actual text entering the tokenizer, retained token IDs, and masks before changing sampling parameters. The [published Sigma artifact](https://huggingface.co/PixArt-alpha/PixArt-Sigma-XL-2-1024-MS) identifies the model configuration, but identical artifact identity does not establish identical preprocessing. Preserve the text path so a change in the environment can be explained directly.

## Define a complete cache identity

Key text-conditioning caches by the selected encoder and tokenizer revisions, actual preprocessing behavior, sequence limit, and prompt content. Store masks together with their embeddings and separate the user's original text from the encoded form. Existing guides on [Unicode normalization](/journal/data-guide-unicode-normalization-span-integrity/) and [artifact validation](/journal/safetensors-artifact-validation/) provide background. PixArt Sigma's distinctive reproducibility issue is that optional cleaning dependencies can change model inputs while leaving the visible request and model weights apparently unchanged.
