Sohbet rolleri atama

Llama 3 ile Çalışmak

Imtihan Ahmed

Machine Learning Engineer

Rolleri tanımlama

  • Modelin tonunu iyileştirme
  • Örnek: müşteri destek sohbet botu

Bir sohbet botuyla konuşma - 1

Llama 3 ile Çalışmak

Rolleri tanımlama

  • Modelin tonunu iyileştirme
  • Örnek: müşteri destek sohbet botu

Bir sohbet botuyla konuşma - 2

Llama 3 ile Çalışmak

Rolleri tanımlama

  • Modelin tonunu iyileştirme
  • Örnek: müşteri destek sohbet botu

Bir sohbet botuyla konuşma - 3

Llama 3 ile Çalışmak

Sohbet tamamlamada rollerin kullanımı

  • Llama'nın yanıtlarını yönlendirmek için sohbet rolleri

Screenshot 2025-02-26 at 15.32.28.png

  • Kişilik ve stili belirler

 

Screenshot 2025-02-26 at 15.31.50.png

  • Soruyu soran kişiyi temsil eder
Llama 3 ile Çalışmak

Sohbet tamamlamada rollerin kullanımı

  • Yapılandırılmış bir görüşme gönderme

  • create_chat_completion() işlevi

from llama_cpp import Llama

llm = Llama(model_path="path/to/model.gguf")

message_list = [...] # Bu listede roller bulunur
response = llm.create_chat_completion(
messages = message_list
)
Llama 3 ile Çalışmak

Sistem rolü

  • Sistem mesajı: modelin nasıl davranacağına dair talimatlar
system_message = "You are a business consultant who gives data-driven answers."

message_list = [{
"role": "system",
"content": system_message
}]
Llama 3 ile Çalışmak

Kullanıcı rolü

  • Kullanıcı mesajı: modele sorulan istem
system_message = "You are a business consultant who gives data-driven answers."

user_message = "What are the key factors in a successful marketing strategy?"
message_list = [{"role": "system", "content": system_message},
{ "role": "user", "content": user_message }
]
Llama 3 ile Çalışmak

Yanıt üretme

from llama_cpp import Llama
llm = Llama(model_path="path/to/model.gguf")

system_message = "You are a business consultant who gives data-driven answers."
user_message = "What are the key factors in a successful marketing strategy?"

message_list = [{"role": "system", "content": system_message},
               {"role": "user", "content": user_message}]

response = llm.create_chat_completion(messages = message_list) print(response)
{'id': ..., 'object': ..., 'created': ..., 'model': ..., 'choices': [...], ...}
Llama 3 ile Çalışmak

Asistan rolü

response["choices"][0]

Yanıt çıktısı

Llama 3 ile Çalışmak

Asistan rolü

response["choices"][0]

Mesaj vurgulanmış yanıt çıktısı

Llama 3 ile Çalışmak

Asistan rolü

response["choices"][0]

Rol vurgulanmış yanıt çıktısı

Llama 3 ile Çalışmak

Asistan rolü

response["choices"][0]

İçerik vurgulanmış yanıt çıktısı

result['choices'][0]['message']['content']
'A successful marketing strategy relies on clear objectives, established 
through specific, measurable goals. Understanding the target audience ...'
Llama 3 ile Çalışmak

Hadi pratik yapalım!

Llama 3 ile Çalışmak

Preparing Video For Download...