0%

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