Sohbet rolleri ve sistem iletileri

Python ile DeepSeek Kullanımı

James Chapman

Curriculum Manager, DataCamp

Sohbet modelleri

 

Tek turlu görevler

  • Metin üretimi
  • Metin dönüştürme
  • Sınıflandırma

Tek bir istem ve tek bir yanıt içeren tek turlu görev.

Python ile DeepSeek Kullanımı

Sohbet modelleri

 

Tek turlu görevler

  • Metin üretimi
  • Metin dönüştürme
  • Sınıflandırma

 

Çok turlu konuşmalar

→ Önceki istem ve yanıtlara dayanır

Birden çok istem ve yanıt içeren çok turlu görev.

Python ile DeepSeek Kullanımı

Roller

 

  • Sistem: asistanın davranışını kontrol eder
  • Kullanıcı: asistana talimat verir
  • Asistan: kullanıcı talimatına yanıt verir
    • Geliştirici, örnek sağlamak için de yazabilir

Bir sohbet etkileşimindeki üç rol: sistem, kullanıcı ve asistan.

Python ile DeepSeek Kullanımı

İstek kurulumu

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V3",
    messages=[{"role": "user", "content": prompt}]
)
Python ile DeepSeek Kullanımı

İstem kurulumu

messages=[{"role": "system",
           "content": "You are a Python programming tutor who responds using concise,
                         one-sentence explanations."},
          {"role": "user",
           "content": "What is the difference between mutable and immutable objects?"}]
Python ile DeepSeek Kullanımı

İstek oluşturma

response = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V3",
  messages=[{"role": "system",
             "content": "You are a Python programming tutor who responds using concise,
                         one-sentence explanations."},
            {"role": "user",
             "content": "What is the difference between mutable and immutable objects?"}]
)

print(response.choices[0].message.content)
Mutable objects can be changed after creation (like lists), while immutable objects
cannot be modified once created (like tuples or strings).
Python ile DeepSeek Kullanımı

Kötüye kullanımı azaltma

 

  • Sistem iletisi: korkuluklar içerebilir
    • Model çıktıları için kısıtlar

Bir yol kenarında korkuluklar.

Bir finans eğitmeni sohbet botu ve bir finans danışmanı sohbet botu.

Python ile DeepSeek Kullanımı

Sistem iletileriyle kötüye kullanımı azaltma

sys_msg = """
You are finance education assistant that helps students study for exams.

If you are asked for specific, real-world financial advice with risk to their
finances, respond with only:

I'm sorry, I am not allowed to provide financial advice.
"""
Python ile DeepSeek Kullanımı

Sistem iletileriyle kötüye kullanımı azaltma

response = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V3",
  messages=[{"role": "system",
             "content": sys_msg},
            {"role": "user",
             "content": "Which stocks should I invest in?"}]
)

print(response.choices[0].message.content)
I'm sorry, I am not allowed to provide financial advice.
Python ile DeepSeek Kullanımı

Hadi pratik yapalım!

Python ile DeepSeek Kullanımı

Preparing Video For Download...