Meta Prompt ile Çok Dilli Çeviri Çıktılarını Optimize Etmek

Ufuk

Yeni Üye
Katılım
Eyl 2026
Konular
1
Mesajlar
1
Tepki puanı
0
Görüntülenme
0
1. Translate the same text into multiple languages—how can I keep the prompt short?
Çoklu diller için tek satırda dil kodlarını listelerim:
Kod:
Translate the following text into Spanish, French, German, and Italian.  
Text: {original_text}
Bu sayede tek bir çağrıda dört çeviri alınır; prompt uzunluğu kısa tutulur.

2. How do I force a consistent output structure for each language?
System mesajı ekleyerek formatı belirlerim:
Kod:
System: For each language, output the ISO code followed by the translation.  
Example: "es: Hola"  
Do not add extra text or explanations.
Bu, genellikle json_format gibi yapılandırılmış çıktı sağlamaya yöneliktir.

3. What settings reduce token usage and cost for large texts?
  • max_tokens parametresiyle maksimum çıktı uzunluğunu sınırlayın.
  • Çok uzun metinleri bölebilir ve her parçayı ayrı çağrı yaparak toplam token sayısını düşürebilirsiniz.
  • temperature=0.2 gibi düşük bir sıcaklık ile daha kısa yanıtlar alınır.

4. Can I cache translations to avoid repeated requests?
Evet, çeviri sonuçlarını bir key‑value veritabanında saklayarak aynı metin için tekrar çağrı yapılmasını engelleyebilirsiniz.
Python:
cache_key = f"translate:{hash(original_text)}:{','.join(languages)}"
translation = cache.get(cache_key) or openai.ChatCompletion.create(...)
cache.set(cache_key, translation, ttl=86400)

5. What is a quick sanity check before sending a big request?
Bir test isteğiyle tek bir dil için kısa bir metni çevirerek yanıt formatını ve token sayısını kontrol edin.
Python:
response = openai.ChatCompletion.create(
    model="gpt-4o-mini",
    messages=[{"role":"system","content":"..."},
              {"role":"user","content":"Translate 'Hello world' to Spanish."}],
    max_tokens=50
)
print(response.choices[0].message.content)
Bu, beklenmedik yüksek token maliyetlerini önler.

İlgili konular​

 
Geri
En Üst