Difference between revisions of "Conversational-AI-Tools/C2/Prompt-Engineering/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "'''Title of the script: Prompt Engineering''' '''Author: Sudhakar Kumar''' '''Keywords''': prompt, engineering, context, background, few-shot, video tutorial. {|border=1...")
 
Line 81: Line 81:
 
Then tabulates the differences between the two.  
 
Then tabulates the differences between the two.  
  
Note that the content of the response may differ at your end, even with the exact same prompt.  
+
Note that the content of the response may differ at your end, even with the same prompt.  
 
|-  
 
|-  
 
|| '''Highlight compile-time polymorphism in the generated response'''
 
|| '''Highlight compile-time polymorphism in the generated response'''
Line 221: Line 221:
 
|-  
 
|-  
 
||  
 
||  
|| More information on prompt engineering and few-shot prompting, is provided in the Additional Reading Material available on this tutorial page.
+
|| More information on prompt engineering and  
 +
few-shot prompting, is provided in the Additional Reading Material available on this tutorial page.
 
|-
 
|-
 
|| '''Slide 8'''
 
|| '''Slide 8'''

Revision as of 20:22, 23 November 2025

Title of the script: Prompt Engineering

Author: Sudhakar Kumar

Keywords: prompt, engineering, context, background, few-shot, video tutorial.


Visual Cue Narration
Slide 1

Title Slide

Welcome to the Spoken Tutorial on Prompt Engineering.
Slide 2

Learning Objectives

In this tutorial, we will learn about
  • Prompt engineering
  • Importance of context and background
  • Few-shot prompting
Slide 3

System Requirements

To record this tutorial, I am using
  • Ubuntu Linux OS version 22.04
  • Firefox web browser version 141.0.4
  • Visual Studio Code version 1.100.3
Slide 4

Pre-requisites

To follow this tutorial, learners should have basic knowledge of:
  • Using internet, and
  • Programming in C/C++
Slide 5

Code files

The following code file is required to practice this tutorial.

  1. prompt-engineering.cpp

This file is provided in the Code Files link of this tutorial page.

The following code file is required to practice this tutorial.

This file is provided in the Code Files link of this tutorial page.

Slide 6

What is Prompt Engineering?

Let us learn about Prompt engineering.
  • It is a skill of writing and refining prompts for AI tools like ChatGPT.
  • It means designing clear instructions, questions, or context.
  • Good prompts guide the AI tool to give accurate, useful, or creative answers.
Highlight the address bar in Google Chrome Open ChatGPT on any browser.
Let us give a prompt to ChatGPT.
Highlight

Ask anything in the middle of the page

Type: You are a C++ tutor.

Explain the difference between function overloading and function overriding in C++ with examples. Press Enter.

You are a C++ tutor. Explain the difference between function overloading and function overriding in C++ with examples.Press Enter.
Highlight the generated response in the chat window ChatGPT first defines function overloading, followed by an example.

Similarly, for function overriding.

Then tabulates the differences between the two.

Note that the content of the response may differ at your end, even with the same prompt.

Highlight compile-time polymorphism in the generated response Suppose I am unfamiliar with compile-time polymorphism.

I can ask ChatGPT to provide further explanation.

Highlight this term.

Observe that an option of “Ask ChatGPT” appears.

Click this option and type your query.

I will type, explain this term, and press Enter.

ChatGPT now explains compile-time polymorphism.

Highlight some terms in the generated response such that the Ask ChatGPT option appears “Ask ChatGPT” is a built-in feature of ChatGPT’s web app.

Think of it like a shortcut for quickly asking “What does this mean?”

Let us try another prompt.
I am a first-year Computer Science student, and I know the concepts of variables and functions.

I want ChatGPT to explain references in C++.

Click New Chat Click on New chat to open a new chat.
Type: Explain the concept of references in C++ to a first-year CS student who only knows variables and functions. Press Enter.

Highlight the few lines of response

Type the following

And, press Enter.

Observe the response.

ChatGPT explains the concept of references in C++.

Next, I want to teach the concept of dangling pointers in C with some funny analogy.
Click New chat

Type: Explain the concept of dangling pointers in C in a way that a beginner can understand, using a funny or relatable real-life analogy.

Click New chat to start a new conversation.

In the new chat, type the following.

And, press Enter.

Highlight the Funny analogy in the generated response

Scroll and show

Cursor on previous chat

See how ChatGPT adds a funny analogy in its response.

All my previous chats appear under Chats in the sidebar.

I can click on any of them to open and continue that conversation.

Let us now learn about few-shot prompting.
Slide 7

Few-shot Prompting

If we give ChatGPT a few inputs with examples, it will resolve the issues.

This technique helps the tool recognize patterns and apply them to similar unseen problems.

Show the code in the visual studio code editor. Let us try out a few-shot prompt with an example.


I have a C++ code, and I want ChatGPT to identify the error in a particular format.

Type

Identify the error in the following C++ code.

Code:

int main() {

int a = "hello";

return 0;

}

Error:

Assigning a string literal to an int variable is invalid.


Code:

int main() {

cout << "Hello";

return 0

}

Error:

Missing semicolon after return 0.


Code:

int main() {

int arr[3] = {1, 2, 3, 4};

return 0;

}

Error:

Go to ChatGPT and start a new chat.

Type the code at the prompt:

And press Enter.

Highlight Error: in the generated response Observe that ChatGPT prints the error with Error semicolon.

Then the error message, followed by an explanation.

More information on prompt engineering and

few-shot prompting, is provided in the Additional Reading Material available on this tutorial page.

Slide 8

Summary

In this tutorial, we have learnt

  • Prompt Engineering
  • Importance of Context and Background
  • Few-shot Prompting
With this, we come to the end of this tutorial.

Let us summarise.

Slide 9

Assignment

Give ChatGPT the same programming question using two scenarios:

  1. Without role or context, and
  2. With role and context.

Compare how the answers differ.

As an assignment,
Slide 10

Thank you

This Spoken Tutorial is brought to you by EduPyramids Educational Services Private Limited, SINE, IIT Bombay.

Thank you for joining!

Contributors and Content Editors

Ketkinaina, Madhurig, Sudhakarst