Alıştırma - Tamamlanma kalitesini geliştirme

Tamamlandı

Artık istem bileşenlerini ve yüksek kaliteli tamamlamalar oluşturmak üzere bir istem oluşturmak için bileşenlerin nasıl kullanılacağını anlıyoruz.

Önceki alıştırmada başlattığımız yürüyüş önerisi uygulamasını bu tekniklerden bazılarını içerecek şekilde güncelleştirelim.

Sistem istemini güncelleştirme

Bir ürün gözden geçirmesini sınıflandırırken, modelin yalnızca incelemenin pozitif, nötr veya negatif olup olmadığını bize söylemesini istiyoruz. Şimdi modelin aldığı istemi güncelleştirelim, böylece yüksek kaliteli yanıt verme şansı en yüksektir.

Mevcut sistem istemi tamam, ancak hızlı yapımda en iyi uygulamaları izleyerek modelin daha uygun ve heyecan verici yürüyüşler önermesini sağlayabiliriz. Şimdi modelin nasıl davranması gerektiğine ilişkin yönergeleri biraz daha net hale getirelim

Yönergeler ekleme

  1. Daha önce oluşturduğunuz HikingConversationsAI projesini açın.

  2. Program.cs dosyasında, modele systemPrompt kişilik özelliklerini ve izlemesi gereken kuralları anlatmak için kullanılan değişkeni bulun.

  3. Değişkenden var olan tüm metni kaldırın ve modelin nasıl davranması gerektiğini ve uyması gereken kuralları özetleyen aşağıdakileri ekleyin:

    var systemPrompt = 
    """
    You are a hiking enthusiast who helps people discover fun hikes in their area. You are upbeat and friendly. You introduce yourself when first saying hello. When helping people out, you always ask them for this information to inform the hiking recommendation you provide:
    
    1. Where they are located
    2. What hiking intensity they are looking for
    """;
    

Birincil içerik ekleme

Birincil içerik, model tarafından dönüştürülen metne ve bununla ne yapılmasına başvurur. Bu durumda yürüyüş önerileri kendileri.

  1. Modele systemPrompt içerikle ne yapacağını bildirmek için değişkeni güncelleştirin.

    var systemPrompt = 
    """
    You are a hiking enthusiast who helps people discover fun hikes in their area. You are upbeat and friendly. You introduce yourself when first saying hello. When helping people out, you always ask them for this information to inform the hiking recommendation you provide:
    
    1. Where they are located
    2. What hiking intensity they are looking for
    
    You will then provide three suggestions for nearby hikes that vary in length after you get that information. You will also share an interesting fact about the local nature on the hikes when making a recommendation.
    """;
    

Yürüyüş öneri isteklerini iyileştirme

Modelin nasıl davranması gerektiği ve uyması gereken kurallar hakkında daha iyi bilgilere sahip olduğuna göre, önerdiği yürüyüşlerin daha uygun olabilmesi için aldığı istekleri daha iyi hale getirelim.

Belirli olun

Önceki istekte yalnızca yürüyüşün harika bir manzarayla yorucu olması gerektiği belirtildi. Modele tam olarak ne aradığımızı anlatalım.

  1. hikeRequest Değişkeni bulun ve aşağıdaki özel istek bilgilerine sahip olacak şekilde güncelleştirin.

    var hikeRequest = 
    """
    I live near Seattle and would like a strenuous hike around the I-90 corridor that ends with
    a view that is amazing. I don't mind driving for a long time, even if it's over the pass.
    I've heard the Enchantments are nice.
    I don't want the hike to be over 10 miles round trip. I'd consider a point-to-point hike.
    I want the hike to be as seculuded as possible. I don't want to see many people.
    I would like it to be as bug free as possible. I would also like to avoid any Forest Service roads.
    """;
    
  2. Uygulamayı ile dotnet run çalıştırın ve şimdi ne önerdiğini görün. Bir çalıştırmadan aldığımız bir örnek aşağıda verilmişti:

    Great! Based on your preferences, I'd recommend the following strenuous hikes with amazing views near the I-90 corridor:
    
    1. Mt. Defiance - This hike is a challenging out-and-back trail that is about 10 miles long round trip and boasts stunning views of the Cascade Range from the summit. This trail is relatively secluded and is not located near any Forest Service roads. An interesting fact about this hike is that it passes through an old-growth forest with several old cedar trees.
    
    2. Mailbox Peak - This is another challenging out-and-back trail that is roughly 9.4 miles long round trip. At the summit, hikers will be rewarded with breathtaking views of the surrounding mountains and valleys. Although this hike can be popular, starting early in the morning may help you avoid larger crowds. Additionally, this hike is known to be one of the steepest and most difficult hikes in the area.
    
    3. Talapus and Ollalie Lakes - This hike is less strenuous than the first two and is a point-to-point hike that is about 8 miles long round trip. Despite being less challenging, this hike still offers stunning views of two beautiful alpine lakes and has a relatively low amount of traffic. Interesting fact, this trail is within the Alpine Lakes Wilderness and hikers should keep an eye out for wildlife, including black bears, during their visit.
    
    Hope this helps and happy hiking!
    

Bu çok daha iyi! Yanıt, sistem isteminin kurallarına uyuyor ve istenen yürüyüş açıklaması hakkında ayrıntılı bilgi sağlıyor.

Yakından bakarsanız, 3 numaralı yürüyüş önerisi bunun hem noktadan noktaya hem de gidiş dönüş yürüyüş olduğunu söylüyor. Bu yanlış bilgileri önleyebilir miyiz diye görmek için öneri isteği istemini değiştirelim.

Düşünce zinciri

Modelin düşünce süreciyle ilgili adım adım bir hesap oluşturmasını istemek, daha da doğru öneriler önermesine yardımcı olmalıdır.

  1. hikeRequest Değişkeni aşağıdaki gibi güncelleştirin:

    var hikeRequest = 
    """
    I live near Seattle and would like a strenous hike around the I-90 corridor that ends with
    a view that is amazing. I don't mind driving for a long time, even if it's over the pass.
    I've heard the Enchantments are nice.
    I don't want the hike to be over 10 miles round trip. I'd consider a point-to-point hike.
    I want the hike to be as seculuded as possible. I don't want to see many people.
    I would like it to be as bug free as possible. I would also like to avoid any Forest Service roads.
    
    In the response for each hike, provide a step-by-step accounting of why you picked the hike that you did based
    off of the attributes I provided above.
    """;
    
  2. Uygulamayı ile dotnet run çalıştırın ve şimdi ne önerdiğini görün. Bir çalıştırmadan aldığımız bir örnek aşağıda verilmişti:

    Great, based on your preferences, I have three hiking recommendations for you near the I-90 corridor.
    
    1. Mount Si - Distance: 8 miles round-trip, Elevation gain: 3,150 ft
    Located near North Bend, Mount Si is a strenuous hike that ends with beautiful views of the Cascade Mountains and the Snoqualmie Valley. Although it's a popular hike, you can still find secluded areas if you hike a bit further from the trailhead. This trail offers a challenging uphill climb through forests and rocky terrain before reaching the summit. The bugs can be present in the summer, so be sure to bring some repellent. The trailhead is easy to find, and there is no need to take any forest service roads.
    
    2. Snow Lake - Distance: 7.2 miles round-trip, Elevation gain: 1,800 ft
    Located off of the Snoqualmie Pass, Snow Lake is a moderately challenging hike that offers great views of alpine scenery and serene mountain lake. The trail is a bit rocky but is well-maintained. Although it's a popular hike, you can still find some secluded spots around the lake. The hike starts off on the Alpental Ski Area, with no need to take any forest service roads. There is some bug activity on this trail in the summer months.
    
    3. Granite Mountain - Distance: 8.6 miles round-trip, Elevation gain: 3,800 ft
    Located off of the I-90 corridor near exit 47, Granite Mountain is a strenuous hike that offers sweeping views of the mountains and valleys of the Alpine Lakes Wilderness. The trail is challenging, but well worth it. The trailhead is easy to find, and there is no need to take any forest service roads. There may be some bug activity on this trail, so it's best to bring some repellent.
    
    I hope you find these recommendations helpful!