Developing Apps with GPT-4 and ChatGPT

Book description

This minibook is a comprehensive guide for Python developers who want to learn how to build applications with large language models. Authors Olivier Caelen and Marie-Alice Blete cover the main features and benefits of GPT-4 and ChatGPT and explain how they work. You'll also get a step-by-step guide for developing applications using the GPT-4 and ChatGPT Python library, including text generation, Q&A, and content summarization tools.

Written in clear and concise language, Developing Apps with GPT-4 and ChatGPT includes easy-to-follow examples to help you understand and apply the concepts to your projects. Python code examples are available in a GitHub repository, and the book includes a glossary of key terms. Ready to harness the power of large language models in your applications? This book is a must.

You'll learn:

  • The fundamentals and benefits of ChatGPT and GPT-4 and how they work
  • How to integrate these models into Python-based applications for NLP tasks
  • How to develop applications using GPT-4 or ChatGPT APIs in Python for text generation, question answering, and content summarization, among other tasks
  • Advanced GPT topics including prompt engineering, fine-tuning models for specific tasks, plug-ins, LangChain, and more

Table of contents

  1. Preface
    1. Conventions Used in This Book
    2. Using Code Examples
    3. O’Reilly Online Learning
    4. How to Contact Us
    5. Acknowledgments
  2. 1. GPT-4 and ChatGPT Essentials
    1. Introducing Large Language Models
      1. Exploring the Foundations of Language Models and NLP
      2. Understanding the Transformer Architecture and Its Role in LLMs
      3. Demystifying the Tokenization and Prediction Steps in GPT Models
    2. A Brief History: From GPT-1 to GPT-4
      1. GPT-1
      2. GPT-2
      3. GPT-3
      4. From GPT-3 to InstructGPT
      5. GPT-3.5, Codex, and ChatGPT
    3. LLM Use Cases and Example Products
      1. Be My Eyes
      2. Morgan Stanley
      3. Khan Academy
      4. Duolingo
      5. Yabble
      6. Waymark
      7. Inworld AI
    4. Beware of AI Hallucinations: Limitations and Considerations
    5. Optimizing GPT Models with Plug-ins and Fine-Tuning
    6. Summary
  3. 2. A Deep Dive into the GPT-4 and ChatGPT APIs
    1. Essential Concepts
    2. Models Available in the OpenAI API
    3. Trying GPT Models with the OpenAI Playground
    4. Getting Started: The OpenAI Python Library
      1. OpenAI Access and API Key
      2. “Hello World” Example
    5. Using ChatGPT and GPT-4
      1. Input Options for the Chat Completion Endpoint
      2. Output Result Format for the Chat Completion Endpoint
      3. From Text Completions to Functions
    6. Using Other Text Completion Models
      1. Input Options for the Text Completion Endpoint
      2. Output Result Format for the Text Completion Endpoint
    7. Considerations
      1. Pricing and Token Limitations
      2. Security and Privacy: Caution!
    8. Other OpenAI APIs and Functionalities
      1. Embeddings
      2. Moderation Model
      3. Whisper and DALL-E
    9. Summary (and Cheat Sheet)
  4. 3. Building Apps with GPT-4 and ChatGPT
    1. App Development Overview
      1. API Key Management
      2. Security and Data Privacy
    2. Software Architecture Design Principles
    3. LLM-Powered App Vulnerabilities
      1. Analyzing Inputs and Outputs
      2. The Inevitability of Prompt Injection
    4. Example Projects
      1. Project 1: Building a News Generator Solution
      2. Project 2: Summarizing YouTube Videos
      3. Project 3: Creating an Expert for Zelda BOTW
      4. Project 4: Voice Control
    5. Summary
  5. 4. Advanced GPT-4 and ChatGPT Techniques
    1. Prompt Engineering
      1. Designing Effective Prompts
      2. Thinking Step by Step
      3. Implementing Few-Shot Learning
      4. Improving Prompt Effectiveness
    2. Fine-Tuning
      1. Getting Started
      2. Fine-Tuning with the OpenAI API
      3. Fine-Tuning Applications
      4. Generating and Fine-Tuning Synthetic Data for an Email Marketing Campaign
      5. Cost of Fine-Tuning
    3. Summary
  6. 5. Advancing LLM Capabilities with the LangChain Framework and Plug-ins
    1. The LangChain Framework
      1. Dynamic Prompts
      2. Agents and Tools
      3. Memory
      4. Embeddings
    2. GPT-4 Plug-ins
      1. Overview
      2. The API
      3. The Plug-in Manifest
      4. The OpenAPI Specification
      5. Descriptions
    3. Summary
    4. Conclusion
  7. Glossary of Key Terms
  8. Index
  9. About the Authors

Product information

  • Title: Developing Apps with GPT-4 and ChatGPT
  • Author(s): Olivier Caelen, Marie-Alice Blete
  • Release date: September 2023
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781098152482