multimodal-models

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Multimodal Models

多模态模型

Pre-trained models for vision, audio, and cross-modal tasks.

用于视觉、音频和跨模态任务的预训练模型。

Model Overview

模型概述

ModelModalityTask
CLIPImage + TextZero-shot classification, similarity
WhisperAudio → TextTranscription, translation
Stable DiffusionText → ImageImage generation, editing

模型模态任务
CLIP图像 + 文本零样本分类、相似度计算
Whisper音频 → 文本转录、翻译
Stable Diffusion文本 → 图像图像生成、编辑

CLIP (Vision-Language)

CLIP(视觉-语言模型)

Zero-shot image classification without training on specific labels.
无需针对特定标签训练的零样本图像分类模型。

CLIP Use Cases

CLIP 应用场景

TaskHow
Zero-shot classificationCompare image to text label embeddings
Image searchFind images matching text query
Content moderationClassify against safety categories
Image similarityCompare image embeddings
任务实现方式
零样本分类将图像与文本标签的嵌入向量进行对比
图像搜索查找与文本查询匹配的图像
内容审核针对安全类别进行分类
图像相似度计算对比图像嵌入向量

CLIP Models

CLIP 模型版本

ModelParametersTrade-off
ViT-B/32151MRecommended balance
ViT-L/14428MBest quality, slower
RN50102MFastest, lower quality
模型参数规模权衡点
ViT-B/321.51亿推荐的平衡版本
ViT-L/144.28亿质量最佳,速度较慢
RN501.02亿速度最快,质量较低

CLIP Concepts

CLIP 核心概念

ConceptDescription
Dual encoderSeparate encoders for image and text
Contrastive learningTrained to match image-text pairs
NormalizationAlways normalize embeddings before similarity
Descriptive labelsBetter labels = better zero-shot accuracy
Key concept: CLIP embeds images and text in same space. Classification = find nearest text embedding.
概念说明
双编码器为图像和文本分别配备独立的编码器
对比学习通过匹配图文对进行训练
归一化计算相似度前需先对嵌入向量进行归一化
描述性标签标签越精准,零样本分类准确率越高
核心概念:CLIP 将图像和文本映射到同一向量空间。分类过程即查找最接近的文本嵌入向量。

CLIP Limitations

CLIP 局限性

  • Not for fine-grained classification
  • No spatial understanding (whole image only)
  • May reflect training data biases

  • 不适用于细粒度分类
  • 缺乏空间理解能力(仅能处理整幅图像)
  • 可能反映训练数据中的偏见

Whisper (Speech Recognition)

Whisper(语音识别)

Robust multilingual transcription supporting 99 languages.
支持99种语言的鲁棒性多语言转录模型。

Whisper Use Cases

Whisper 应用场景

TaskConfiguration
TranscriptionDefault
transcribe
task
Translation to English
task="translate"
SubtitlesOutput format SRT/VTT
Word timestamps
word_timestamps=True
任务配置方式
转录默认
transcribe
任务
翻译为英文设置
task="translate"
生成字幕输出格式选择SRT/VTT
单词级时间戳设置
word_timestamps=True

Whisper Models

Whisper 模型版本

ModelSizeSpeedRecommendation
turbo809MFastRecommended
large1550MSlowMaximum quality
small244MMediumGood balance
base74MFastQuick tests
tiny39MFastestPrototyping only
模型规模速度推荐场景
turbo8.09亿推荐使用
large15.5亿追求最高质量
small2.44亿中等平衡质量与速度
base7400万快速测试
tiny3900万最快仅用于原型开发

Whisper Concepts

Whisper 核心概念

ConceptDescription
Language detectionAuto-detects, or specify for speed
Initial promptImproves technical terms accuracy
TimestampsSegment-level or word-level
faster-whisper4× faster alternative implementation
Key concept: Specify language when known—auto-detection adds latency.
概念说明
语言检测自动检测语言,已知语言时手动指定可提升速度
初始提示提升专业术语的识别准确率
时间戳支持段落级或单词级
faster-whisper速度提升4倍的替代实现方案
核心概念:已知语言时手动指定——自动检测会增加延迟。

Whisper Limitations

Whisper 局限性

  • May hallucinate on silence/noise
  • No speaker diarization (who said what)
  • Accuracy degrades on >30 min audio
  • Not suitable for real-time captioning

  • 在静音/噪音环境下可能产生幻觉输出
  • 不支持说话人 diarization(区分说话人)
  • 音频时长超过30分钟时准确率下降
  • 不适用于实时字幕生成

Stable Diffusion (Image Generation)

Stable Diffusion(图像生成)

Text-to-image generation with various control methods.
具备多种控制方式的文本转图像生成模型。

SD Use Cases

SD 应用场景

TaskPipeline
Text-to-image
DiffusionPipeline
Style transfer
Image2Image
Fill regions
Inpainting
Guided generation
ControlNet
Custom stylesLoRA adapters
任务流水线
文本转图像
DiffusionPipeline
风格迁移
Image2Image
区域填充
Inpainting
引导生成
ControlNet
自定义风格LoRA 适配器

SD Models

SD 模型版本

ModelResolutionQuality
SDXL1024×1024Best
SD 1.5512×512Good, faster
SD 2.1768×768Middle ground
模型分辨率质量
SDXL1024×1024最佳
SD 1.5512×512良好,速度更快
SD 2.1768×768折中方案

Key Parameters

关键参数

ParameterEffectTypical Value
num_inference_stepsQuality vs speed20-50
guidance_scalePrompt adherence7-12
negative_promptAvoid artifacts"blurry, low quality"
strength (img2img)How much to change0.5-0.8
seedReproducibilityFixed number
参数作用典型取值
num_inference_steps质量与速度的权衡20-50
guidance_scale对提示词的遵循程度7-12
negative_prompt避免生成瑕疵"模糊、低质量"
strength(img2img)图像修改幅度0.5-0.8
seed结果可复现性固定数值

Control Methods

控制方式

MethodInputUse Case
ControlNetEdge/depth/poseStructural guidance
LoRATrained weightsCustom styles
Img2ImgSource imageStyle transfer
InpaintingImage + maskFill regions
方法输入应用场景
ControlNet边缘/深度/姿态图结构引导生成
LoRA训练后的权重自定义风格
Img2Img源图像风格迁移
Inpainting图像+遮罩区域填充

Memory Optimization

内存优化技巧

TechniqueEffect
CPU offloadReduces VRAM usage
Attention slicingTrades speed for memory
VAE tilingLarge image support
xFormersFaster attention
DPM schedulerFewer steps needed
Key concept: Use SDXL for quality, SD 1.5 for speed. Always use negative prompts.
技巧效果
CPU 卸载降低VRAM占用
注意力切片以速度换内存
VAE 分块支持生成大尺寸图像
xFormers加速注意力计算
DPM 调度器减少所需推理步数
核心概念:追求质量选SDXL,追求速度选SD 1.5。务必使用negative prompt。

SD Limitations

SD 局限性

  • GPU strongly recommended (CPU very slow)
  • Large VRAM requirements for SDXL
  • May generate anatomical errors
  • Prompt engineering matters

  • 强烈推荐使用GPU(CPU运行速度极慢)
  • SDXL 对VRAM要求较高
  • 可能生成解剖结构错误的图像
  • 提示词工程对结果影响较大

Common Patterns

通用模式

Embedding and Similarity

嵌入向量与相似度计算

All three models use embeddings:
  • CLIP: Image/text embeddings for similarity
  • Whisper: Audio embeddings for transcription
  • SD: Text embeddings for image conditioning
这三个模型均使用嵌入向量:
  • CLIP:图像/文本嵌入向量用于相似度计算
  • Whisper:音频嵌入向量用于转录
  • SD:文本嵌入向量用于图像生成条件控制

GPU Acceleration

GPU 加速需求

ModelVRAM Needed
CLIP ViT-B/32~2 GB
Whisper turbo~6 GB
SD 1.5~6 GB
SDXL~10 GB
模型所需VRAM
CLIP ViT-B/32~2GB
Whisper turbo~6GB
SD 1.5~6GB
SDXL~10GB

Best Practices

最佳实践

PracticeWhy
Use recommended model sizesBest quality/speed balance
Cache embeddings (CLIP)Expensive to recompute
Specify language (Whisper)Faster than auto-detect
Use negative prompts (SD)Avoid common artifacts
Set seeds for reproducibilityConsistent results
实践原因
使用推荐的模型规模平衡质量与速度
缓存CLIP的嵌入向量重新计算成本较高
手动指定Whisper的语言比自动检测更快
SD使用negative prompt避免常见瑕疵
设置固定seed获得一致的结果

Resources

资源