Prompt Engineering & LLM Optimization for Developers · Pelajaran

Perintah Zero-shot dan Few-shot

Kuasai teknik pemberian perintah yang tidak memerlukan contoh (zero-shot) atau hanya memerlukan beberapa contoh (few-shot) untuk menghasilkan perilaku model yang diinginkan.

Pelajaran 3 dari 412 langkah

Perintah Zero-shot dan Few-shot adalah pelajaran Prompt Engineering & LLM Optimization for Developers gratis di CoddyKit. Ini adalah pelajaran 3 dari 4. Kamu bisa membaca pelajaran lengkapnya di bawah secara gratis — lalu praktikkan langsung di browser dengan editor kode bawaan dan tutor AI 24/7. Ini adalah bagian dari jalur belajar Prompt Engineering & LLM Optimization for Developers, dan progresmu tersinkronisasi di web dan aplikasi CoddyKit. Kursus Prompt Engineering & LLM Optimization for Developers mencakup 4 pelajaran total.

Bagian dari pelajaran ini belum diterjemahkan dan ditampilkan dalam bahasa Inggris.

Guiding LLMs with Examples

LLMs often need guidance. With zero-shot you give the task and no examples; with few-shot you include a few examples to show what you expect.

Zero-shot: Relying on Knowledge

Zero-shot prompting gives a task with no examples - the model leans entirely on its pre-trained knowledge. Efficient, and great for common, straightforward tasks.

Zero-shot in Action: Summarization

Here's a zero-shot summarization prompt: no example summaries, just the task. The model relies on its general grasp of summarizing.

Summarize the following text in one sentence:

"The quick brown fox jumped over the lazy dog. This action demonstrated the fox's agility and the dog's relaxed nature. It was a sunny afternoon, perfect for such playful antics."

Zero-shot: Sentiment Analysis

Zero-shot shines for sentiment analysis too - just name the task and the model classifies it. Perfect for quick checks without specialized categories.

Classify the sentiment of the following product review as Positive, Negative, or Neutral:

"The battery life is terrible, but the camera is surprisingly good."

When Zero-shot Falls Short

Zero-shot has limits: custom output formats, multi-step reasoning, ambiguous tasks, and consistency across queries can all trip it up. That's where few-shot helps.

Few-shot: Learning from Examples

Few-shot prompting includes a few input-output examples right in the prompt. They demonstrate the pattern, style, or format, boosting accuracy on tricky tasks.

Structuring Few-shot Prompts

A few-shot prompt is: instruction, a couple of input/output examples, then your new input. Keep examples clear, concise, and representative.

Instruction:
Input: Example 1 Input
Output: Example 1 Output

Input: Example 2 Input
Output: Example 2 Output

Input: Your New Input
Output:

Few-shot in Action: Structured Output

Want JSON output? Few-shot nails it - the examples below pin down the exact structure for sentiment and confidence, so the model copies the shape.

Classify the sentiment of the following reviews and output as JSON:

Review: "This movie was fantastic!"
Output: {"sentiment": "Positive", "confidence": "High"}

Review: "I didn't like it at all."
Output: {"sentiment": "Negative", "confidence": "High"}

Review: "It was okay, nothing special."
Output: {"sentiment": "Neutral", "confidence": "Medium"}

Review: "The product worked sometimes, but often failed."
Output:

Few-shot: Consistent Tone & Style

Few-shot is ideal for tone and style: hard to describe "quirky," easy to show. These examples teach the model a short, punchy headline voice.

Rephrase the following sentences into a short, catchy, and slightly quirky headline:

Original: "A group of scientists discovered a new species of glowing mushroom in the Amazon rainforest."
Headline: "Amazon Glow-Shroom Shines!"

Original: "The city council decided to ban plastic bags to protect the environment."
Headline: "Bag the Bags: City Goes Green!"

Original: "A new study suggests that eating chocolate can improve your mood."
Headline:

Zero-shot vs. Few-shot: Choosing Your Tool

Choosing: zero-shot for simple, common tasks and lower cost; few-shot for specific formats, niche knowledge, and when consistency really matters.

Quick Check on Prompting

You need an LLM to extract specific data from customer reviews (e.g., product name, issue type, suggested improvement) and output it as a structured JSON object. Which prompting technique would be most effective?

Recap: Master Your Prompts!

Recap: zero-shot is quick and efficient for general tasks; few-shot uses examples to lift accuracy and consistency on complex ones. Match the tool to the job.

Gratis untuk memulai

Belajar Prompt Engineering & LLM Optimization for Developers dengan tutor AI — gratis

Tulis dan jalankan kode asli di browser kamu, dapatkan bantuan instan dari tutor AI 24/7, dan lanjutkan di mana kamu tinggalkan di web atau aplikasi.

Kursus
12
Pelajaran
48

Pertanyaan yang Sering Diajukan

Apakah pelajaran “Perintah Zero-shot dan Few-shot” gratis?

Ya — teks lengkap “Perintah Zero-shot dan Few-shot” gratis dibaca di sini di web. Untuk praktiknya secara interaktif (editor kode bawaan dan tutor AI 24/7) dan buka sisa kursus Prompt Engineering & LLM Optimization for Developers, upgrade ke CoddyKit PRO. Kursus Prompt Engineering & LLM Optimization for Developers mencakup 4 pelajaran total.

Apa yang akan aku pelajari di “Perintah Zero-shot dan Few-shot”?

Kuasai teknik pemberian perintah yang tidak memerlukan contoh (zero-shot) atau hanya memerlukan beberapa contoh (few-shot) untuk menghasilkan perilaku model yang diinginkan. Kamu berlatih Prompt Engineering & LLM Optimization for Developers dengan kode praktik yang langsung kamu jalankan di browser, dan tutor AI 24/7 menjawab pertanyaanmu saat kamu mengerjakan pelajaran ini.

Apakah aku perlu pengalaman untuk memulai Prompt Engineering & LLM Optimization for Developers?

Tidak diperlukan pengalaman sebelumnya. Prompt Engineering & LLM Optimization for Developers di CoddyKit dirancang untuk pemula hingga pelajar tingkat lanjut, jadi kamu bisa memulai di sini atau dari awal dan belajar sesuai kecepatan kamu sendiri. Ini adalah pelajaran 3 dari 4.

Berapa lama pelajaran “Perintah Zero-shot dan Few-shot” memakan waktu?

Sebagian besar pelajaran CoddyKit memakan waktu sekitar 5–10 menit. Setiap pelajaran ringkas dan interaktif, jadi kamu membuat kemajuan stabil dan melanjutkan dari tempat kamu tinggalkan di web dan aplikasi.

Bisakah aku menulis dan menjalankan kode dalam pelajaran Prompt Engineering & LLM Optimization for Developers ini?

Ya. Setiap pelajaran Prompt Engineering & LLM Optimization for Developers menyertakan editor kode bawaan, jadi kamu menulis dan menjalankan kode nyata langsung di browser dan mendapatkan umpan balik AI instan — tidak diperlukan penyiapan lokal.

Semua pelajaran dalam kursus ini

  1. Pengenalan LLM dan Perancangan Perintah
  2. Struktur Dasar Perintah
  3. Perintah Zero-shot dan Few-shot
  4. Kesalahan Umum dalam Penulisan Prompt dan Cara Menghindarinya
← Kembali ke Prompt Engineering & LLM Optimization for Developers