avatarManav

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

3290

Abstract

nd or contextual data included in the prompt helps the model understand the context it needs to generate a response.</li><li><b>Parameters for Specificity</b>: In some advanced uses, prompt parameters can include instructions on specificity or creativity, guiding the model on how closely it should stick to known information versus generating novel content.</li></ol><p id="b830"><b><i>Developer</i></b>: Prompt Parameters? Are we talking about Prompt Engineering here?</p><p id="466d">Yes, this takes us to the next major topic — <b>Prompting.</b></p><p id="cc26" type="7">The method of providing a model with a specific input to elicit desired output or response</p><p id="70b9">A prompt can be a simple question or a large set of instructions with examples and can take many shapes:</p><ul><li>Direct Instruction</li><li>Question-Based</li><li>Conversational</li><li>Creative Prompting</li><li>Zero-Shot or Few-Shot Learning</li></ul><p id="b57e" type="7">Prompt Engineering is referred to the design and optimization of these prompt patterns</p><p id="ef53">Let’s look at examples for each style of Prompting</p><h2 id="104c">Direct Instruction</h2><p id="03f9"><b>User</b>: Analyze the following text for emotional tone and key themes, then summarize your findings: <i>The Atlantic puffin (Fratercula arctica) is a seabird species in the auk family and is the only puffin native to the Atlantic Ocean. It has a black crown and back, pale grey cheek patches and white underparts and its broad, boldly marked red and black beak and orange legs contrast with its otherwise sombre plumage. The Atlantic puffin spends the autumn and winter at sea, mainly in the North Atlantic, and returns to land at the start of the breeding season in late spring.</i></p><p id="cb35"><b>LLM</b><i>: The provided text describes the Atlantic puffin (Fratercula arctica), focusing primarily on its physical characteristics and migration patterns. The emotional tone of the text is neutral and informative, devoid of personal opinion or emotional language.</i></p><p id="b597"><i>Key themes in the text include:</i></p><ol><li><i>Species Identification</i></li><li><i>Physical Description</i></li><li><i>Habitat and Behavior</i></li></ol><h2 id="e25b">Question — Based</h2><p id="1d3d"><b>User</b>: <i>Can you explain how blockchain technology works and its potential financial industry implications?</i></p><p id="8ac3">This prompting style requires the model to provide relevant information on blockchain technology and delve into its specific applications in the financial sector.</p><h2 id="24ed">Conversational</h2><p id="0042"><b>User</b>: <i>I’ve been thinking about switching careers but am unsure about the risks involved. What should I consider before deciding, and how can I prepare for a career transition?</i></p><p id="4705">This prompt engages the model in a more nuanced conversation. It seeks guidance on a complex personal decision, inviting the model to provide thoughtful considerations and practical advice for a career change.</p><h2 id="187a">Creative Prompting</h2><p id="d941"><b>User</b>: <i>Create a story set in a dystopian future where humans coexist with advanced AI. The narrative should focus on a human protagonist who discovers a hidden truth about the AI that changes their

Options

perception of reality.</i></p><p id="526e">This style of prompting invites the model to be creative and craft a detailed and imaginative story based on the elements provided</p><h2 id="fb39">Zero-Shot Learning</h2><p id="007d"><b>User</b>: Explain the principle behind solar panels and how they contribute to sustainable energy. Also, discuss the challenges in their widespread adoption.</p><p id="ba81">The model is prompted to provide detailed information on a topic (solar panels) <b><i>without prior examples</i></b>, relying on its <b>pre-trained knowledge</b> to explain the technology and discuss its benefits and challenges.</p><h2 id="40e0">Few-Shot Prompting</h2><figure id="fd2e"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*AqN-g6_a1SSghSL0HqhsqQ.png"><figcaption>Few-Shot Prompting example</figcaption></figure><p id="5e20">This style focuses on providing some examples followed by a new question. The expectation is for the model to use the examples and respond in the same format and depth of explanation.</p><p id="728b"><b><i>Developer</i></b>: Okay, so far we have covered Tokenization, Embedding, Parameters and Prompting. Is there anything else?</p><p id="a91c">Yes, the last piece of the puzzle is Fine Tuning, which refers to the process of taking a pre-trained model and further training it on a specific smaller dataset to specialize its capabilities.</p><p id="29b0">Below are Key aspects of fine-tuning:</p><ol><li><b>Pre-Trained Models</b>: Fine-tuning starts with a model already trained on a large, general dataset. This pre-training equips the model with a broad understanding of language, context, and general knowledge.</li><li><b>Specialized Dataset</b>: Fine-tuning involves training the model further on a dataset specific to the desired task or domain. <i>For example, if you want the model to perform well in medical diagnostics, you would fine-tune it on medical texts</i>.</li><li><b>Adjusting Parameters</b>: During fine-tuning, the model’s parameters (weights and biases) are slightly adjusted to fit the specifics of the new data. This adjustment is typically smaller and more focused than the initial broad-scale training.</li><li><b>Reduced Training Time</b>: Since the model is already pre-trained, fine-tuning is usually quicker and requires less data than training a model from scratch.</li><li><b>Task-Specific Performance</b>: The goal of fine-tuning is to enhance the model’s performance on a specific task, making it more accurate, relevant, and effective in that particular area.</li></ol><p id="3998">A great example of Fine-tuning is <a href="https://openai.com/blog/introducing-gpts"><code>GPTs by Ope</code>nAI</a> which are custom versions of ChatGPT that can be created for a specific purpose</p><p id="667e"><b><i>Developer</i></b>: This is a great start. Is there anything else?</p><p id="bfca">That’s pretty much it. To succeed in today's tech landscape, it's vital for developers to understand LLM models and the nuances of prompting and fine-tuning.</p><p id="4727">Remember, they are not just tools for today but a foundation for a future where the interaction between humans and machines becomes more seamless, intelligent, and beneficial for all.</p><p id="d844">Thanks for reading!</p></article></body>

LLM Basics — What Every Developer Should Know — Part II

Hey! Welcome back.

I hope you had a chance to review Part I of the series and now understand two essential aspects of LLM architecture — Tokens & Embeddings.

Photo by Growtika on Unsplash

Next, Let’s start by understanding Parameters

In the context of Machine learning and LLMs, parameters are elements of the model that are learned from training data. They are the backbone of LLMs, allowing them to learn from data and perform complex tasks.

Consider Parameters as internal settings of a neural network that can be adjusted through training to better predict and generate accurate outputs

Parameters are primarily two types: 1. Weights — connections between neurons across different layers of LLM. Weights determine how much influence one neuron’s output will have on other neuron’s activation

2. Biases — a weighting factor generally added before neuron activation to shift the model left or right, which helps generate better output

Another distinction that is commonly used exists between Model parameters and prompt parameters. Model Parameters can be used at multiple levels in a LLM

  1. Training — Parameters can be adjusted to capture the relationships and language structures better
  2. Context and Meaning — Parameters enable LLMs to capture context. For ex, in a transformer-based model, parameters can help a model understand words in a sentence are relevant to each other.
  3. Text Generation — Parameters can determine how a model constructs sentences and maintains coherence
  4. Model Size — The most common usage tied to Parameters. The # of parameters is generally connected to a model size. Although the model size does not necessarily imply it is a better model, the notion exists.
  5. Fine-Tuning — Using Bias Parameters, models can be fine-tuned for a specific task.
Model and Prompt Parameters

Prompt Parameters, on the other hand, refer to the variables or elements that are part of the input given to the model.

  1. Input Text: The prompt's actual text guides the model on the expected response or output.
  2. Control Tokens or Instructions: These might include special tokens or structured instructions that guide the model’s response style, length, or content.
  3. Contextual Information: Any background or contextual data included in the prompt helps the model understand the context it needs to generate a response.
  4. Parameters for Specificity: In some advanced uses, prompt parameters can include instructions on specificity or creativity, guiding the model on how closely it should stick to known information versus generating novel content.

Developer: Prompt Parameters? Are we talking about Prompt Engineering here?

Yes, this takes us to the next major topic — Prompting.

The method of providing a model with a specific input to elicit desired output or response

A prompt can be a simple question or a large set of instructions with examples and can take many shapes:

  • Direct Instruction
  • Question-Based
  • Conversational
  • Creative Prompting
  • Zero-Shot or Few-Shot Learning

Prompt Engineering is referred to the design and optimization of these prompt patterns

Let’s look at examples for each style of Prompting

Direct Instruction

User: Analyze the following text for emotional tone and key themes, then summarize your findings: The Atlantic puffin (Fratercula arctica) is a seabird species in the auk family and is the only puffin native to the Atlantic Ocean. It has a black crown and back, pale grey cheek patches and white underparts and its broad, boldly marked red and black beak and orange legs contrast with its otherwise sombre plumage. The Atlantic puffin spends the autumn and winter at sea, mainly in the North Atlantic, and returns to land at the start of the breeding season in late spring.

LLM: The provided text describes the Atlantic puffin (Fratercula arctica), focusing primarily on its physical characteristics and migration patterns. The emotional tone of the text is neutral and informative, devoid of personal opinion or emotional language.

Key themes in the text include:

  1. Species Identification
  2. Physical Description
  3. Habitat and Behavior

Question — Based

User: Can you explain how blockchain technology works and its potential financial industry implications?

This prompting style requires the model to provide relevant information on blockchain technology and delve into its specific applications in the financial sector.

Conversational

User: I’ve been thinking about switching careers but am unsure about the risks involved. What should I consider before deciding, and how can I prepare for a career transition?

This prompt engages the model in a more nuanced conversation. It seeks guidance on a complex personal decision, inviting the model to provide thoughtful considerations and practical advice for a career change.

Creative Prompting

User: Create a story set in a dystopian future where humans coexist with advanced AI. The narrative should focus on a human protagonist who discovers a hidden truth about the AI that changes their perception of reality.

This style of prompting invites the model to be creative and craft a detailed and imaginative story based on the elements provided

Zero-Shot Learning

User: Explain the principle behind solar panels and how they contribute to sustainable energy. Also, discuss the challenges in their widespread adoption.

The model is prompted to provide detailed information on a topic (solar panels) without prior examples, relying on its pre-trained knowledge to explain the technology and discuss its benefits and challenges.

Few-Shot Prompting

Few-Shot Prompting example

This style focuses on providing some examples followed by a new question. The expectation is for the model to use the examples and respond in the same format and depth of explanation.

Developer: Okay, so far we have covered Tokenization, Embedding, Parameters and Prompting. Is there anything else?

Yes, the last piece of the puzzle is Fine Tuning, which refers to the process of taking a pre-trained model and further training it on a specific smaller dataset to specialize its capabilities.

Below are Key aspects of fine-tuning:

  1. Pre-Trained Models: Fine-tuning starts with a model already trained on a large, general dataset. This pre-training equips the model with a broad understanding of language, context, and general knowledge.
  2. Specialized Dataset: Fine-tuning involves training the model further on a dataset specific to the desired task or domain. For example, if you want the model to perform well in medical diagnostics, you would fine-tune it on medical texts.
  3. Adjusting Parameters: During fine-tuning, the model’s parameters (weights and biases) are slightly adjusted to fit the specifics of the new data. This adjustment is typically smaller and more focused than the initial broad-scale training.
  4. Reduced Training Time: Since the model is already pre-trained, fine-tuning is usually quicker and requires less data than training a model from scratch.
  5. Task-Specific Performance: The goal of fine-tuning is to enhance the model’s performance on a specific task, making it more accurate, relevant, and effective in that particular area.

A great example of Fine-tuning is GPTs by OpenAI which are custom versions of ChatGPT that can be created for a specific purpose

Developer: This is a great start. Is there anything else?

That’s pretty much it. To succeed in today's tech landscape, it's vital for developers to understand LLM models and the nuances of prompting and fine-tuning.

Remember, they are not just tools for today but a foundation for a future where the interaction between humans and machines becomes more seamless, intelligent, and beneficial for all.

Thanks for reading!

Machine Learning
AI
Prompt Engineering
Software Engineering
Technology
Recommended from ReadMedium