Self-consistency istemleri
Dizüstü bilgisayarlar ve cep telefonları satan bir mağazaya sahip olduğunu hayal et. Güne mağazada 50 cihazla başlıyorsun ve bunların %60'ı cep telefonu. Gün içinde üç müşteri mağazayı ziyaret ediyor; her biri birer cep telefonu satın alıyor ve içlerinden biri ayrıca bir dizüstü bilgisayar alıyor. Ayrıca stoğuna 10 dizüstü bilgisayar ve 5 cep telefonu ekliyorsun. Günün sonunda kaç dizüstü bilgisayar ve kaç cep telefonu var? Bu problem problem_to_solve değişkenindeki metinde tanımlanmıştır ve bunu çözmek için bir self-consistency istemi kullanacaksın.
OpenAI paketi ve get_response() fonksiyonu senin için önceden yüklendi.
Bu egzersizdeki get_response() fonksiyonu, egzersizin daha hızlı çalışmasına yardımcı olmak için max_tokens parametresini kullanır.
Bu egzersiz
OpenAI API ile Prompt Engineering
kursunun bir parçasıdırEgzersiz talimatları
- Modelin problemi üç uzman ile çözüp sonuçları çoğunluk oylaması ile birleştirmesine olanak tanıyan
self_consistency_instructionifadesini oluştur. self_consistency_instructionveproblem_to_solveifadelerini birleştirerek sonpromptu oluştur.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
client = OpenAI(api_key="")
# Create the self_consistency instruction
self_consistency_instruction = ____
# Create the problem to solve
problem_to_solve = "If you own a store that sells laptops and mobile phones. You start your day with 50 devices in the store, out of which 60% are mobile phones. Throughout the day, three clients visited the store, each of them bought one mobile phone, and one of them bought additionally a laptop. Also, you added to your collection 10 laptops and 5 mobile phones. How many laptops and mobile phones do you have by the end of the day?"
# Create the final prompt
prompt = ____
response = get_response(prompt)
print(response)