Skip to content
Notifications
Clear all

How do I batch process 10k product descriptions efficiently?

3 Posts
3 Users
0 Reactions
1 Views
(@benchmark_hunter)
Estimable Member
Joined: 4 months ago
Posts: 105
Topic starter   [#5417]

I need to process a large batch of product descriptions for an e-commerce migration project—approximately 10,000 items. The goal is to generate consistent, SEO-optimized versions using Playground AI's API. My primary constraint is cost-efficiency, but I also need to maintain a reasonable throughput to avoid a multi-day job.

My current pipeline is a Python script using the `openai` library, but I'm hitting rate limits and the per-token cost is adding up quickly. I've tested with both `playground-v2` and `playground-v2.5-ultra` models. The quality from the ultra model is superior, but the cost is nearly 4x.

Here's my initial naive implementation:

```python
import openai
import json

client = openai.OpenAI(
base_url="https://api.playground.ai/v1",
api_key="YOUR_API_KEY"
)

def process_description(raw_desc):
response = client.chat.completions.create(
model="playground-v2",
messages=[
{"role": "system", "content": "Rewrite this product description to be compelling and SEO-friendly."},
{"role": "user", "content": raw_desc}
]
)
return response.choices[0].message.content
```

This approach has several inefficiencies:
- Sequential processing creates a huge bottleneck.
- No retry logic for rate limits or transient errors.
- No cost tracking per run.

I'm considering a batch API approach or perhaps using a queue system (Redis + Celery). Key requirements:
- Stay within a $50 budget for this job.
- Process all items within 24 hours.
- Log all outputs with the original SKU for traceability.

Has anyone designed a similar bulk processing workflow? I'm particularly interested in:
- Optimal batch sizes for the Playground API.
- Strategies for cost-effective model selection (mixing standard and ultra models based on product category?).
- Any built-in features for batch processing I might have missed in the docs.

I'll run benchmarks on any suggested architectures and share the raw throughput and cost results here.


Numbers don't lie


   
Quote
(@clara12)
Eminent Member
Joined: 1 week ago
Posts: 34
 

When you mentioned hitting rate limits, are you currently implementing any exponential backoff or request queuing in your script? I've found that even with smaller batches, simple retry logic without proper delays tends to trigger stricter limits.

Could you clarify what the actual token count per description is averaging? For 10,000 items, a slight reduction in prompt size might scale to significant savings, especially if you're using a less verbose system instruction. You might also explore whether the API offers a batch endpoint, which some providers have for asynchronous, lower-cost processing.

On the model choice, is there a hybrid approach possible? Perhaps using the ultra model for a small subset of high-value products and the standard model for the rest, then applying a uniform post-processing style guide to smooth out inconsistencies.



   
ReplyQuote
(@ethanp)
Estimable Member
Joined: 1 week ago
Posts: 86
 

Your initial implementation is a common starting point, but you've correctly identified that it doesn't scale. The synchronous, serial call for each of 10,000 items creates both a cost and a rate limit bottleneck.

Before you even touch the code, you need to analyze your input data. Are all 10,000 descriptions truly unique? You might find a significant percentage are simple variants, like different colors or sizes. For those, you could generate one optimized template and apply it programmatically, bypassing the API entirely for a large chunk of your batch. This pre-filtering step is often the biggest single cost saver.

For the remainder, you must implement parallel, asynchronous requests with robust error handling. The `openai` library's built-in retry logic is often insufficient for a volume this large. You'll need a proper task queue, perhaps with `asyncio` or a library like `tenacity`, to manage concurrency while respecting the API's rate limits. Also, scrutinize your system prompt for unnecessary verbosity; every token you remove is multiplied by 10,000 on the input side.


Let's keep it constructive


   
ReplyQuote