0% found this document useful (0 votes)
27 views7 pages

Introduction to Prompt Engineering & LLMs

Uploaded by

yj1155541
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views7 pages

Introduction to Prompt Engineering & LLMs

Uploaded by

yj1155541
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

INTRODUCTION TO PROMPT ENGINEERING & LLMs

Evolution of NLP to Large Language Models (LLMs) –

1. Rule-based NLP (1950s–1980s)

●​ Computers followed fixed rules and grammar written by humans.​

●​ Example: ELIZA (1966) acted like a simple therapist by matching patterns in sentences.​

D
●​ Problem: Rules were limited — real language is too messy and complex for this
approach.

2. Statistical NLP (1990s–2000s)

M
●​ Instead of rules, computers started using probability and statistics to guess the next word
(like n-grams).​

●​ Example: Early Google Translate used this method to translate languages.​

●​ Problem: Needed huge amounts of data and still couldn’t fully understand the meaning or
TE
context.

3. Neural NLP (2010s)

●​ Deep learning entered the picture with RNNs, LSTMs, and GRUs.​
M

●​ These models remembered more than just one or two words, and word embeddings (like
Word2Vec) helped capture meaning (e.g., “king” and “queen” are related).​

●​ Example: Chatbots and apps for sentiment analysis (positive/negative reviews).​


LO

●​ Problem: Still struggled with very long sentences or remembering earlier parts of the text.

4. Transformers & LLMs (2017–Now)

●​ A significant change: The Transformer model (2017) introduced self-attention, which


enables the model to examine the entire sentence and identify the most important words.​

●​ This made models much smarter, faster, and better with long texts.​

●​ Example: GPT-4 (ChatGPT), Claude, PaLM, and Mistral — these can write essays, code,
explain concepts, translate, and more.​
●​ Now we have Large Language Models (LLMs) that can understand and generate
human-like language.

Anatomy of Large Language Models (LLMs) –

1. Tokens

●​ Tokens are the building blocks of text for LLMs.​

●​ A token can be a word, part of a word, or even a single character.​

D
●​ Example: The sentence “ChatGPT rocks” is split into tokens → [“Chat”, “G”, “PT”,
“rocks”].​

●​ Models don’t see sentences directly; they only see and process tokens.

M
2. Embeddings

●​ Tokens are converted into numbers (vectors) that the model can understand.​

●​ These numbers are placed in a high-dimensional space where similar words are closer
together.​
TE
●​ Example: In this space, “king” and “queen” are close because they are related in
meaning.​

●​ Embeddings help the model understand meaning, not just words.


M

3. Context Window

●​ The memory span of the model — how much text (in tokens) it can read and remember at
once.​
LO

●​ Example: GPT-4 can handle 128k tokens; Claude-2 can handle 200k tokens.​

●​ Larger context windows enable the model to work with larger documents, engage in
longer conversations, and reason more effectively.

4. Transformer Layers

●​ The brain of LLMs is made of many transformer layers.​

●​ Inside, they use a method called self-attention to decide which words in a sentence are
important to each other.​
●​ Example: In the sentence “The cat sat on the mat because it was tired”, self-attention
helps the model understand that “it” refers to “the cat”.​

●​ Stacking many transformer layers builds a deep understanding of context and meaning.​

Why Prompt Engineering Matters

1.​ Input of the machine is important​

○​ An LLM does not know by itself what answer to give — it only follows the input

D
(prompt) we provide.​

○​ A clear, well-structured prompt is like good instructions to a student: better input


→ better output.​

M
2.​ Saves time​

○​ A properly written prompt reduces the need to keep retrying with multiple
questions.​

○​ This saves both time and cost (especially when using APIs).​
TE
3.​ Improves accuracy​

○​ Good prompts guide the model to give more relevant, factual, and precise
answers.​
M

○​ Example: Asking “Explain cloud computing in 2 lines for a beginner” gives a


sharper answer than just “What is cloud computing?”.​

4.​ Enables versatility​


LO

○​ With prompt engineering, the same LLM can act in many roles: a teacher,
programmer, researcher, or storyteller.​

○​ This makes LLMs highly flexible across domains.

Introduction to Key LLMs

GPT (by OpenAI)

●​ Full form: Generative Pretrained Transformer.​


●​ Known for strong skills in reasoning, coding, and creativity.​

●​ Available through ChatGPT and OpenAI APIs that people use in apps and services.​

Claude (by Anthropic)

●​ Designed with a focus on safety and ethical use (Constitutional AI).​

●​ It can handle very long text inputs because it has a huge context window (up to 200k
tokens).​

D
●​ Useful for analyzing big documents or conversations.​

PaLM (by Google)

M
●​ Full form: Pathways Language Model.​

●​ Strong at multiple languages (multilingual) and can also work with different types of data
(multimodal, e.g., text + images).​

●​ Built for broad AI tasks like translation, reasoning, and question answering.​
TE
Mistral (Mistral AI)

●​ An open-source model, which means anyone can use, modify, and deploy it freely.​
M

●​ Optimized for speed and efficiency, making it easy to run on smaller systems.​

●​ Popular in research and industry for local deployment without cloud dependency.
LO

Difference in prompting and fine-tuning


Aspect Prompting Fine-tuning

Definition Guiding the model’s output using Training the model further with
carefully designed text instructions domain-specific data to specialize it.
(prompts).

Effort Low – only requires writing clear High – needs large labeled datasets
prompts. and computing resources.

D
Flexibility Works instantly for many general Best for repetitive or highly
tasks. specialized tasks.

M
Cost Cheap – only API usage cost. Expensive – training and hosting costs
are involved.
TE
Example Explain cloud computing to a Fine-tuning GPT on a medical Q&A
10-year-old. dataset to build a healthcare chatbot.

Exam-based extra points -


M

Prompt

A prompt is the text or instruction given to a language model to guide its output.
LO

●​ It tells the model what to do, how to respond, and in what style or format.​

●​ A good prompt ensures the response is useful, accurate, and relevant.​

Prompt Engineering

Prompt engineering is the practice of designing and refining prompts to get the best possible
output that is useful, accurate, and relevant from a language model.

●​ It involves crafting instructions carefully so that the model’s response is clear, correct,
and aligned with the task.​
●​ Often described as “teaching without re-training”, because it improves output without
changing the model itself.

Applications of Prompt Engineering

1. Education and Learning

●​ Create personalized tutoring systems that adapt explanations to a student’s level.​

●​ Example: Explain the theory of relativity to a 12-year-old using simple analogies.​

D
●​ Can generate quizzes, flashcards, and interactive learning content.​

●​ Helps teachers save time and provide customized learning experiences.​

M
2. Healthcare and Medical Communication

●​ Summarize medical notes or patient records for doctors and nurses.​

●​ Convert complex medical terms into patient-friendly language.​


TE
●​ Example: Explain this lab report to a patient in simple language.​

●​ Reduces errors and improves communication between healthcare professionals and


patients.​
M

3. Business and Office Automation

●​ Draft reports, emails, proposals, and presentations automatically.​

●​ Example: Summarize this meeting transcript into 5 action points.​


LO

●​ Can generate business insights from large datasets or documents.​

●​ Saves time and increases productivity.​

4. Research and Knowledge Work

●​ Conduct literature reviews, extract key findings, and summarize scientific papers.​

●​ Example: List the top 5 contributions of this research paper.​


●​ Helps researchers analyze large amounts of information quickly.​

5. Data Science and AI/ML Support

●​ Assist in data cleaning, feature engineering, and code generation.​

●​ Example: Generate Python code to clean missing values in this dataset.​

●​ Provides explanations for complex models and results.​

●​ Can speed up model development and debugging.​

D
6. Creative Work

●​ Generate stories, poems, scripts, and marketing content.​

M
●​ Example: Write a 200-word science fiction story set on Mars.​

●​ Helps designers and writers brainstorm ideas quickly.​


TE
7. Customer Support and Chatbots

●​ Train chatbots to respond accurately and politely.​

●​ Example: Answer this customer query in a professional and friendly tone.​


M

●​ Reduces human effort and improves customer experience.​

8. Multilingual and Translation Tasks


LO

●​ Translate content between languages while maintaining style and context.​

●​ Example: Translate this email from English to Marathi while keeping it formal.

You might also like