3. OpenAI API Python - Earnings Call Summarization

Part Time Larry
21 Dec 202220:53

Summary

TLDRThis video script offers a tutorial on utilizing OpenAI's API with Python to perform tasks like summarizing earnings calls. It guides viewers through installing the OpenAI package, obtaining an API key, and crafting prompts for the AI model. The script demonstrates the process of summarization by breaking down a lengthy earnings call transcript into manageable chunks and using the API to generate concise summaries for each part. The tutorial emphasizes the importance of understanding basic functionalities to build more complex applications and hints at future videos exploring real-time speech transcription and text classification.

Takeaways

  • 🧑‍💻 The power of OpenAI is fully realized when developers interact with it through computer programs using its API, allowing dynamic crafting of prompts and processing of outputs for unique tasks.
  • 📚 To start with OpenAI's API in Python, one must first install the OpenAI Python package using the pip command 'pip install openai'.
  • 🔑 Users need to sign up on OpenAI's website to obtain an API key, which is essential for accessing the API and managing credits for the services used.
  • 💡 OpenAI provides free credits worth $18 to new users, which is a good starting point to learn and experiment with the API without incurring costs.
  • 💰 The API key is necessary for billing purposes, as using OpenAI's services will eventually require payment when the free credits are exhausted.
  • 📈 OpenAI's models, such as Ada and DaVinci, have different costs associated with them based on the complexity and capabilities of the model.
  • 📝 The script demonstrates a basic task of using the OpenAI API to answer questions and generate summaries, starting with a simple Q&A prompt and moving to summarizing earnings calls.
  • 🔍 The script also covers how to handle large text data by chunking it into smaller parts to comply with OpenAI's token limit for processing.
  • 🔄 The process of summarizing long documents involves breaking down the text, sending chunks to OpenAI for summarization, and then combining the results into a cohesive summary.
  • 🛠️ The script provides a foundation for building more complex applications, such as those that process audio, text, and video, and perform natural language processing tasks.
  • 🔮 The tutorial encourages users to explore OpenAI's capabilities further and consider building applications that can leverage its advanced features for various use cases.

Q & A

  • What is the main purpose of the video script?

    -The main purpose of the video script is to demonstrate how to use OpenAI's API with Python to perform tasks such as summarizing earnings calls and to introduce viewers to the capabilities of AI for developers.

  • How can one start using OpenAI's API?

    -To start using OpenAI's API, one needs to install the OpenAI Python package using pip, obtain an API key from the OpenAI website, and then configure the API key in the Python code.

  • What is the significance of an API key in using OpenAI's services?

    -An API key is significant as it ties the usage of OpenAI's services to an individual account, allowing for tracking of usage and billing, ensuring that each user's credits are managed separately.

  • Why might OpenAI start charging for its services in the future?

    -OpenAI might start charging for its services in the future because running cloud infrastructure and making machine learning models available as a service incurs substantial costs.

  • What is the initial credit provided by OpenAI for new users?

    -OpenAI provides 18 dollars worth of credits for free to new users, allowing them to try out the service and learn how to use it.

  • How can the OpenAI API be used to summarize text?

    -The OpenAI API can be used to summarize text by sending a prompt with the text to be summarized appended with 'tldr' to the OpenAI completion endpoint, which will then return a summarized version of the text.

  • What is the limitation on the maximum content length for the OpenAI API?

    -The OpenAI API has a maximum content length limit of 4096 tokens, which means that very long texts need to be chunked into smaller parts before being sent for processing.

  • How can the text of an earnings call be obtained for summarization?

    -The text of an earnings call can be obtained by using the Python requests library to fetch the text from a URL where the transcript is available online.

  • What is the approach to handle long texts when the OpenAI API has a token limit?

    -The approach to handle long texts is to chunk the text into smaller parts, summarize each part individually using the OpenAI API, and then combine the summaries to form a complete summary of the original text.

  • What are some potential future applications of the OpenAI API as mentioned in the script?

    -Some potential future applications of the OpenAI API include real-time speech transcription, text classification for sentiment analysis, and building full-stack applications that process various types of data like sound, text, and video.

Outlines

00:00

🚀 Getting Started with OpenAI's API

This paragraph introduces the capabilities of OpenAI's large language model, emphasizing the interactive experience provided by the Open AI playground and the powerful API available to developers. It outlines the process of installing the OpenAI Python package, obtaining an API key, and configuring the environment for API use. The speaker also discusses the cost implications of using the API, including the initial free credit and the potential future costs associated with extensive use, highlighting the balance between cost and the convenience of leveraging AI without training custom models.

05:01

📚 Exploring OpenAI's API Features and Prompts

The speaker delves into the various examples and prompts available within the OpenAI API, demonstrating how to interact with the API using Python to perform tasks like answering questions or summarizing text. The paragraph highlights the importance of crafting specialized prompts to achieve desired outcomes from the AI model. It also touches on the different models offered by OpenAI, such as Ada and DaVinci, and their respective costs, emphasizing the need to choose the right model based on the task's complexity.

10:03

🔍 Summarizing Earnings Calls with OpenAI

This section focuses on a practical application of the OpenAI API: summarizing earnings calls. The speaker describes the process of transcribing audio to text and then using the API to generate summaries with the 'TLDR' prompt. The paragraph discusses the limitations of the API in terms of content length and introduces a method for dividing the text into manageable chunks to overcome these limitations, providing a step-by-step approach to summarizing large documents effectively.

15:04

📈 Implementing Text Chunking for API Summarization

The speaker provides a detailed explanation of how to chunk long texts into smaller segments for summarization using the OpenAI API. This includes splitting the text into an array of words, dividing it into equal-sized chunks, and then joining these chunks back into sentences for summarization. The paragraph demonstrates the process of summarizing each chunk individually and then combining the summaries to form a comprehensive summary of the entire document.

20:06

🌟 Building Complex Applications with OpenAI API

In the final paragraph, the speaker envisions the potential for building more complex applications using the OpenAI API, starting from mastering simple tasks and gradually incorporating more sophisticated functionalities. The speaker expresses optimism about the future of AI applications and invites viewers to share ideas for specific use cases they would like to see demonstrated with OpenAI. The paragraph concludes with a teaser for upcoming videos that will explore real-time speech transcription and text classification, among other advanced topics.

Mindmap

Keywords

💡API

API stands for 'Application Programming Interface,' which is a set of rules and protocols that allows different software applications to communicate with each other. In the context of the video, the OpenAI API is highlighted as a powerful tool that enables developers to integrate AI capabilities, such as language models, into their own computer programs. The script discusses the process of using the OpenAI API with Python to perform tasks like summarizing text.

💡GPT (Generative Pre-trained Transformer)

GPT is an abbreviation for 'Generative Pre-trained Transformer,' which is a type of AI language model developed by OpenAI. The video script mentions experimenting with GPT through the OpenAI playground, showcasing its ability to generate creative and responsive text based on user prompts. The script also refers to various models like GPT-3 and DaVinci, indicating the evolution and capabilities of these models.

💡Language Model

A language model is an AI system that is trained to predict and generate human-like text based on the input it receives. The video emphasizes the capabilities of large language models like GPT to produce creative outputs and perform tasks such as summarizing earnings calls, which is a key demonstration in the script.

💡Summarization

Summarization refers to the process of condensing a large piece of text into a shorter version while retaining the main points. In the video script, the task of summarizing earnings call transcripts is used as an example of how the OpenAI API can be utilized to process and distill information efficiently, as demonstrated by appending 'TLDR' to a prompt for the AI to generate a summary.

💡Token

In the context of AI and language models, a token typically refers to a unit of text, which could be a word, a number, or a punctuation mark. The script mentions 'per thousand tokens' in relation to the cost of using certain models like Ada and DaVinci, indicating that the pricing is based on the amount of text processed by the AI.

💡DaVinci Model

The DaVinci model is a specific version of the GPT language model, known for its advanced capabilities in generating human-like text. The video script discusses using the DaVinci model for tasks that require more sophistication, such as creative storytelling or advanced summarization, and notes that it comes at a higher cost due to its capabilities.

💡Earnings Call

An earnings call is a conference call that publicly traded companies typically hold to discuss their financial performance with investors and analysts. The script uses the task of summarizing an earnings call transcript as an example to demonstrate the practical application of the OpenAI API in processing and summarizing large amounts of financial and business-related text.

💡Python Package

A Python package is a collection of Python modules, libraries, or other packages that serve a specific purpose. The video script instructs viewers on installing the 'openai' Python package using the pip command, which allows developers to interact with the OpenAI API and utilize its features within their Python programs.

💡API Key

An API key is a unique code that identifies an application making requests to an API. In the script, the process of obtaining an API key from the OpenAI platform is described as a necessary step for developers to authenticate their applications and gain access to the API's capabilities, such as calling different models like GPT-3 or Codex.

💡Machine Learning Model

A machine learning model is an algorithm that learns patterns from data and makes decisions or predictions based on that learning. The video script refers to the costs associated with running these models as a service, indicating that while the initial use may be free, there are expenses involved in maintaining and providing access to these advanced AI models.

Highlights

Introduction to the power of AI and its creative output through the Open AI Playground.

The capability of developers to interact with OpenAI through a powerful API for dynamic tasks.

Tutorial on getting started with OpenAI's API using Python for summarizing earnings calls.

Installation of the OpenAI Python package using pip and importing it for use.

Explanation of obtaining and securing an API key from the OpenAI website.

The necessity of an API key for accessing the service and managing credits.

Details on the cost associated with different OpenAI models and their usage in applications.

Demonstration of using the OpenAI API to answer questions like 'Who is the best investor of all time?'

The process of crafting specialized prompts for the OpenAI API to perform unique tasks.

Experimentation with different parameters like 'temperature' to control randomness in responses.

Method of handling text length limitations by chunking data for processing by OpenAI.

Technique for summarizing long earnings call transcripts by breaking them into smaller pieces.

Example of summarizing the first 1/6th of an earnings call document using OpenAI.

Collating summaries from multiple text chunks to form a comprehensive summary.

Final summary of an earnings call highlighting key financial figures and business insights.

Discussion on the potential for building more complex applications using the OpenAI API.

Invitation for viewers to suggest specific applications or tasks for future OpenAI demonstrations.

Transcripts

play00:00

over the past several weeks millions of

play00:01

people have been experimenting with chat

play00:03

GPT and the open AI playground by typing

play00:06

in a specialized text prompt into a text

play00:08

area and clicking submit users are able

play00:11

to witness the power of AI right in

play00:13

front of their faces and see the very

play00:15

creative output that can be produced by

play00:17

this large language model but the real

play00:19

power of open AI comes when you are a

play00:22

developer who is able to interact with

play00:24

openai from a computer program openai

play00:27

provides a very powerful API that allows

play00:30

us to call gpt3 codex and Dolly from our

play00:34

computer programs allowing us to

play00:36

dynamically craft specialized prompts

play00:38

and process that output in order to

play00:40

perform very unique and interesting

play00:42

tasks and build applications that do

play00:45

whatever we want to do with AI without

play00:47

training our own models in this tutorial

play00:49

I'm going to show you how to get started

play00:51

with openai's API and Python and we're

play00:54

going to start with a very simple task

play00:56

which is summarizing earnings calls from

play00:59

there we'll be able to build more and

play01:00

more complex things but I want to start

play01:02

with a very basic task and get people up

play01:04

and running with open AI first and then

play01:06

we'll begin to build more and more

play01:08

complex applications if you've never

play01:10

written code to interact with the open

play01:12

AI API I've included a Google collab

play01:15

notebook down below where you can follow

play01:16

along exactly with what you see here

play01:18

execute the code and see how all this

play01:21

works so to get started with the open AI

play01:23

API from python the first thing we need

play01:25

to do is install the open AI python

play01:28

package and to do this you just run this

play01:30

pip command pip install openai and

play01:32

that's going to use the python package

play01:34

manager to install open AI once you see

play01:37

that the package is installed right

play01:39

there you see the check mark we need to

play01:41

import the open AI package very easy

play01:44

right the next thing you need to do is

play01:46

if you don't have an account on open AI

play01:48

already you need to visit this API page

play01:51

here and sign up and when you do that

play01:53

you'll be able to log in with your

play01:55

account so you sign up there I just used

play01:57

my Google account so it'll just log me

play01:59

right in and and what you're going to

play02:00

need to do is visit this view API Keys

play02:03

page right here and what you can do is

play02:05

create a new secret key so I'm going to

play02:07

click that and I'm going to delete this

play02:09

key right afterwards but you'll get this

play02:10

key and you can copy it right there to

play02:13

your clipboard and then you can paste it

play02:15

in down below and you can delete these

play02:17

if you're worried that someone gets it

play02:18

you can just delete them I'm going to

play02:19

delete that one right after this

play02:21

tutorial so what I'm doing here is

play02:23

configuring open AI to use this API key

play02:27

and so you can either set that as a

play02:28

string right here but since I want to

play02:30

show a an API key on here without

play02:34

showing it to you I realize I already

play02:35

did but what you can do is you can just

play02:38

import this Library called get pass if

play02:40

you run this it'll actually prompt it

play02:42

prompt you for it and I'm going to paste

play02:44

a new one right there that you've never

play02:46

seen before right I paste it in and I

play02:49

click enter it should be done and now

play02:51

open AI should have access to this API

play02:54

key now why do you need an API key what

play02:56

do you mean I've been using chat gbt and

play02:58

typing stuff in the Box and it's been

play03:00

free no once uh mentioned anything about

play03:02

an API key well I don't expect this free

play03:05

stuff to last forever when you sign up

play03:06

for open AI they give you 18 worth of

play03:09

credits free and this is enough to

play03:11

actually use it quite a bit you can

play03:12

probably run thousands and thousands of

play03:14

requests on this thing and learn how to

play03:16

use it and all of that but actually

play03:18

running all this Cloud infrastructure

play03:20

and making this machine learning model

play03:22

available as a service I think costs a

play03:24

substantial amount of money for them so

play03:26

I expect that over time that they'll

play03:28

begin to charge money for a lot of this

play03:31

stuff now is that worth it for you for

play03:33

me it personally is I have plenty of

play03:35

money and I'm willing to pay for things

play03:37

in order to accomplish tasks and to be

play03:39

able to train these models on my own

play03:41

would take so much time and buying like

play03:43

Nvidia gpus and all the things I would

play03:45

need to do this and running this service

play03:47

myself would cost a lot of money so if I

play03:49

can spend a few bucks a month and run

play03:51

all this these cool summaries and build

play03:53

an entire startup on top of it or do

play03:56

something that helps me financially then

play03:58

I would love to to use this and I'm

play04:00

happy to pay for it and I've actually

play04:02

already done that and I'm spending a few

play04:03

bucks at this point but I was able to

play04:05

get by I think you can get by for a

play04:07

month on just this 18 and learn this so

play04:10

definitely a sign up and it's definitely

play04:11

worth it and the reason there's an API

play04:13

key is so it can tie it to you and so

play04:15

you have your own credits and you'll get

play04:17

this uh billing screen if you haven't

play04:19

used it yet but there's this December

play04:21

usage and you can see this isn't my main

play04:23

account but it'll show the number of

play04:24

times you call it and there's a whole

play04:26

section where it shows how much it costs

play04:28

to call each one of these machine

play04:31

learning models so you can see

play04:32

generating all these images cost a

play04:34

couple cents and using these language

play04:36

models if you use this smaller model

play04:38

called Ada it's .0004 cents per thousand

play04:42

tokens and if you use the most powerful

play04:43

DaVinci model it's two cents per

play04:45

thousand tokens and so you can send it

play04:47

tons and tons of text and it'll charge

play04:51

fractions of a Cent and then over time

play04:52

you think if you built some startup

play04:54

that's worth millions of dollars on top

play04:56

of this and called it thousands of times

play04:57

this would add up over time right and so

play05:00

you know to come up with your your use

play05:03

case for it and decide if this thing is

play05:05

going to be worth it for you but for now

play05:06

it's absolutely free and you can try it

play05:08

out uh with no cost so I recommend

play05:11

trying it out and learning about this

play05:13

stuff and I think ultimately

play05:15

um there will be more and more versions

play05:16

of this maybe not run by open AI but but

play05:19

by someone else for instance stable

play05:20

diffusion I can run it on my MacBook

play05:23

right here and run it for absolutely

play05:25

free and it doesn't go through an API I

play05:27

can download it and run it right here

play05:28

and open AI whisper which I ran in the

play05:31

in the last video if you watch that that

play05:33

does live speech transcription that's

play05:35

absolutely free and we're able to just

play05:36

run it on our own machine but uh this

play05:39

latest DaVinci 3 Model right here I need

play05:42

to access it through the API and using

play05:44

chat GPT cost a lot of resources and so

play05:47

that's why there's an API key here so

play05:49

once we have the API key configured then

play05:51

we just need to call openai with one of

play05:54

these prompts and so I recommend if you

play05:56

haven't done so already I assume a lot

play05:58

of people here have already done this

play05:59

but if you click around they have these

play06:01

examples here and can look at some of

play06:03

the powerful prompts that can be sent

play06:05

here so they have like a q a where you

play06:07

can ask it a question they have a a text

play06:10

command they have natural language to

play06:12

open AI API there's a SQL translate

play06:14

where you can send in a database

play06:16

structure we'll play with that later so

play06:18

send it a database structure and have a

play06:20

query and maybe build some kind of a

play06:21

stock screener on top of that there's

play06:24

parsing unstructured data python to

play06:26

natural language so this takes code

play06:28

translates it in a to natural language

play06:31

so it tells you what the code does and

play06:33

so the first thing we can try is just

play06:35

this q a and it shows you what the

play06:37

prompt looks like and you can say open

play06:38

in the playground here and type this

play06:41

prompt directly in and so I can ask of

play06:44

you know who is the best investor right

play06:46

and as you probably know you can't just

play06:48

ask it anything especially about Finance

play06:50

it doesn't know like real-time price

play06:51

date or anything and so I don't want

play06:53

anyone to be misled into thinking you

play06:55

can ask in any Financial question that's

play06:56

going to give some great answer for you

play06:58

it turns down out a lot of those

play07:00

questions but it doesn't mean it's not

play07:03

extremely useful for financial tests so

play07:05

if I say who is the best investor of all

play07:08

time right it probably has an answer for

play07:09

that

play07:10

right if I click that it just says

play07:13

Warren Buffett just like that and or I

play07:15

can say who are the best investors of

play07:17

all time so who are the best investors

play07:19

of all time let's see if it understands

play07:21

multiple right George Warren Buffett

play07:24

George Torres Carl icon Ray dalio

play07:26

generally considered some of the best

play07:27

investors of all time so there's no real

play07:29

absolute there and it has some knowledge

play07:31

it's trained on all this text and knows

play07:33

you know these guys are investors that

play07:34

are highly acclaimed or widely praised

play07:37

right and so what we can do how do we

play07:39

call this from the open AI API this is

play07:42

one interface for openai but the

play07:44

powerful power as I mentioned is

play07:46

creating our own unique interfaces that

play07:49

allow the user to interact with and

play07:50

enter these prompts in interesting ways

play07:53

and so what we want to do is take this

play07:55

exact prompt right and send it over uh

play07:58

using python code and so we can do is

play08:00

using this open AI python package we can

play08:03

send this prompt and so same way we had

play08:06

this I'm highly intelligent question

play08:07

answering box ask me a question blah

play08:09

blah blah I can say who is the the

play08:11

greatest investor of all time and notice

play08:12

I have these Carriage returns in here

play08:14

back just and backslash n right and

play08:16

that's just a character chart so when I

play08:18

hit enter that's actually a backslash n

play08:20

so that's how I encode that in a string

play08:22

if you're a programmer you know this

play08:24

stuff already but I'm just beating it to

play08:26

death here and so uh prompt so there's

play08:28

our prompt and now we just need to pass

play08:30

that prompt to this open AI completion

play08:32

create and so that's a parameter so the

play08:34

prompt equals this prompt up here and we

play08:37

need to tell it an engine and so I

play08:39

mentioned all these models have a

play08:40

different cost associated with them

play08:42

right Ada is this cheap one DaVinci and

play08:44

DaVinci 3 is the latest one this came

play08:46

out like last week this stuff is

play08:47

changing so fast so new stuff is coming

play08:49

out like all the time so we start for

play08:51

free with 18 in free credit pay as you

play08:53

go uh choose your own model and so you

play08:55

can look at this and see how much those

play08:57

things cost and depending on the

play08:58

complexity of your task you might just

play09:00

need this most basic model so you should

play09:02

use just the cheap one but if you want

play09:04

something very Advanced you need to

play09:06

summarize or tell a very creative story

play09:08

maybe you'll use DaVinci and it'll come

play09:10

up with a better better answer so I'm

play09:11

using text DaVinci 3 right here but I

play09:13

might not have to so you can experiment

play09:15

with the different engines so you can do

play09:17

a text Babbage 001 for instance and so

play09:20

you can change these variables

play09:21

experiment with different prompts and I

play09:22

encourage you to play with the

play09:24

playground for a while figure out what

play09:25

this thing is capable of and how you

play09:27

might craft these prompts in order to

play09:29

come up with unique things right and so

play09:31

there's a variety of parameters here

play09:32

this temperature parameter you can

play09:34

experiment with and this controls the

play09:35

randomness of the response so you can

play09:37

have it give a real exact answer or you

play09:39

can have it be a little more creative a

play09:41

little bit more random the same with

play09:42

these uh parameters down here you can

play09:45

also control the maximum number of

play09:47

tokens so if you want the response to be

play09:49

longer or shorter right and so there's a

play09:51

variety of parameters that are all

play09:52

documented and we'll talk about these in

play09:54

more and more detail as we build more

play09:56

applications and so let's run this now

play09:58

we're going to send in this string as

play10:00

input and get a response from open Ai

play10:03

and see what it tells us so I'm going to

play10:04

run this right and I ask it the greatest

play10:07

investor of all time and you can see the

play10:09

response right here is this dictionary

play10:11

where choices usage tokens the model

play10:14

that's used and that's the text

play10:15

completion it says the greater greatest

play10:17

investor of all time is widely

play10:18

considered to be Warren Buffett and so

play10:20

the magic here is that we can vary this

play10:24

prompt and build it dynamically based on

play10:27

some variables based on a text file

play10:28

based on audio and we can generate this

play10:31

cool string whatever we want to send it

play10:32

and then parse this response and present

play10:34

it in a unique way in order to build a

play10:37

sophisticated applications right and so

play10:39

it responds to us that Warren Buffett is

play10:41

the greatest investor of all time and

play10:44

that's great and I've included a link

play10:46

here if you want to check out check out

play10:47

the difference between the different

play10:49

models and all of the different

play10:51

parameters and they're all in the

play10:52

documentation right there I just want to

play10:55

show you you know you could learn all

play10:56

this from the documentation but a lot of

play10:58

people like this channel because I

play10:59

showed an action and kind of explain it

play11:01

from the ground up give you the code and

play11:03

walk through it and that helps a lot of

play11:04

people see it visually so now that we've

play11:06

done the most basic thing you know we've

play11:08

successfully used the open AI API let's

play11:10

try to get it to do something a little

play11:12

bit more sophisticated so let's try a

play11:14

summarization task and so what I've done

play11:17

here in the last video we transcribed

play11:19

the audio to text so we transcribed the

play11:21

FED speech now in this video I'm going

play11:23

to use the text transcript of an

play11:25

earnings call and so you could build

play11:26

this huge data set of different earnings

play11:29

calls and extract information out of

play11:31

these earnings calls and so I've linked

play11:33

an earnings call that I've already done

play11:34

so we don't need to do that again and

play11:36

transcribe it from audio but this is the

play11:38

text of an earnings call and you can see

play11:40

it's quite long right quite long and if

play11:43

I click the raw thing you can see all

play11:45

the text right and where they say on

play11:46

Reddit whenever someone posts this big

play11:49

long wall of text and we don't have time

play11:52

for it too long didn't read they post

play11:54

tldr and it turns out you can send this

play11:56

exact prompt that's one of the examples

play11:58

in the open AI examples here there's

play12:01

this too long didn't read right and so

play12:03

if you look for summarization there's

play12:05

TLD are a summarization so you can add

play12:07

that to the end of The Prompt and so

play12:09

what we can do is do a an audio

play12:11

transcription a two text then take the

play12:14

text and then append a couple Carriage

play12:16

returns and tldr to it and then send

play12:18

that to the open AI API and instead of

play12:21

telling us a story or answering a

play12:23

question it will do a tldr summary now

play12:26

how am I going to get this earnings

play12:28

transcript into python well this one is

play12:30

on the internet here and so I'm just

play12:32

going to use the python request library

play12:34

to a request that URL and just get the

play12:37

text transcript right here and so if I

play12:39

import that I can retrieve that and here

play12:41

you see I have the plain text and so now

play12:44

I'll be able to get that plain text and

play12:46

append tldr to it and some Carriage

play12:49

returns and craft a special response and

play12:51

tell it to summarize this earnings call

play12:54

and so what I have here is a prompt

play12:56

variable and I'm going to pass it this

play12:58

transcript variable so this transcript

play13:00

is going to be inside I put a couple

play13:01

character terms and this tldr colon

play13:04

right there and this forms my prompt and

play13:07

so if I run this you'll see my prompt

play13:09

right there and if I were to expand this

play13:11

out you'll see the entire Big Blob of

play13:13

text here and this little TR tldr right

play13:17

here at the end so I know that seems

play13:19

pretty basic but these very basic

play13:20

building blocks are what are going to

play13:22

enable us to build more and more complex

play13:24

things so we need to master these very

play13:26

simple tasks and we'll be able to put

play13:28

them together to build these full stack

play13:31

applications in uh following videos and

play13:33

so we'll be able to build as some type

play13:35

of crawler that gets tons of audio and

play13:38

extracts a tons of text and builds a

play13:40

queue and sends it through open AI build

play13:42

summaries extracts does natural language

play13:44

processing uh pulls named entity

play13:47

recognition pulls company names and

play13:49

different numbers out of them and we'll

play13:51

be able to perform more and more unique

play13:53

tasks as we go

play13:54

so let's first see if we can summarize

play13:57

this text so we have the prompt now and

play13:59

we can just call open AI again with the

play14:01

same completion endpoint and send us

play14:04

this new send in this new prompt now if

play14:06

I run that what you're going to see is

play14:08

the multiple the model's maximum content

play14:11

length is 4097 tokens and so this

play14:13

returns an error it doesn't work we send

play14:15

out this huge wallet text and open an AI

play14:17

says no not going to do it and so we're

play14:19

going to need to learn how to take all

play14:22

of our different inputs and massage them

play14:24

and do different things with them in

play14:25

order to make it acceptable to open AI

play14:27

so it'll process them and so the first

play14:29

thing we're going to do here is chunk up

play14:31

our data so we can't send it a giant

play14:34

like thousands of pages of text and tell

play14:36

it to summarize Wikipedia all at once

play14:39

right that's too complex of a task to

play14:40

get an instant response like this and so

play14:42

we're going to take this long earnings

play14:44

call and chunk it up into pieces and

play14:46

this is the approach we're going to take

play14:47

so we have this long text transcript in

play14:51

a string and so since there's spaces

play14:53

that separate all the work words right

play14:55

here what I'm going to do is just divide

play14:57

this long blob of text into an array of

play14:59

words and so if I run this and split it

play15:01

on Spaces we'll get an array of words so

play15:04

good afternoon my name is Emma and so we

play15:06

have a python list I'm just going to

play15:08

show the first 20 words just to show

play15:09

what that looks like now what I can do

play15:12

here is since openai has this length

play15:15

limit here what I'm going to do is just

play15:17

divide up our text into different chunks

play15:20

here and so numpy has this array split

play15:22

function right here and so I'm going to

play15:24

send it this this giant list of

play15:25

thousands and thousands of words I'm

play15:27

going to say divide this up into

play15:30

pieces of equal size so I'm going to get

play15:32

six lists here and so you can come up

play15:35

with different rules on how you want to

play15:36

divide your text but for this particular

play15:38

one I just hard coded six and I said

play15:39

divide this into a six pieces you could

play15:42

divide it into paragraphs and do other

play15:44

things like that as well and so I call

play15:45

it numpy dot array split and I'm going

play15:47

to split this list of words into six

play15:49

smaller arrays and I'm calling this

play15:51

chunks and so if I run this and you see

play15:54

the chunks here here you see the first 1

play15:56

6 of the earning calls the next one six

play15:58

and so forth so this is a list of arrays

play16:01

here right and so now we have this

play16:03

nicely chunked up and then now I can

play16:06

join one of these so I'm going to take

play16:08

the first array here so the first one

play16:10

six this list of words I'm going to join

play16:12

this back on spaces and just turn it

play16:14

back into the sentences and you'll see

play16:16

this is just it in paragraph format so

play16:18

this is the first 1 6 of sentences in

play16:21

that giant document right and so now

play16:24

let's see how one of these looks like

play16:26

let's summarize just the first 1 6 of

play16:28

the document so I'm going to get the

play16:30

sentences here and tldr and send it

play16:32

again and you'll see a summary of the

play16:35

first 1 6 of the document and so we can

play16:38

take the same technique and chunk up

play16:40

this into six pieces then summarize all

play16:43

six pieces and call open AI for each

play16:46

chunk of text and then we can collate

play16:48

and combine all these different chunks

play16:50

into a single final summary of the

play16:52

entire earnings call right and so if I

play16:54

go here and I run it you see the summary

play16:57

of that first one six and you'll see

play16:59

Simona welcomed everyone to the earnings

play17:01

call Colette Cress Executive Vice

play17:03

President and CFO reported revenue of

play17:05

5.93 billion down 12 successionally

play17:08

sequently data center a revenue of 3.83

play17:11

billion and so just a few sentences here

play17:13

we summarized that first uh that first

play17:16

section of the earnings call so that

play17:19

looks pretty good so how do we summarize

play17:21

all of it what we can do here since I've

play17:23

divided this into six chunks right we

play17:26

access the first chunk with uh chunks

play17:28

zero what I'm going to do is create a

play17:30

list of all the different summary

play17:32

responses and we're going to store all

play17:34

those summaries in this list so we're

play17:36

going to Loop through all the chunks

play17:37

we're going to take the sentences from

play17:39

each chunk we're going to tldr and call

play17:42

open AI then we're going to build this

play17:44

list of summary responses then we're

play17:46

going to join all those summary

play17:47

responses together and print out the

play17:49

full summary of the earnings call and so

play17:51

this is calling open AI six times with

play17:54

six different chunks of text we're going

play17:56

to get the summary put it all together

play17:57

and we'll have an earnings call summary

play18:00

just like that and that's our full

play18:02

Earnest call summaries and so we got

play18:04

that back and so I'm going to copy this

play18:06

into a text editor and let's look at it

play18:08

and see if it makes sense see how well

play18:10

open AI gpt3 understands the language of

play18:13

those many pages of text and so if you

play18:15

look at this gpt3 is very aware of all

play18:18

the different people that are talking in

play18:20

this earnings transcript so I have

play18:22

Simona Jankowski collect Cress and

play18:24

Jensen the CEO here we see a summary of

play18:28

the earnings right here just the the

play18:29

basic numbers we talk we see some

play18:32

information about the sell-through rate

play18:33

in gaming and then there's some comments

play18:35

on AI so the dynamic Computing

play18:38

environment so AI focus on productivity

play18:40

and the AI Enterprise software stack and

play18:44

uh Cloud gpus which I actually bought

play18:47

some Nvidia about a couple months ago a

play18:49

month and a half ago and so I'm kind of

play18:51

optimistic on the demand for a GPU use

play18:54

and their use in machine learning and so

play18:56

you can see some questions about

play18:58

hyperscale Cloud purchases and demand

play19:01

for these gpus in the future there's

play19:04

also some brief notes here that

play19:06

blockchain is not expected to be a major

play19:08

part of the company's business in the

play19:10

future because of the ethereum change to

play19:12

the proof of stake and so these miners

play19:14

aren't needing these gpus as much but

play19:16

you can see there's a huge demand coming

play19:18

in for gpus for AI machine learning

play19:21

purposes so there you go just like that

play19:23

we have a quick understanding of how to

play19:25

use the open AI API for a very specific

play19:28

task I'll be at a fairly simple one but

play19:30

this lays a very solid Baseline so that

play19:33

we can get started building more and

play19:34

more complex application some folks had

play19:36

said in comments in the previous video

play19:38

they couldn't even get the basic example

play19:40

off the open AI web page going so I'm

play19:42

hoping this helps those people get

play19:45

started and now we can continue to build

play19:47

on this and start building apps that

play19:48

accept sound text video URLs process

play19:52

them and perform perform more and more

play19:54

complex task and let our creativity run

play19:57

wild and so yeah I have a lot of good

play19:59

ideas in the pipeline and also let me

play20:01

know if there's anything specific you

play20:03

want to see with open Ai and I'll try to

play20:05

take that into account I already have

play20:07

like 10 to 12 other video ideas in my

play20:10

head right now and also a few people I

play20:13

just posted the open AI Whisperer video

play20:15

and a couple people are already asking

play20:16

me for like real time uh real-time uh

play20:20

Speech analysis of the FED speech and

play20:22

executing trades based on that which is

play20:24

completely expected because we have a

play20:26

bunch of Trader Types on this channel

play20:28

and so I'll show how to do a real-time

play20:30

speech transcription as well using

play20:32

whisper and talk about how we might

play20:34

classify text and maybe classify

play20:37

sentences as hawkish or dovish and

play20:39

things like that so text classification

play20:40

is something we need to do as well image

play20:42

classification all those types of things

play20:44

so thanks a lot for watching hope this

play20:45

was helpful for getting started with

play20:47

open ai's API and stay tuned got a lot

play20:50

in store for you thanks a lot for

play20:51

watching see you next time bye

Rate This

5.0 / 5 (0 votes)

Ähnliche Tags
OpenAI APIPython CodingSummarizationEarnings CallAI PlaygroundText ProcessingAPI TutorialMachine LearningData AnalysisGPT-3 Model
Benötigen Sie eine Zusammenfassung auf Englisch?