AI 驱动的内容生成:使用 DeepSeek 生成产品描述

本文介绍我们如何使用 DeepSeek AI 大规模生成产品描述、翻译内容和创建营销文案。

问题:内容创作的规模化挑战

我们有 5,000+ 个产品配置,需要:

  • 产品描述:每个产品 200-300 字

  • Meta 描述:150-160 个字符,用于 SEO

  • 功能亮点:关键功能的要点列表

  • 营销文案:有吸引力的销售语言

手动撰写:

  • 5,000 个产品 × 每个产品 30 分钟 = 2,500 小时(104 天)

  • 一致性:确保所有描述符合品牌语调

  • 更新:产品变更时需要重写

  • 翻译:乘以 10 种语言 = 25,000 小时

手动撰写无法规模化,因此我们使用 AI 来生成这些内容。

解决方案:DeepSeek AI

我们使用 DeepSeek AI 模型来生成内容:

  • 模型:DeepSeek-V3(671B 参数)

  • API:deepseek.com,以 Together.ai 作为备用

  • 成本:每百万输入 token $0.27,每百万输出 token $1.10

  • 速度:约 50 token/秒(每条描述约 10 秒)

按此速率,5,000 条描述约需 14 小时,成本约 $50。

统一的 AI 生成接口

我们构建了一个支持多个提供商的统一接口:

from app.shared.ai_generation import generate_content

description = generate_content(
    prompt="Write a product description for Treo N100 Mini PC",
    provider="deepseek",
    max_tokens=800,
    temperature=0.7,
    system_prompt="You are a technical writer..."
)

支持的提供商:

  • DeepSeek:主要提供商(deepseek.com)

  • Gemini:备用提供商(Google)

  • Together.ai:DeepSeek 备用(如果 deepseek.com 失败)

DeepSeek API 集成

直接 API 调用

我们直接调用 deepseek.com API:

response = requests.post(
    "https://api.deepseek.com/v1/chat/completions",
    headers={
# ... (implementation details omitted)

回退到 Together.ai

如果 deepseek.com 失败,我们会回退到 Together.ai:

response = requests.post(
    "https://api.together.xyz/v1/chat/completions",
    headers={
# ... (implementation details omitted)

备用方案确保在某个提供商宕机时内容生成仍然可用。

为缓存设计的系统提示词

DeepSeek 支持提示词缓存以降低成本:

  • 系统提示词:已缓存(跨请求复用)

  • 用户提示词:不缓存(每个请求唯一)

我们将系统提示词设计为可复用:

system_prompt = """You are a technical writer for Thinvent, a manufacturer of mini PCs, thin clients, and industrial computers.

Write product descriptions that:
# ... (implementation details omitted)

该系统提示词被缓存并复用于所有 5,000 个产品,每次运行可节省约 $40。

缓存命中日志记录

我们记录缓存命中以监控节省情况:

usage = result.get("usage", {})
cache_hits = usage.get("prompt_cache_hit_tokens", 0)
cache_misses = usage.get("prompt_cache_miss_tokens", 0)

if cache_hits > 0:
    logging.info(f"DeepSeek cache HIT: {cache_hits} tokens (miss: {cache_misses})")

示例输出:

DeepSeek cache HIT: 1,200 tokens (miss: 50)
DeepSeek cache HIT: 1,200 tokens (miss: 48)
DeepSeek cache HIT: 1,200 tokens (miss: 52)

这表明系统提示词(1,200 token)已缓存,而用户提示词(50 token)未缓存。

温度设置

我们针对不同用例使用不同的温度值:

产品描述(0.7)

目的:平衡创造力和一致性

description = generate_content(
    prompt=f"Write a description for {product_name}",
    temperature=0.7
)

结果:听起来自然的描述,有一定变化

翻译(1.3)

目的:更具创造性、更自然的翻译

translation = generate_content(
    prompt=f"Translate to {lang}: {text}",
    temperature=1.3
)

结果:更地道、更自然的翻译

技术规格(0.3)

目的:事实性、一致的输出

specs = generate_content(
    prompt=f"List specifications for {product_name}",
    temperature=0.3
)

结果:一致的规格列表

营销文案(1.0)

目的:有创意、引人入胜的内容

copy = generate_content(
    prompt=f"Write marketing copy for {product_name}",
    temperature=1.0
)

结果:有吸引力、多样化的营销语言

用例

1. 产品描述

  • 输入:产品 SKU 和功能

  • 提示词:

Write a product description for:

- Name: Treo N100 Mini PC

- Processor: Intel N100 (4 cores, 3.4GHz)

- RAM: 8GB DDR4

- Storage: 256GB SSD

- Ports: 2× HDMI, 4× USB 3.0, Gigabit Ethernet

- OS: Windows 11 Pro

输出:

The Thinvent Treo N100 Mini PC is a compact powerhouse designed for business and industrial applications. Powered by the Intel N100 processor with 4 cores running at 3.4GHz, it delivers reliable performance for everyday computing tasks.

With 8GB DDR4 RAM and a 256GB SSD, the Treo provides smooth multitasking and fast boot times. The dual HDMI ports support multi-monitor setups, while 4 USB 3.0 ports and Gigabit Ethernet ensure seamless connectivity.

Pre-installed with Windows 11 Pro, the Treo is ready for business use out of the box. Its fanless design ensures silent operation, making it ideal for office environments, digital signage, and industrial automation.

Backed by Thinvent's 3-year warranty and certified to BIS, RoHS, and ISO standards, the Treo N100 Mini PC is built to last.

2. 内容翻译

  • 输入:英文文本和目标语言

  • 提示词:

Translate to Hindi:
"The Thinvent Treo N100 Mini PC is a compact powerhouse designed for business and industrial applications."

输出:

Thinvent Treo N100 मिनी पीसी एक कॉम्पैक्ट पावरहाउस है जो व्यावसायिक और औद्योगिक अनुप्रयोगों के लिए डिज़ाइन किया गया है।

3. Meta 描述

  • 输入:产品名称和关键功能

  • 提示词:

Write a 150-character meta description for:
Treo N100 Mini PC with Intel N100, 8GB RAM, 256GB SSD, Windows 11 Pro

输出:

Compact Treo N100 Mini PC with Intel N100, 8GB RAM, 256GB SSD, Windows 11 Pro. Perfect for business and industrial use. 3-year warranty.

4. 功能亮点

  • 输入:产品功能

  • 提示词:

Write 5 bullet points highlighting key features of:
Treo N100 Mini PC

输出:

• Intel N100 processor (4 cores, 3.4GHz) for reliable performance
• 8GB DDR4 RAM and 256GB SSD for smooth multitasking
• Dual HDMI ports for multi-monitor setups
• Fanless design for silent operation
• Windows 11 Pro pre-installed, ready for business use

批处理

我们批量处理内容以提高效率:

from app.web.models_product_description import ProductDescription

# Queue descriptions for generation
# ... (implementation details omitted)

这允许在后台处理数千条描述。

错误处理

我们优雅地处理 API 故障:

try:
    content = generate_content(prompt, provider="deepseek")
    if content:
# ... (implementation details omitted)

如果生成失败,我们会: 1. 记录错误 2. 返回 None(调用方处理回退) 3. 稍后重试(对于排队的项目)

成本优化

我们通过以下方式优化成本:

1. 提示词缓存

  • 系统提示词:1,200 token × 5,000 个产品 = 6M token

  • 不使用缓存:$0.27 × 6 = $1.62

  • 使用缓存:$0.27 × 0.006 = $0.0016(节省 99.9%)

2. 批处理

在一次 API 调用中处理多个项目:

prompt = "Write descriptions for:\n"
for sku in batch_skus:
    prompt += f"- {sku}\n"

这减少了 API 开销并提高了吞吐量。

3. 温度调优

较低的温度 = 生成的 token 更少:

  • 温度 0.3:每条描述约 200 token

  • 温度 0.7:每条描述约 250 token

  • 温度 1.3:每条描述约 300 token

尽可能使用较低的温度。

性能特征

生成速度:

  • 单条描述:约 10 秒

  • 10 条批量:约 30 秒(每条描述 3 秒)

  • 5,000 条描述:约 14 小时(批处理)

成本:

  • 输入 token:1,200(系统)+ 50(用户)= 1,250 token

  • 输出 token:250 token

  • 每条描述成本:$0.27 × 0.00125 + $1.10 × 0.00025 = $0.00061

  • 5,000 条描述:$3.05

使用缓存后:

  • 输入 token:6(缓存)+ 50(用户)= 56 token

  • 每条描述成本:$0.27 × 0.000056 + $1.10 × 0.00025 = $0.00029

  • 5,000 条描述:$1.45(节省 52%)

与 SEO 流水线的集成

AI 生成的内容与 SEO 流水线集成:

第 9 步:迁移描述

SEO 流水线为所有产品生成描述:

for sku in product_skus:
    description = generate_content(
        prompt=f"Write description for {sku}",
# ... (implementation details omitted)

详见 SEO 流水线概览。

翻译队列

缺失的翻译会被排队并使用 AI 处理:

for item in translation_queue:
    translation = generate_content(
        prompt=f"Translate to {item['lang']}: {item['text']}",
        provider="deepseek",
        temperature=1.3
    )

    translation_manager.set(item['text'], item['lang'], translation)

详见翻译系统。

参考资料

AI 服务

技术概念

相关文章

总结

我们使用 DeepSeek AI 大规模生成内容:

  • 模型:DeepSeek-V3(671B 参数)

  • API:deepseek.com,以 Together.ai 作为备用

  • 用例:

  • 产品描述(0.7 温度)

  • 翻译(1.3 温度)

  • 技术规格(0.3 温度)

  • 营销文案(1.0 温度)

优化:

  • 提示词缓存(系统提示词节省 99.9%)

  • 批处理(快 3 倍)

  • 温度调优(减少 20% token)

性能:

  • 约 14 小时生成 5,000 条描述

  • 成本:使用缓存后 $1.45(节省 52%)

  • 速度:每条描述约 3 秒(批处理)

集成:

  • SEO 流水线(第 9 步)

  • 翻译队列(后台 worker)

  • 产品描述表(DynamoDB)

通过这种方法,我们无需手动撰写即可生成和维护数千种多语言产品描述。


← 返回文档索引