Harici bağlam ekleme

OpenAI API ile Prompt Engineering

Fouad Trad

Machine Learning Engineer

Harici bağlama ihtiyaç

  • Önceden eğitilmiş dil modelleri, eğitildiği bilgileri tanır
  • Daha fazla bağlam sağlamak gerekir
  • Daha yüksek doğruluk ve etkililik

Bir mobil telefonda sohbet botu simgesi.

OpenAI API ile Prompt Engineering

Büyük dil modellerinde bilgi eksikliği

  • Bilgi kesim tarihi
system_prompt = "Act as a financial expert that knows about the latest trends."

user_prompt = "What are the top financial trends in 2023?"

print(get_response(system_prompt, user_prompt))
I apologize for any inconvenience, but as of my last knowledge update in 
September 2021, I don't have information about financial trends in 2023.
OpenAI API ile Prompt Engineering

Büyük dil modellerinde bilgi eksikliği

  • İstenen, kamuya açık olmayan bilgi
system_prompt = "Act as a study buddy that helps me with my studies to succeed 
in exams."

user_prompt = "What is the name of my favorite instructor?" print(get_response(system_prompt, user_prompt))
I don't have personal information about you, including the name of your 
favorite instructor.
OpenAI API ile Prompt Engineering

Ek bilgi nasıl verilir?

  • Önceki görüşmelerden örnekler
  • Sistem istemi

Sohbeti yansıtan iki mesaj balonu simgesi.

OpenAI API ile Prompt Engineering

Örnek konuşmalar

  • Modeli belirli soruları yanıtlamaya yönlendirin
response = client.chat.completions.create(
  model="gpt-3.5-turbo",
  messages=[{"role": "system",
             "content": "You are a customer service chatbot that responds to user queries in a gentle way"},

{"role": "user", "content": "What services do you offer?"},
{"role": "assistant", "content": "We provide services for web application development, mobile app development, and custom software solutions."},
{"role": "user", "content": "How many services do you have?"}])
print(response.choices[0].message.content)
We have 3 services including web application development, mobile app development, and custom software solutions.
  • Dezavantaj: Çok sayıda örnek gerekebilir
OpenAI API ile Prompt Engineering

Sistem istemi

  • Sohbet yanıtları için gerekli bağlamı içerir
services = "ABC Tech Solutions, a leading IT company, offers a range of services: 
application development, mobile app development, and custom software solutions."

system_prompt = f"""You are a customer service chatbot that responds to user queries in a gentle way. Some information about our services are delimited by triple backticks. ```{services}```"""
user_prompt = "How many services do you offer?" print(get_response(system_prompt, user_prompt))
We have 3 services including web application development, mobile app development, 
and custom software solutions.
OpenAI API ile Prompt Engineering

Son not

  • Önceki yöntemler küçük bağlamlarda iyi çalışır
  • Daha büyük bağlamlar için daha gelişmiş teknikler gerekir

Uyarı simgesi.

OpenAI API ile Prompt Engineering

Ayo berlatih!

OpenAI API ile Prompt Engineering

Preparing Video For Download...