Lecture: Large Language Models (LLMs) and Prompt Engineering

Jul 10, 2024

Lecture: Large Language Models (LLMs) and Prompt Engineering

Overview

  • LLMs are directed using natural language prompts.
  • Multimodal models like Google’s Gemini can take various input prompts like text, images, or audio.
  • Practice known as prompt engineering involves refining prompts to achieve optimal outcomes.

Influence of Input on Output

  • Input drastically influences the LLM's output.
  • Crafting inputs carefully guides the LLM to give the best responses.
  • Natural language provides expressivity but also potential variance in prompting and results.

Best Practices for Consistent Results

  • Zero and Few Shot Prompts: Helps in various tasks based on examples provided.
    • Zero Shot: Model uses pre-trained knowledge without specific training/examples (e.g., knowing Paris is the capital of France).
    • Few Shot: Provides few examples to guide the model for specific tasks (e.g., sentiment analysis with labeled examples like “I love sunny days” as positive).
    • Other Shot Types: Includes one-shot and k-shot prompts.

Google AI Studio Demonstration

  • Standalone environment to experiment with Gemini prompts and model tuning.
  • Interface includes various parameters for configuring the model.
    • System Instructions: Controls specific output elements, like verbiage, length, and literary style (e.g., answering in a paragraph vs. a haiku).
      • System instructions can set overarching rules for response generation.
    • Model Type: Option to select pre-built models like Gemini 1.5 Flash or custom fine-tuned models.
    • Token Count: Basic units of input/output, influences context model considers (Gemini supports over 1 million tokens).
    • Temperature: Measure of AI creativity in responses.
      • Higher temperature = more creative responses.
      • Temperature of zero = deterministic, similar responses.
    • Stop Sequence: Control length and structure of responses (e.g., adding a stop sequence of “water” stops response before the word).
    • Safety Settings: Ensure model generates safe content.

Key Takeaways

  • Robust models like Gemini can adapt to various rules through prompt engineering.
  • Parameters help configure and guide the model’s behavior and output.
  • Google AI Studio provides a practical environment for experimenting with different prompting techniques.