Exploring GPT-3

Book description

Get started with GPT-3 and the OpenAI API for natural language processing using JavaScript and Python

Key Features

  • Understand the power of potential GPT-3 language models and the risks involved
  • Explore core GPT-3 use cases such as text generation, classification, and semantic search using engaging examples
  • Plan and prepare a GPT-3 application for the OpenAI review process required for publishing a live application

Book Description

Generative Pre-trained Transformer 3 (GPT-3) is a highly advanced language model from OpenAI that can generate written text that is virtually indistinguishable from text written by humans. Whether you have a technical or non-technical background, this book will help you understand and start working with GPT-3 and the OpenAI API.

If you want to get hands-on with leveraging artificial intelligence for natural language processing (NLP) tasks, this easy-to-follow book will help you get started. Beginning with a high-level introduction to NLP and GPT-3, the book takes you through practical examples that show how to leverage the OpenAI API and GPT-3 for text generation, classification, and semantic search. You'll explore the capabilities of the OpenAI API and GPT-3 and find out which NLP use cases GPT-3 is best suited for. You’ll also learn how to use the API and optimize requests for the best possible results. With examples focusing on the OpenAI Playground and easy-to-follow JavaScript and Python code samples, the book illustrates the possible applications of GPT-3 in production.

By the end of this book, you'll understand the best use cases for GPT-3 and how to integrate the OpenAI API in your applications for a wide array of NLP tasks.

What you will learn

  • Understand what GPT-3 is and how it can be used for various NLP tasks
  • Get a high-level introduction to GPT-3 and the OpenAI API
  • Implement JavaScript and Python code examples that call the OpenAI API
  • Structure GPT-3 prompts and options to get the best possible results
  • Select the right GPT-3 engine or model to optimize for speed and cost-efficiency
  • Find out which use cases would not be suitable for GPT-3
  • Create a GPT-3-powered knowledge base application that follows OpenAI guidelines

Who this book is for

Exploring GPT-3 is for anyone interested in natural language processing or learning GPT-3 with or without a technical background. Developers, product managers, entrepreneurs, and hobbyists looking to get to grips with NLP, AI, and GPT-3 will find this book useful. Basic computer skills are all you need to get the most out of this book.

Table of contents

  1. Exploring GPT-3
  2. Foreword
  3. Contributors
  4. About the author
  5. Acknowledgments
  6. About the reviewers
  7. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Reviews
  8. Section 1: Understanding GPT-3 and the OpenAI API
  9. Chapter 1: Introducing GPT-3 and the OpenAI API
    1. Technical requirements
    2. Introduction to GPT-3
      1. Simplifying NLP
      2. What exactly is GPT-3?
    3. Democratizing NLP
    4. Understanding prompts, completions, and tokens
      1. Prompts
      2. Completions
      3. Tokens
    5. Introducing Davinci, Babbage, Curie, and Ada
      1. Davinci
      2. Curie
      3. Babbage
      4. Ada
      5. Content filtering model
      6. Instruct models
      7. A snapshot in time
    6. Understanding GPT-3 risks
      1. Inappropriate or offensive results
      2. Potential for malicious use
    7. Summary
  10. Chapter 2: GPT-3 Applications and Use Cases
    1. Technical requirements
    2. Understanding general GPT-3 use cases
    3. Introducing the Playground
      1. Getting started with the Playground
    4. Handling text generation and classification tasks
      1. Text generation
      2. Text classification
    5. Understanding semantic search
      1. The Semantic Search tool
    6. Summary
  11. Section 2: Getting Started with GPT-3
  12. Chapter 3: Working with the OpenAI Playground
    1. Technical requirements
    2. Exploring the OpenAI developer console
      1. Developer documentation
      2. Developer resources
      3. Accounts and organizations
      4. Pricing and billing
      5. Usage reporting
      6. Member management
    3. Diving deeper into the Playground
      1. Choosing the right engine
      2. Response length
      3. Temperature and Top P
      4. Frequency and presence penalty
      5. Best of
      6. Stop sequence
      7. Inject Start Text and Inject Restart Text
      8. Show Probabilities
    4. Working with presets
      1. Grammatical Standard English
      2. Text to command
      3. Parse unstructured data
    5. Summary
  13. Chapter 4: Working with the OpenAI API
    1. Technical requirements
    2. Understanding APIs
    3. Getting familiar with HTTP
      1. Uniform resource identifiers
      2. HTTP methods
      3. The HTTP body
      4. HTTP headers
      5. HTTP response status codes
    4. Reviewing the OpenAI API endpoints
      1. List Engines
      2. Retrieve Engine
      3. Create Completions
      4. Semantic Search
    5. Introducing CURL and Postman
    6. Understanding API authentication
      1. Keeping API keys private
    7. Making an authenticated request to the OpenAI API
      1. Working with multiple organizations
    8. Introducing JSON
    9. Using the Completions endpoint
    10. Using the Semantic Search endpoint
    11. Summary
  14. Chapter 5: Calling the OpenAI API in Code
    1. Technical requirements
    2. Choosing your programming language
    3. Introducing replit
      1. Creating a repl
      2. Setting your OpenAI API key as an environment variable
      3. Understanding and creating the .replit file
    4. Using the OpenAI API with Node.js/JavaScript
      1. Calling the engines endpoint
      2. Calling the Completions endpoint
      3. Calling the search endpoint
    5. Using the OpenAI API in Python
      1. Calling the completions endpoint
      2. Calling the search endpoint
    6. Using other programming languages
    7. Summary
  15. Section 3: Using the OpenAI API
  16. Chapter 6: Content Filtering
    1. Technical requirements
    2. Preventing inappropriate and offensive results
    3. Understanding content filtering
    4. Testing the content filtering process
    5. Filtering content with JavaScript
      1. Flagging unsafe words with Node.js/JavaScript
    6. Filtering content with Python
      1. Flagging unsafe words with Python
    7. Summary
  17. Chapter 7: Generating and Transforming Text
    1. Technical requirements
    2. Using the examples
    3. Generating content and lists
      1. Dumb joke generator
      2. Mars facts (in most cases)
      3. Webinar description generator
      4. Book suggestions
      5. Children's book generator
    4. Translating and transforming text
      1. Acronym translator
      2. English to Spanish
      3. JavaScript to Python
      4. Fifth-grade summary
      5. Grammar correction
    5. Extracting text
      1. Extracting keywords
      2. HTML parsing
      3. Extracting a postal address
      4. Extracting an email address
    6. Creating chatbots
      1. A simple chatbot
    7. Summary
  18. Chapter 8: Classifying and Categorizing Text
    1. Technical requirements
    2. Understanding text classification
      1. Using the completions endpoint for text classification
      2. Content filtering is a text classification task
    3. Introducing the classifications endpoint
      1. Uploading files
    4. Implementing sentiment analysis
    5. Assigning an ESRB rating to text
    6. Classifying text by language
    7. Classifying text from keywords
    8. Summary
  19. Chapter 9: Building a GPT-3-Powered Question-Answering App
    1. Technical requirements
    2. Introducing GPT Answers
      1. GPT Answers technical overview
      2. Hosting the app
    3. Introducing the Answers endpoint
    4. Setting up and testing Express
    5. Creating the API endpoint for GPT Answers
      1. Creating the API endpoint
      2. Testing our API with Postman
    6. Creating the GPT Answers user interface
    7. Integrating the Answers endpoint
    8. Generating relevant and factual answers
    9. Using files with the Answers endpoint
    10. Summary
  20. Chapter 10: Going Live with OpenAI-Powered Apps
    1. Technical requirements
    2. Going live
    3. Understanding use case guidelines
    4. Addressing potential approval issues
      1. Content filtering
      2. Input and output lengths
      3. Request rate limiting
    5. Completing the pre-launch review request
      1. High-level use case questions
      2. Security and risk mitigation questions
      3. Growth plan questions
      4. Wrapping-up questions
    6. Summary
    7. Why subscribe?
  21. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Leave a review - let other readers know what you think

Product information

  • Title: Exploring GPT-3
  • Author(s): Steve Tingiris
  • Release date: August 2021
  • Publisher(s): Packt Publishing
  • ISBN: 9781800563193