sdxl-qwen-phase1-cache
收藏资源简介:
SDXL + Qwen3.5 Phase-1 Conditioning Cache 是一个预计算的、冻结编码器条件数据集,专为 SDXL 与 Qwen 整流流微调任务设计。其核心目的是通过一次性预计算昂贵的编码过程,为下游训练器提供所有必要的数组数据,避免重复编码开销,从而实现跨运行和项目的可重用性。数据集基于源数据集 AbstractPhil/sdxl-qwen-phase0(包含标题、图像和 aleph 地址)构建,规模在1万到10万样本之间(10K<n<100K)。数据内容以每行一个图像/标题对的形式组织,包含多个字段,如行标识符、原始标题、增强重描述文本、序列长度、潜在表示、交叉注意力上下文、池化输出、Qwen模型向量等。数据集适用于文本到图像生成任务,特别是基于 SDXL 和 Qwen 模型的微调与实验,支持多种使用方式,如复现标准条件、替换部分条件或添加锚点。数据以 Parquet 文件分片存储(使用 zstd 压缩),并附有详细的解码说明和元数据。需要注意的是,数据集是 SDXL(基于 CreativeML OpenRAIL++-M 许可证)和 Qwen3.5 输出的派生表示,下游使用需遵守上游模型和数据的许可证。
SDXL + Qwen3.5 Phase-1 Conditioning Cache is a pre-computed, frozen encoder conditioning dataset designed for SDXL and Qwen rectified-flow fine-tuning tasks. Its core purpose is to pre-compute expensive encoding processes once, providing all necessary array data for downstream trainers, avoiding repetitive encoding overhead, and enabling reusability across runs and projects. The dataset is built on the source dataset AbstractPhil/sdxl-qwen-phase0 (containing captions, images, and aleph addresses), with a scale between 10,000 and 100,000 samples (10K<n<100K). The data is organized as one image/caption pair per row, including fields such as row identifier, original caption, enhanced re-description text, sequence length, latent representation, cross-attention contexts, pooled outputs, Qwen model vectors, and more. It is suitable for text-to-image generation tasks, particularly fine-tuning and experiments with SDXL and Qwen models, supporting various usage modes like reproducing standard conditions, replacing partial conditions, or adding anchor points. The data is stored in sharded Parquet files (compressed with zstd) and includes detailed decoding instructions and metadata (meta.json). Note that the dataset is a derived representation of SDXL (based on the CreativeML OpenRAIL++-M license) and Qwen3.5 outputs, and downstream use must comply with upstream model and data licenses.
数据集概述
数据集名称: SDXL + Qwen3.5 Phase-1 Conditioning Cache
许可证: Apache-2.0(注意:数据集为派生表示,下游使用需遵守上游模型/数据许可)
语言: 英语
任务类别: 文本到图像生成(Text-to-Image)
数据规模: 10K < n < 100K 条样本
数据文件格式: Parquet(分片存储,每片 256 行,Zstd 压缩)
发布者: AbstractPhil
数据集目的与背景
本数据集为 SDXL + Qwen3.5 修正流(Rectified Flow)微调 提供 预计算、冻结编码器条件向量。核心目标是将昂贵的编码过程(VAE、CLIP、Qwen)一次性完成,使下游训练器可直接复用,避免重复计算。
- 数据来源:
AbstractPhil/sdxl-qwen-phase0(包含原始图像、描述文本和 aleph 地址) - 图像尺寸: 1024×1024 → 潜在表示形状
[4, 128, 128] - VAE 缩放因子:
0.13025(已应用于lat列) - 编码器(冻结): SDXL VAE + CLIP-L(
text_encoder)+ CLIP-G(text_encoder_2)+ Qwen3.5-0.8B
数据模式(Schema)
每条样本对应一个图像/文本对。数组列以 原始小端 float16 字节 存储在 Parquet 的 binary 列中,需通过指定形状解码。文本/整数列为原生类型。
| 列名 | 类型 | 形状 | 来源 | 说明 |
|---|---|---|---|---|
rid |
string |
— | 行 ID | row{global_index:08d} 或源数据集中的 id |
caption |
string |
— | 源数据集 | 原始描述文本 |
gen_text |
string |
— | Qwen 两次生成(Two-shot Greedy) | 经过丰富重述的描述文本(实际编码对象) |
seq_len |
int32 |
— | Qwen | qseq 中非填充的真实 token 数量 |
lat |
fp16 |
[4, 128, 128] |
SDXL VAE 编码(fp32 执行) | 已乘以 vae_scale=0.13025 |
clipl |
fp16 |
[77, 768] |
SDXL CLIP-L,倒数第二层隐藏状态 | 交叉注意力上下文第一部分 |
clipg |
fp16 |
[77, 1280] |
SDXL CLIP-G,倒数第二层隐藏状态 | 交叉注意力上下文第二部分 |
clipgp |
fp16 |
[1280] |
SDXL CLIP-G 池化向量 | 微条件输入(text_embeds) |
qpool |
fp16 |
[1024] |
Qwen 最后一层的最后一个 token 池化 | 与训练器的池化缓存完全一致 |
qseq |
fp16 |
[512, 1024] |
Qwen 完整最后一层隐藏状态 | 左填充,真实 token 位于尾部 |
addr |
fp16 |
[32, 128] |
从源数据集直接传递 | geolip aleph 符号投影地址 |
qseq 解码提示: 真实 token 位于序列末尾,可通过 qseq[512 - seq_len:] 提取。实际长度较短(约 50–100 tokens),因此填充部分多为零,Zstd 压缩后占用空间小。
条件向量组合方式(适用于 SDXL 训练)
标准 SDXL 文本条件为:concat(clipl, clipg) → [77, 2048] 作为交叉注意力上下文,clipgp [1280] 融入时间步嵌入。本数据集将这些组件分开存储,并额外提供 Qwen 池化/序列向量和 aleph 地址,支持三种使用方式:
- 复现标准 SDXL 条件: 直接使用
clipl、clipg、clipgp - 替换组件: 例如,将 CLIP-G 池化替换为
qpool(对应 geolip 程序aleph_clipl_clipg_pooled) - 扩展条件: 将 aleph 地址
addr[32,128]拼接到交叉注意力上下文中
本数据集捕获时使用的训练配方为 aleph_clipl_clipg_pooled(CLIP-L 序列被交换,CLIP-G 序列保留真实值,CLIP-G 池化替换为 Qwen 池化,aleph 地址启用)。但捕获结果本身与配方无关,组合方式由训练器决定。
数据提取细节
- Qwen 文本特征 (
qpool,qseq,gen_text,seq_len): 每个原始描述先经过 Qwen 两次生成(greedy,max_new_tokens=64)得到丰富描述gen_text,然后包裹在对话模板中,以左填充方式分词(max_length=1024),执行前向传播获取完整隐藏状态。qseq取最后一个解码器层(layer −1)的隐藏状态,qpool为该层最后一个真实 token 的池化结果。由于池化读取最后的真实 token 且填充在左侧,qpool与训练器自行计算的结果完全一致。 - SDXL 潜在表示 (
lat): 图像缩放/中心裁剪至 1024×1024,归一化至[-1, 1],由 SDXL VAE 在 fp32 精度下编码,再乘以vae_scale=0.13025,存储为 fp16。 - SDXL 文本特征 (
clipl,clipg,clipgp): 分别对 77 token 提示进行编码,取倒数第二层隐藏状态(clipl、clipg)和 CLIP-G 池化输出(clipgp)。这些是拼接前的原始编码器输出。 - Aleph 地址 (
addr): 32 个锚点方向 × 128 维的符号投影地址,直接从源数据集传递,不做任何修改。
数据使用与解码示例
解码所有数组中列的标准方法:
python import numpy as np from datasets import load_dataset
SPECS = { "lat": (np.float16, (4, 128, 128)), "clipl": (np.float16, (77, 768)), "clipg": (np.float16, (77, 1280)), "clipgp": (np.float16, (1280,)), "qpool": (np.float16, (1024,)), "qseq": (np.float16, (512, 1024)), "addr": (np.float16, (32, 128)), }
def decode(row, key): dt, shape = SPECS[key] return np.frombuffer(row[key], dtype=dt).reshape(shape).copy()
ds = load_dataset("AbstractPhil/sdxl-qwen-phase1-cache", split="train", streaming=True) row = next(iter(ds))
lat = decode(row, "lat") clipgp = decode(row, "clipgp") qseq = decode(row, "qseq") qtok = qseq[512 - row["seq_len"]:]
转换为训练器 .npy 缓存: 使用 qwen_cache_dataset.py 的 MODE="rehydrate" 将 Parquet 分片展开为训练器所需的每个样本的 .npy 文件布局。映射关系如下:
| 列名 | 训练器文件名 |
|---|---|
lat |
{rid}_lat.npy |
clipl |
{rid}_clipl.npy |
qpool |
{rid}_qpool.npy |
clipg |
{rid}_clipg.npy |
clipgp |
{rid}_clipgp.npy |
addr |
{rid}_addr.npy |
qseq、seq_len、gen_text、caption 不会被基础训练器消费,其中 qseq 用于全序列(Qwen 交叉注意力)条件实验。参考图像(fid_ref/)在展开时从源数据集中拉取,不存储在本数据集中。
数据集结构
data/shard_00000.parquet data/shard_00001.parquet ... meta.json # 机器可读的解码契约(形状、数据类型、Qwen 设置) README.md
复现说明
使用 qwen_cache_dataset.py 的 MODE="prepare" 构建:流式读取源数据集(不解码图像),对每个分片的样本执行一次编码(VAE + CLIP-L + CLIP-G + Qwen,一次前向同时获得池化与序列),写入 data/shard_NNNNN.parquet(Zstd 压缩,每片 256 行),并即时上传至 Hub。构建过程从中断点恢复,确保在长时间编码前验证 512 序列长度覆盖语料库,以及捕获的池化向量与训练器编码器一致。
引用与致谢
本数据集属于 AbstractPhil 的 geolip 几何深度学习生态系统。使用此缓存时,请致谢此仓库。




