Prompt engineering: Part 1
What is prompt engineering?
A prompt is a piece of text that is given to a large language model (LLM) to guide its response. The prompt can be as simple as a question or a command, or it can be more complex like a paragraph of text that provides context or instructions. The goal of the prompt is to give the LLM enough information to generate the desired output. Prompt engineering is the process of crafting effective prompts to guide LLMs towards generating desired responses. Here are some examples of different types of prompts:
- Question: What is the capital of India?
- Command: Write a poem about a cat.
- Context & question: Imagine you are a chatbot that is designed to answer questions about the weather. What is the weather of New Delhi today?
- Instructions: Generate a Python code snippet that reverses a string.
Why prompt engineering?
LLMs are trained on massive datasets of text, but they can be difficult to control. Prompt engineering helps to bridge the gap between the LLMs’ understanding of language and the user’s desired output. Prompt engineering is an important tool for anyone who wants to use LLMs to carry out any instruction for performing a task. By understanding how to craft effective prompts, users can improve the quality of the responses generated by LLMs and unlock their full potential.
Writing effective prompts is an iterative process. The best way to learn how to write effective prompts is to experiment and see what works.
Parts of a prompt
Prompt engineering is a complex and evolving field. There are many different factors to consider when crafting an effective prompt, like the LLM’s training data, the desired output, and the user’s goals.
There are majorly 4 parts of a prompt:

Role: This denotes the role LLM is supposed to take. For example, LLM may take the role of a customer service agent or a protocol author. Further, the objective of the role is also mentioned. For example, ‘As a customer service agent, your task is to send a mail to a customer.’, ‘As a protocol author, your task is to create a protocol for a clinical trial.’
Task: This denotes the actual task to be carried out. This contains the instructions to be followed by LLM. These instructions should be clear & specific. These may contain the detailed steps (methodology) that the LLM is to carry out in a clear & unambiguous manner.
Input: This denotes the actual input on which the task has to be performed. This can be mentioned by enclosing them within delimiters (eg, quotes: “””, backticks: ```).
Output: This denotes the instructions related to response (output) that the LLM is required to generate. This may include instructions with respect to tone (eg, friendly tone), format (eg, JSON, HTML), or other restrictions (eg, length up to 30 words).
As an example, suppose a user wishes to draft a clinical trial protocol using LLM. For this task, the following can be parts of the prompt.

Using the above prompt, the output generated by GPT (gpt-3.5-turbo) is:
Protocol for Clinical Trial in Oncology for Prostate Cancer (Phase 1)
Title: A Phase 1 Study of [Insert Investigational Drug Name] in Patients with Prostate Cancer
Introduction:
This clinical trial aims to evaluate the safety, tolerability, pharmacokinetics, and preliminary efficacy of [Insert Investigational Drug Name] in patients with prostate cancer. The study will be conducted in multiple geographies including the US, Canada, UK, and China.
Objectives:
The primary objective of this study is to determine the maximum tolerated dose (MTD) and recommended Phase 2 dose (RP2D) of [Insert Investigational Drug Name] in patients with prostate cancer. Secondary objectives include evaluating the safety and tolerability of the drug, assessing its pharmacokinetics, and exploring its preliminary efficacy.
Study Design:
This is a Phase 1, open-label, dose-escalation study. Patients with histologically confirmed prostate cancer will be enrolled and treated with [Insert Investigational Drug Name] in 21-day cycles. The dose will be escalated in cohorts until the MTD is reached. Safety and efficacy assessments will be conducted throughout the study.
Inclusion Criteria:
- Histologically confirmed prostate cancer
- Measurable or evaluable disease
- Eastern Cooperative Oncology Group (ECOG) performance status of 0-1
- Adequate organ function
- Signed informed consent
Exclusion Criteria:
- Prior treatment with [Insert Investigational Drug Name] or other investigational agents
- Active brain metastases or leptomeningeal disease
- Active infection requiring systemic therapy
- History of other malignancies within the past 5 years
Toxicity:
As this trial is in the therapeutic area of Oncology, a separate section for toxicity will be included. The toxicity profile of [Insert Investigational Drug Name] will be closely monitored throughout the study. Adverse events will be graded according to the National Cancer Institute Common Terminology Criteria for Adverse Events (NCI CTCAE) version 5.0. Dose-limiting toxicities (DLTs) will be defined as any Grade 3 or higher non-hematologic toxicity, any Grade 4 hematologic toxicity lasting more than 7 days, or any toxicity that results in treatment delay or discontinuation.
Conclusion:
This Phase 1 study will provide important safety, tolerability, pharmacokinetic, and preliminary efficacy data for [Insert Investigational Drug Name] in patients with prostate cancer. The results of this study will inform the design of future Phase 2 and Phase 3 trials.
Sincerely,
AI customer agent
For referring to the GitHub repository, refer here.
The writer is a data scientist specialized in natural language processing, including using large language models for content generation.
Comments
Post a Comment