From zero to finetuned model in 1 hour with GPT-3. Generate a movie script from any premise!
Skills:
LLM Foundations90%Fine-tuning LLMs90%Prompt Craft80%Prompting Basics80%Advanced Prompting70%
Key Takeaways
The video demonstrates how to use GPT-3 to generate movie scripts from any premise, fine-tune a model in 1 hour, and create a script generator using Python and the GPT-3 API. It covers various tools and techniques, including the use of temperature and token limits to control output, generating synthetic data, and creating a three-act structure for a story premise.
Full Transcript
hey everyone david shapiro here with a new kind of video i'm going to try i've had this idea for a while i've had this idea of doing a working session and what i mean by that is i'm just going to walk you through my entire process sometimes people don't really believe me when i tell them how fast i work or how easy this stuff is say you know what i'm just going to record it end to end and here's the project today someone said nicevid so this is my co-writing flash fiction with gpt3 let me zoom in a little bit um he says nicevid and the character dialog one i'm curious if you've tried using gpt3 to generate a high level logical plot summary where you prompt for a structure for a structure like setup incident an inciting incident midpoint false high etc etc in my experiments it is too extensive prompt chaining perhaps that's because it's more complex task i say i tried that with my auto muse project and it was not great at it however this is something that could be fine-tuned so that gave me an idea let me do an outline generator so i just created this repo here is the repo here um and uh i've added a couple files i just added my api key and and a boilerplate thing so let me just show you cd outline generator get status get add git commit am initial commit get push okay so you will see i just did i just did a push there's only a handful of files in here let's get started okay so the first thing to do with this is playground let's go to text davinci o2 so the very first thing let me zoom back in here is uh we need some raw data to work with so we're going to synthesize some data so the first thing is let's just right off the cuff let's see if this prompt works write a detailed um uh no not right imagine no brainstorm there we go brainstorm a plot synopsis for a random story um let's say detailed plot synopsis um and let's just see what that does the town of shepherd's town is a historic located in appalachian of blah blah blah sorry i'm trying to read too fast um this is great and it decides okay keeps going okay perfect so the town of shepherdstown is a historic small town located in the appalachian mountains of west virginia the town is home to a variety of shops and businesses as well as a number of different families the mcbride family has lived in shepherdstown for generations and they own a large farm on the outskirts of town the youngest mcbride daughter lizzie is a free-spirited 18 year old who has always been drawn to the town's history she loves to explore the old buildings and learn about the town's past one day lizzie discovers a hidden room in one of the buildings one of the old buildings the room is filled with dusty old boxes and furniture lizzie starts to explore and she finds a secret passage that leads to hidden staircase she climbs the staircase to find herself in a secret attic the attic is filled with old clothes furniture and books lizzie starts to look through the books and she finds an old journal the journal is filled with the handwritten accounts of the town's history at least lizzie is fascinated by the journal and decides to start her own research project on the town's history she spends the summer exploring the town's past and learning this like oh man this is some pure literary fiction right here okay so we've got a an initial prompt so let's go ahead and just save this um and we'll say we'll call this um prompt underscore premise dot text and so then what i do is i've got this this script that i'm starting um let's change this to davinci o2 and we'll use the same um the same settings so no frequency penalty no presence penalty um i'll leave these the stops actually i'll just remove those because they are not relevant to this project okay i think that's all we need so go with pep8 two new lines beneath each one okay so this is a function that i copy paste in all my projects some people have noticed that that every now and then your your um your prompt will fail and uh or your completion will fail and so i just have a retry built in it rarely needs that especially nowadays i think they i think they've upped their capacity but basically i just say like um oh i need to import sleep as well um from time import sleep um so basically it'll just wait a second and then try again in case it fails to talk to openai okay so for this since i like the prompt let's do if name equals main and this is not strictly required for this just because it's um prototyping i could just jump straight into a loop however this is good practice to do if name equals main if you want to call this from something else i'm not going to do that since i just do imperative programming and rapid prototyping but i just got in the habit and i like it because it just says okay let's demarcate this okay um let's see for i in range um let's see 0 to 10. let's just do 10 for now um let's see premise equals um gpt3 completion prompt equals 08. prompt equals need to load the file so i'll just copy this with open and what did i call it prompt premise because i will use different prompts in the future as in file so we'll say prompt equals infile dot read okay oh and another thing i forgot is what i do is i i grab the the output and i strip it so that removes all white space on from the edges and then i also do a regex swap replace for any any additional white space and just replace it with an individual space so in this case if it adds too much vertical space like new lines i want to remove all the new lines just so it ends up with a single block of text like you see here it's it's not always necessary but sometimes gpt3 will spit out too much too much vertical white space and i want to condense it um so that's why i have this little bit here and that actually reminds me i need to also import three which is regex um okay so premise equals gpt three completion prompt so that'll pass in the prompt i've got the engine set to default to text davinci o2 i've got tokens 500 just in case it gets cut off but you see here the uh these instructions are super short because text davinci o2 is pretty darn good um okay so let's run this oh wait i actually need to save it okay so let's see with open um what did i name that folder premises uh premises slash uh i guess i need a file name um let's do let's start at one and go to 200 file name equals premise underscore dollar or a text insert i don't remember the name of that right now text and then we'll do i okay so that will give us a serial number so we'll then we'll say premises that and do file name write encoding equals utf-8 i always do utf-8 because gpt3 sometimes outputs stuff that will not encode an ascii or other simpler things and utf-8 is just universal um so we'll do oops as out file out file dot right uh premise i think that's i think that's all i need to do um and then we'll do an exit right here so what i often do is just for debugging and testing i'll just have it do one instance um and then let's add a print print premise we'll do ui newline new line premise so that way we can separate them all out exit so that'll just be a quick test make sure okay i think that's it so python generate premises can i zoom in on this can i make this bigger edit properties uh cursor no not cursor size font there we go make the font a little bit bigger so you can see there we go look at that beautiful let's go a little bit bigger so that you can see what the heck is going on you don't have to squint at your screen 36 that's enormous maybe that's a little too big ah heck with it no module named openai really i forgot to re okay so i recently reinstalled my computer um pip install open ai the rest of this while that's installing the rest of these um time and regex are our default um with uh gpt3 um so you don't need or not gpg3 python sorry um the only the only module i need to install here is open ai okay successfully built installing it's doing all this fun stuff okay let's try that again python generate premises error communicating is not valid under interesting it doesn't like it okay i guess it doesn't like my empty whatchamacallit here so we'll just do blah blah maybe i should exclude that if i'm not going to have anything meaningful in it okay let's try again do a clear screen generate premises and the answer is save gpt3 log is not defined oh right because i grabbed this function from something else um save gpt3 log um so i usually in in a lot of my projects is i'll save every interaction with gpt3 so let me just comment that out um my bad sorry again i told you i was going to go through the entire process um this is this is what prototyping looks like with dave um hopefully it'll work this time fail fast and keep going there we go okay cool look at this um incomplete format oh yeah i did do that i it i called me out on my on my crap i messed it up here okay the sky is orange and the sun is red casting an ear glow over the small town of shepherdstown um it really likes shepherdstown doesn't it i wonder how often it will do shepherdstown because the the one up here also says shepherdstown um interesting okay whatever if it if it lights that that's fine um we'll see if it if it repeats that but let's go fix this thing because i missed we need the percent s for file name okay and that should if i'm not mistaken it will not have yeah it did not succeed okay generate premises let's see what it does this time shannon left to run the family okay so this generated a premise um yep she knows it would be inappropriate to pursue a relationship with someone she is employer so that's a that's a typo that doesn't make any sense shannon and diego must find a way to resist their feelings so this came up with a with a romance um so one thing you can do is i often will do um i'll often have placeholders so like let's say we want to modify the premise for a random story let's say like you know romance story actually let's do it this way so we'll do romance and instead of doing um instead of doing 200 of each one we'll do like we'll do like 50. so i'll do like romance um science fiction fantasy and like uh literary fiction or something so we'll just do 50 of each and we'll do premise romance there we go i think this will be good so then we'll get it we'll get a broader variety um yes okay so then we can assume that this yes premise1.txt yay look at that and actually let's switch this open with choose another program notepad plus plus always use notepad plus plus okay so there you have it you see we've got a premise um for a story and so let's go ahead and close that and that that took um what am i doing manage account okay usage this will take a minute to load but this is stupid cheap um because that was like 200 that was like 200 um tokens um so yeah that was that last one was 164 tokens and it cost less than a penny 266 tokens cost 2 cents so you know if i generate 200 of these premises it'll be about a dollar right um and if you've been watching my youtube channel this month um everything that i've shown you has cost two dollars that is how cheap gpt3 is getting to use okay so a quick little aside let's comment out the exit so we should generate now 50 premises um of romance um and then we'll change this to sci-fi fantasy and other stuff do a quick save so now we'll do cls python generate premises okay so basically this is step one of generating synthetic data and i've been doing this for let me pause my video for a second to see how long okay so that was 15 minutes um from zero to getting um a unlimited number of synthetic data we uh we're going from here and you see it's outputting everything as it goes it looks like it's using some similar stuff over and over again interesting jenna is looking forward to the weekend okay so it is it is a little bit repetitive that's interesting i wonder if there's something we can do to make it a little less repetitive at the beach house beach house all right so solutioning time this is way too darn repetitive um i think we might need to have a first thing something that kind of stands before um generating a premise okay so uh generate a list of random characters locations um and genres then we'll just do a dash there giraffe lighthouse comedy okay well that's interesting um uh let's say long list and see what that does because a giraffe lighthouse comedy that's not helpful um oh random characters let's see so we need to tell it for a story um this is for brainstorming a story generate a long list of random characters locations and genres there we go oh good good good good okay so here's what happens is it gives us some random stuff um let's run this a couple times to see if it gives us um similar things because like a group of friends who get stranded on a desert island camping trip in the woods let's see if it's repetitive again a family who owns a farm group of students okay yeah this is this is okay this is a little bit more random um run it a few more times skilled archer town that is terrorized by a band of robbers dark forest oh this is great a final battle between good and evil wonderful um okay so here's what we're going to do we are going to create another prompt that stands before the first one because we saw that it was being way too repetitive okay um let's call this prompt brainstorming brainstorm okay so first we're going to do that and then ooh ooh i'm gonna need to change this because we don't want we want to actually split the lines yeah okay so we'll need to change a couple things let's see how should i approach this i think i'm just going to need to take this out because we want to maintain the lines and um we will say i don't want to waste too many tokens um actually let's simplify this because i don't need multiple outputs i need just one generate a list um generate a list of well no because having a list output allows it to be more creative because there will be some slight variances oh also oh i wonder if i could fix this just by turning up the temperature let's go back before we get too carried away let's turn up the temperature a little one dot zero because this can go up to this can go up to two okay before before we get too carried away with over solutioning it let's try simple things so over here we've got seven romances looking at the console output most of them involve jenna most of them involve the weekend at a beach house so all right let's see if we can restart this and we get a better um better set of outputs um let's see let's go back here python generate premises all right so all i did was i changed the temperature from 0.7 to 1.0 um so let's see if we get that repetitiveness again jenna is looking forward to her evening run okay that's a little bit better jenna and ryan hit it off tamara is a successful businesswoman who seems to have it all she's beautiful and smart great starting to get some variety oh but you see how we're getting some some more vertical white space that i don't like hannah sets cross country road trip good linda's high powered executive yeah okay this is getting better so the simple thing is the better thing all i had to do is turn up the temperature let's add the canceling the white space add that back in that's fine for now jenny is a young woman who is struggling to find her place in the world good rachel is a successful young one notice how all the romances start with with a woman um falls in love with luke who learns to trust again sherry had always been a hopeless romantic so here's what i'll do i'll wait for this to get to about um like 20 or so or 25 rather and then i'll change the prompt actually no i don't need to stop it all i need to do is change the prompt um so we'll go to this so this is this is one advantage actually no that won't work because i only load the prompt once um yeah so for every iteration if i move this up into the into the loop then i could just change the prompt mid flight so actually let's do that um so let's do that put that here so now while it's iterating i can change the prompt mid-flight without having to cancel it um that'll be nice long day of work to her loving fiance miles um jenna and the stranger when olivia's mom dies she's left to fend for herself um so this is all this is all very like anglo-centric these are all like typical pretty much typically american names these aren't even like european names um so let me go ahead and pause this now and let's add a little bit of variety but first we're going to want to change where it starts okay so we're at 16 so let's go here and we'll start um we'll go we'll start at 17 and we'll go up to uh let's see let's we'll just go up to 30. and then we'll change this to uh let's close that one so i stopped clicking on it um for brainstorm a detailed plot synopsis for a random romance let's say europe no let's say french romance story um and watch how much just one word changes this output and let's see make sure that i change the where it starts so it'll go from 17 to 30. uh okay that'll be fine okay so because basically what we're doing now is we're oh elise there we go dashing parisian gentleman pierre oh wonderful um okay so what we're doing is we're generating synthetic data right now so ultimately this will be the input that we use in the future why is it paused there we go oh wow that's a much longer one excellent um so you know we got 17 like you know white bred american um premise romance plots um and we're gonna use those to generate um like a three-act structure in a little bit um but we want variety right we don't want just anglo-centric american stories we want a variety so um oh look at that name antoinette gautier ha love this meets brooding so there's another problem um meats breeding artist cloud monet oh wow look at that look at that this is great okay sorry i'm just really happy really excited about this the goal the reason why they're numbered is because we got to get up to 200 total um so 200 total that's going to be enough for us to uh for us to um what am i trying to say sorry i'm thinking really fast and my mouth can't keep up we need to get a minimum of 200 samples in order to fine tune a model that is open ai's recommended um kind of baseline minimum okay pardon me i have to check uh i have to check something okay sorry about that pause um but i think that's fine for you guys as watching the video just skipped ahead okay so now we've got um 30 uh well zero one one through 29 um premises um just scrolling up here francois is a young woman who lives in paris with her husband um oh that looks like that repeated that's okay it's okay if we get some repetition so what have we learned so far we've learned to turn the temperature up a little bit let's go up a little bit higher next time just to see um it can start to go off the rails so that's why i have the the console output just so i can see what what's doing um as i'm generating this data but already i've got about you know what is this 30 items um how much data is this this is 24 kilobytes of data um that i didn't have to write all i did was tell the machine what i wanted it to do all right so first let's update our starting point so we'll go from 30 to 45 we'll just do 15. and let's do a bollywood romance story um and this is going to take a while but i will explain stuff to you um as we go and if it gets too boring i'll pause the video so it'll just skip ahead so don't worry if i if i pause the video and it skips ahead it's just because i'm letting some of this process finish okay so let's do the generate premises but we change the prompt to bollywood romance and we've got the prompt premise and now the output is still premise romance and we're doing from number 30 to 45. okay let's go let's see what happens let's see how these go ria and raj have been married for five years they have a two-year-old daughter look at this they moved to mumbai oh man this is wonderful um it's so creative and look how fast it's spitting this stuff out i could never i could never write this fast no human could no 10 people could so i'm just churning out um looks like it is a little repetitive raj and simran of course it could be that raj is a common name um i i i work with a lot of indian folks and i know that there are some common names like my name is dave that's freaking common right so like i know that like karthik and satish are ultra common names in uh in india um raul there's another common one so yeah it looks like having the temperature a little bit higher is good i'm not seeing repetitive patterns in here even the names are often unique that's good okay so while this is running let's see what are we up to 36 so we've got about 10 more let's grab one of these oops if i know where i'm going okay so let's grab this and and start start figuring out um let's see um construct that's a good one construct a three act structure for the following yeah sure grammarly is like the most nagging grammar teacher ever but it helps me be a better writer also speaking of between gpt3 and grammarly you combine those two you're an unstoppable writer you can produce content so fast construct a three-act structure for the following um story premise um each each act should have a brief description one to two sentences okay premise so we'll do a premise there and now we'll do um three act structure act one all right let's see what this does it might just be all right let's see how this compares all right i guess i have to read it all out okay it all begins with samir a young man from a wealthy family meets naina a simple girl from a small village nina has come to the city to make a better life for herself she is immediately attracted to samir but is too shy to say anything oh a shy girl story um one day out of the blue samir expresses his feelings for naina and confesses his love for her nyena is overjoyed and eagerly accepts his proposal they begin to date and their families approve of the match however just as things seem to be going well samir smears father suddenly dies interesting leaving him the sole heir to the family business samir is forced to take on a lot of responsibility and doesn't have much time for naina oh oh man this is a good story i want to watch this movie uh naena begins to feel neglected and wonders if samir is really the man she thought he was um samir is soon caught in a world of money and power and nina feels like she is losing him one day she decides to go back to her village leaving samir behind samir realizes how much he loves nina and how much he has been neglecting her he decides to go to her village and confess his love nina is hesitant but eventually agrees to give him another chance they share a passionate embrace in their families rejoice at the news of their reunion oh man i can imagine so much song and dance in this bollywood picture okay so let's see how that has translated to a three-act structure act one um she's immediately attracted okay out of the blue it almost looks like it's just okay it's just splitting it up um this is not this is okay um break the following um uh following premise down into a list of major plot points use the save the cat model for screenplays okay so then let's try this again save the cat plot point one okay let's see what happens [Music] i don't like it it's not working hmm okay so this is where we have to get more and more creative because it's just regurgitating it and that's not exactly what i want and i want to avoid doing a doing a few shot example here let's break this down even simpler write a scene write the opening scene for the following no we we really do need an outline um let's see what was it translate or rewrite rewrite this the following premise into an outline outline all right let's see if this works so again i don't know what i'm doing here i'm just experimenting rapid iteration okay again it's just their families rejoice i guess this is okay because then this we can break each of these points down into we can break them down further um and and we can expand the story for each of these like break this down into uh yeah okay i mean this these premises are so good um yeah okay okay i think i think we can work with this i think we can work with this also this is probably done um let's go ahead and get this started uh raj and priya a painter falls in love with a girl excellent excellent excellent and that should have us up to was that 45 total so we need just a couple more romance let's go ahead and set this to run um all right imaginary audience in my head what kind of romance should we do oh paranormal romance done paranormal romance story uh and then we will go from 45 to 51 so that'll take us all the way up to 50. 50 on the dot cls python generate some premises luke is actually a werewolf that's fun this is great i love this um okay this will only take a minute because we're almost done already 47. jenna is looking jenna looks forward to the weekend a lot in gpthree's brain um [Laughter] this is funny when you wake up from your car accident you find oh this is a first person story excellent excellent excellent um honestly these premises are so good like i don't know if i need to break them down in any further um but let's see let me go back to this guy's comment because maybe maybe this is more of an extraction thing um he said you know setup inciting incident midpoint false high all hope is lost and climax okay actually you know what dude john david parsons i'm just going to copy this because this is such a powerful way to start um let me just paste this in here um identify the following elements all right just copy that for now let's go back over here roman oh wait nope brainstorm a detailed plot synopsis for random all right so now we're going to switch to uh let's see 75 actually no we'll say 76. um now we're going to switch to what did i say sci-fi all right sci-fi and we'll say um science fiction story and then we'll switch that over from like science fiction to like um actually no let's say random hard science fiction and then we'll do like um epic or space opera yeah we'll do space opera next okay so let's get this running uh n a that's interesting did it really just like spit out n a it did okay gbt3 said no i'm not going to give you a premise okay whatever um we'll just delete that one and see what it's doing in the future the human race has all but wiped out a race of advanced aliens wow we're we're jackasses um okay so we're getting some stories okay identify the following elements for the premise one setup why does it keep jumping all the way down two inciting incident three midpoint four false high five all hope is lost six climax and i will actually probably go copy kmylen's storybeat because kmyland is pretty good okay so one um setup all right let's see if it can identify let's turn the temperature down because we don't want it to be as creative now we do want it we do want it to be somewhat creative but we don't want it to go off the rails okay this looks like it's working leaving samir behind i don't know that that actually worked let's see let's see what happens if we turn the temperature down even more and i'll try turning it back up in just a second okay so again this is just kind of like regurgitating the same um there's not really any value add that's that's why i'm not so happy with this is because these premises are so great so it's like okay well what what do we do from here um i guess i guess i will i will go back and say like okay it can it can be helpful if we have a um have a good like breakdown um but let's see cam while in plot beats uh what are her here we go the first act the hook first plot point inciting incident evident key event first half of the second act midpoint this is not the list that i was thinking of because it doesn't include the pinch points oh well this is good enough um setup and citing incident midpoint falls high all hope is lost dark knight is soul whatever climax that's fine we'll go with this all right so temperature of 0.5 let's see if it's consistent okay so this does break it down into a few points um we'll go with that for now uh i really think that we should expand on this though actually here let's let's be more creative uh okay write a detailed opening scene for a film with the following premise um use let's see what is the standard screenplay format called okay um use standard script formats for hollywood films screenplay let's see what it does with this fade in oh wow this is it this is fascinating screenplay fades in exterior of naina's village day we see a small village in the middle of nowhere there are simple houses and dirt roads we see a young woman naina walking down the road she's carrying a small bag and looks determined nina to herself this is it i'm going to the city and i'm going to make something of myself wow this is phenomenal oh man okay nina jumps out of the way and falls to the ground in anger what the hell the car stops and young man sameer gets out he looks apologetic i'm so sorry are you okay i'm fine just watch where you're going next time samir nods okay i'm i will i'm really sorry waves him off it's fine just be more careful um i think it ended because ran out of tokens uh okay i really like this so instead of instead of instead of because the premise is complete we don't need we don't need to break that down it's got this is a full story um so let's copy this and say we'll save this as prompt screenplay or we'll just call it a script um okay and then if i'm not mistaken this is probably done yay the year is 20 27 55 the human race has been decimated by a pandemic it swept across the globe too relevant the year is 20xx okay um all right cool so we should have up to number 75 we got a whole bunch of sci-fi premises so let's go back here we'll start at 76 and go to 101 and we're going to change the prompt script what did i say or the premise this is going to be a um space opera science fiction story okay so let's kick this off again while it's running in the background and that'll be that'll be half of our of our premises big jeff is an unlikely hero a portly space trader oh man these are great in a galaxy far far away young farmer really really it's just copying star wars that's fine um okay so we can't expect gbt3 to always be super unique but um that's fine we don't need it to be so this starts to get a little bit more complicated for these prompts so now that we've got material that we want to feed in we're going to need to add a few more functions and so what i'll do is i'll copy this because this script is just for generating premises so we'll do is we'll save this and now we'll say um we'll call this generate scripts dot pi because we will need to take um actually maybe we won't uh yeah we will need to take all this out because that does too much to the um to the thing we need to keep the format um we'll need to turn the temperature back down i think we're at 0.5 on here yep 0.5 we'll keep 500 tokens actually let's do a little bit more because the screenplay we want we want to expand this right um screenplay fade in it doesn't even have a name okay that's fine uh but yeah so we need this actually here let's copy this whole thing and the prompt for the script so then what we do is we add a token for the premise okay and we go here so um i just want to point out the original idea was to create a um was to create a outline generator but i realized that the the premise generator was more powerful than an outline generator um and so basically i'm moving the goal posts on myself and saying actually let's go a little bit further let's do something unique um and so we'll do scripts and so this is going to be the the script that um that matches matches what we're doing um we'll leave let's change the script write write a detailed opening scene um d write detailed opening scenes plural for a film with the following premise use standard script formats for hollywood films so we'll put in the premise and then the screenplay okay so and then i will also turn um you probably saw uh generate oh sorry generate scripts turn it up to a thousand tokens um davinci instruct can go up to four thousand um so this one so you see like that can go up to four thousand that's gonna get pricey and it's also gonna take a while so i'm not gonna go that i'm not gonna go that far okay this is done kira is a young woman born on a small space station okay cool so now we should have we've got exactly 100 premises we've got romance sci-fi what did i say oh fantasy okay so let's go back in here and switch to fantasy um how long has this video been okay we're at 46 minutes um and we're we're a good chunk of the way done um where was i oh yeah we are going to generate some more premises prompt premise so we're going to switch to fantasy and we're going to go from 101 to 126 and the prompt for the premise is going to be a random high fantasy story um this one will be specifically like well it says high fantasy so that implies magic and dragons um and then we'll do another kind of fantasy after this all right so let's let that rip and roll make sure that it's it runs uh the kingdom of alabaster really is in peril the king has been assassinated and the queen has been kidnapped this is this sounds fun far in the land of doran there lived a great kingdom people were thriving and happy under the leadership of king gelador that's cool um okay the triumphant dorm is restored wren a young woman of humble beginnings okay this is great um a young woman discovers she's recarnated princess of a lost kingdom that's cool she must ventures into uh yeah okay so that's running in the meantime generate scripts okay so we removed that um so what we have to do here is instead i'll leave that in place for now so we'll do import os premises equals os lister premises and so then what we'll do is we'll do four premise in premises and also you can do you can do a one-liner here um actually so let's let's do it that way because that's more pythonic for premise and premises uh we will do um uh let's see we'll say text equals i know with open because we'll use the same um yeah here we go we'll just copy paste this but instead we will say read and we will do for file name as in file premise equals infile dot read okay so now we will have loaded each premise and then we're going to do the same thing that we did here which is the uh script equals gpt3 completion premise um oh wait no the premi we have more to do um the prompt sorry with open uh let's see what was the prompt name there we go so this is going to be our prompt script and let me check on this see if it's done it is done okay so let's go update and i know i'm jumping around a lot but i multitask so basically what i'm doing is i notice that this is done so i'm going to go and update the prompt so this is a random high fantasy what other kind of fantasies let's do uh grimdark fantasy it that's all the rage right now so let's change this from 126 to 151 and we'll start that going again generate premises and so that just so you can see we've got 125 premises here um let's see when the last king of the realm was slain in battle all hope seemed lost but prince aidan heir to the throne was not ready to give up um okay cool life was never meant to be easy grown from the dirt and grime of the world the people toiled day in and day out yeah this is miserable okay all right where was i generate scripts yes generate scripts um so prompt script as in file prompt equals infile dot read um dot replace and we're going to replace the premise with the premise so that grabs that so basically we're saying the prompt is going to read this file and replace this part with the actual premise and so then we will say the script equals gpd3 completion of the prompt and remember the prompt now has the premise embedded um and so then that is the call to gpt3 file name um actually the file name will just be file name equals we'll say new file name equals filename dot replace premise with script so basically what this line will do is it will grab the premise and just say script and it will have the same otherwise it'll have the same number um okay so that'll be the new file name that's fine and then we will we'll copy paste this line um with open and we'll say scripts so this will change to a new file out file right so new file name and we'll say script right there so that should be good and we'll do exit 0 just to test the first one and so this should be ready once uh as soon as as soon as we've got enough training data so tell you what um this is about as far as i can code right now so i'm gonna pause the video and skip ahead but basically all i'm gonna do is make sure that um that this finishes creating the underlying data and then i'll i'll restart the video once we are once we're ready to start generating the scripts all right pause okay as promised we have 200 premises um a bunch of them i did a i did a gritty noir mystery anime uh was one of them but we've got 200 all kinds of we got mystery fantasy sci-fi and romance and they're all great okay so next up let's do a quick test python generate scripts okay so as a reminder we did this premise of the um uh or the script premise sorry re reset we have a script writer that uses the premises we just made okay there we go that's what i was trying to say so let's do this let's just generate one to make sure it works and then if that works i'm going to pause the video again while it runs because you don't want to sit here and just watch 200 go alright so generate scripts let's see if this throws any errors and if it doesn't let's check to make sure that it outputs correctly oh i didn't have it do any console output um script one hey look at this shannon's farm shannon early 20s shannon look at this perfect okay this is 1400 lines long or characters long so that's uh that's probably right about a thousand tokens um yeah this is great okay so i'm gonna pause the video again while this runs and i'll see you in just a second okay and we're back um we've got almost 200 scripts written so you can just see like hey here's some actual scripts being generated i'm not going to read them all but i'm just going to trust that like hey this works and if you want to go through it and um and take a look at them um in the meantime though while this was running because this has taken let's see 8 22 now i don't know when it paused you can do some math but i think i started about an hour and a half ago now total maybe a little bit more so hour and a half later most of this time has actually been spent waiting because this is this is a slow process okay so we've got that so what i did it while i was waiting so we've got the generate premises we're done with that generate the prompt for the premises we've got that oh let me zoom back in sorry you probably can't see this generate scripts you saw me write this this works just fine you can see the results here um and then whoops and then uh okay so this is the next thing i did i borrowed this from a previous previous project so all this does is create a json l file so let me do python generate json l name data is not defined what do you mean data is not defined um where do i use data oh i meant to delete that okay okay so let's make sure that this file was good scripts.jsonl cool so it looks like that worked so prompt and then it ends with completion you see here where i have nnn script so what i always do is i always add a natural language token at the end openai they recommend doing something like that as your divider but i don't like doing that it doesn't work as well because if you have a natural language token at the end of the prompt then it knows um it knows like okay now it's time to do this particular task so what this data looks like is it what it does let me explain this um so we take the premise and we match it to a pr uh sorry a script and so this script shannon's farm on the day like da da shannon is left to a family farm on her own so basically this this is going to train a model to take any any premise so this could be like a handwritten premise and output a movie script um i know it completely changed the purpose from what i said at the beginning of the video but hey that's how rapid prototyping and research goes let me save that because i don't want to or close that because i don't want to save it okay so this file worked so we've got our we've got our json l file so this is the final product for our training data and then the very last script that i wrote is this fine tune dot pi and again excuse me i um i borrowed it from a previous one so basically all it does is it uploads the file the json l file that we just did and then it calls the fine tune model and i'll pause it again because the fine tuning takes a while to show you but then once it's done it'll actually appear oh and so just so you know how much this cost let me do a quick refresh so everything that you've seen today i started the day at about two dollars so now we're at 11 so generating generating 200 premises which is let's see that's about 139 kilobytes of text data um and then generating 200 scripts from those which is going to be a lot more 330 or 303 kilobytes so this all told was cost about nine dollars so far because i was at about two dollars already when i got started this morning um yeah so nine dollars to generate um to to synthesize the data that's that's not just the fine tuning the fine tuning is way cheaper but this was synthesizing from scratch okay so i think this should be ready um so let's see file upload that does do the pretty print of that and then the fine fine-tune model um okay so yes this should work if i'm not mistaken it might error out so let's do cls python find two fine-tune okay got the file uploaded and let's see status pending okay cool i think this is usually usually it's in in sequential order so davinci fine tune file name file um it doesn't have the name in it anyways i'm assuming that it is fine tuning um let's do fine tune get fine tune list okay so here we will uh let me oh yeah so that was the last thing it did let me save that real quick so i just comment these two out i actually don't need that so let me just do cls so fine tune all this will do is just do a fine tune list so it's pending okay this will take a while so i'll pause the video again pause the record because you don't want to just sit and wait for this to finish but let me show you what it looks like when it's done um so when it's done the under your engines your fine tunes will pop up here and it'll have so it starts with the engine name um and then they changed it so it's like the original fine tunes were like user blah blah blah blah this wasn't helpful they changed it to the name so it gives me my name and then i gave it a tag so this was my eve project um yep so on and so forth core objective functions eve so on and so forth so once that's done another fine tune will pop up here with the name um what name did i give it scripts um so that i could i could have said something better like movie script or something um but yeah so that's pretty much it um let me pause it and i'll show you what how this performs in the playground in just a moment okay gang and we are done it's uh nine o'clock so i think that's about two and a half hours in granted a huge chunk of this was waiting um so let me do a quick refresh here and let me show you what the final result is um whoops scroll down um scripts okay so um oh let's come up with a random premise for a story uh actually here my creativity is offline so let me just go back up here write a premise for um oh let's combine it so we have an anime um an anime mystery and a high fantasy so let's do write a premise for a high fantasy anime movie write a detailed premise uh let's go brainstorm okay in a world of swords and sorcery a young girl named lily is thrust into a quest to save her kingdom from a powerful evil sorcerer okay great okay we've got a premise so let's oops clear that out in a world of swords and sorcery and then the um the fine tuning data adds this uh this script so that tells it that the the premise is done so we'll go down to scripts and we'll change this to 0.5 and here we go let's see what happens it might timeout because it does often take a little bit of extra time to load a fine-tuned model but we should be just about done and to prove it let me go back here and show you outline generators so started three hours ago um yeah so three hours ago that's about how long i've been working on this and we will do a final commit and i'll do a final push yep please try again shortly actually i'm not changing anything so we'll just do ahead get status so remember i started this video with um with just doing this get the initial commit get add all get commit am final commit and you can go check on the um the commits yourself if you want get push okay so this code is now updated and online i'm probably also going to rename it from outline generator because this has actually became a script generator um why did it name it that oh i probably accidentally copy pasted that didn't i that shouldn't be there cof jsonl yeah i totally accidentally copy pasted that okay that needs to go away um also this is under the mit license so you are free to use this however you want um let's see if this is loaded still being loaded try again um get status get add get commit am removing extraneous oh actually there's another one that needs to be removed um brainstorm because we didn't use that one okay get add git commit am remove extra files keep it as simple as possible get push okay cool so now the only stuff in this is exactly what was used nothing more nothing less um has it finished loading oh come on why is it going so slow don't you know i got a youtube video to make here usually it only takes one or two tries before the fine tune model loads so i wonder if openai is extra busy today okay i'm gonna pause it rather than make you wait okay and of course the very like three seconds after i clicked pause it ran okay so with this notice i didn't include any instructions i just give it a premise and it writes a script fade in uh lily's house day young girl of about 10 is playing in her backyard with her dog a small terrier laughing having a good time mama papa there is no answer little girl starts to get scared this is totally like a miyazaki right this is a studio ghibli [Laughter] um because there's a sorcerer's castle etc etc okay the men chase after lily grabbing her there you have it you can do this yourself you can go fine tune this it's all up here i'll leave it named outline generator even though that's a misdemeanor whatever it'll just be an inside joke yeah it's done thanks for watching
Original Description
The Kickstarter for my Post-Labor Economics book is live! https://www.kickstarter.com/projects/daveshap/labor-zero
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from David Shapiro · David Shapiro · 17 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
▶
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Raven MVP Demo 2021-04-02
David Shapiro
Get Started with Raven AGI
David Shapiro
Coding Raven's Encyclopedia Service (v.1)
David Shapiro
Prototype AGI demo - Natural Language Cognitive Architecture "NLCA" running on GPT-3
David Shapiro
Raven Release 1 Deep Dive
David Shapiro
Fine-tuning GPT-3 to generate questions about anything
David Shapiro
Fine-tuning GPT-3 for benevolent and trustworthy AGI
David Shapiro
Implementing Natural Language Cognitive Architecture with GPT-3 and the "nexus" concept
David Shapiro
5 Tips and Misconceptions about Finetuning GPT-3
David Shapiro
How to create synthetic datasets with GPT-3
David Shapiro
What is a heuristic imperative? What imperatives should we give AGI?
David Shapiro
Talking Philosophy with GPT-3
David Shapiro
Talking Boundaries and Consent with GPT-3
David Shapiro
Convergence and acceleration towards AGI (or Artificial Cognitive Entities)
David Shapiro
GPT-3 for Writing Dialog
David Shapiro
Co-writing flash fiction with GPT-3
David Shapiro
From zero to finetuned model in 1 hour with GPT-3. Generate a movie script from any premise!
David Shapiro
GPT-3 Working Session: Finetune an information companion chatbot in 30 minutes (RESEARCH ONLY)
David Shapiro
What is "toxic stoicism"? Talking philosophy with GPT-3
David Shapiro
Billion-dollar GPT-3 startup! Fix education with an expert tutor chatbot!
David Shapiro
Finetune GPT-3 to write an entire coherent novel (part 1)
David Shapiro
Concepts in Neuroscience and Cognition - Deficits of GPT-3 and the path to AGI and ACE
David Shapiro
Finetuning GPT-3 to be a master tutor that can handle any topic and hostile students
David Shapiro
Testing "Theory of Mind" in GPT-3 - making fully aligned ACOG (Artificial Cognitive Entities)
David Shapiro
Finetune GPT-3 to write an entire coherent novel (part 2)
David Shapiro
Finetune multiple cognitive tasks with GPT-3 on medical texts (and reduce hallucination)
David Shapiro
Finetune GPT-3 to write a novel - Part 3 (IT WORKS!!!) ...at least a little bit
David Shapiro
How will we know when we've invented AGI? How will we know it is complete?
David Shapiro
Finetuning a Creative Writing Coach in GPT-3 - Part 1
David Shapiro
Finetune GPT-3 to write a coherent novel - Part 4 (success! with minor bugs...)
David Shapiro
Recursively summarize text of any length with GPT-3
David Shapiro
Finetuning a Creative Writing Coach in GPT-3 - Part 2
David Shapiro
Increasingly Verbose Bot with GPT-3 - Expand any word or phrase into a whole paragraph
David Shapiro
Metaprompting with GPT-3 to dynamically generate arguments
David Shapiro
I'm taking a short break from research and YouTube
David Shapiro
Are LaMDA or GPT-3 sentient? No, but...
David Shapiro
Can GPT-3 generate training data? Short answer? Yes! Here's why that's a legit methodology...
David Shapiro
DALLE2 Style Tags Tutorial - "Elven archer in a sunny forest" with different tags
David Shapiro
Many of you have asked for it: Join my new research Discord! Link in description
David Shapiro
Answer complex questions from an arbitrarily large set of documents with vector search and GPT-3
David Shapiro
Fixing "goldfish memory" with GPT-3 and external sources of information in a chatbot - part 1
David Shapiro
Fixing "goldfish memory" with GPT-3 and external sources of information in a chatbot - part 2
David Shapiro
Python & GPT-3 for Absolute Beginners #1 - Setting up your environment
David Shapiro
Python & GPT-3 for Absolute Beginners #2 - Your first chatbot
David Shapiro
Python & GPT-3 for Absolute Beginners #3 - What the heck are embeddings?
David Shapiro
Introducing the RAVEN MVP - a general purpose AI companion (with a live DEMO)
David Shapiro
I needed SQLITE but for vectors so I wrote it myself. Now it's on PyPI - introducing VDBLITE
David Shapiro
Prompt Engineering 101: Autocomplete, Zero-shot, One-shot, and Few-shot prompting
David Shapiro
Prompt Engineering 101: Introduction to CODEX
David Shapiro
Prompt Engineering 101: Summarizing, Extraction, and Rewriting
David Shapiro
Summarize product reviews with GPT-3 fast and easy, get product insights and improvements fast!
David Shapiro
Finetuning GPT-3 101: Synthesizing Training Data
David Shapiro
Finetuning GPT-3 101: Augmenting Training Data
David Shapiro
Finetuning GPT-3 101: Using Your Finetuned Model
David Shapiro
Modeling different viewpoints with GPT-3 for automatic debates
David Shapiro
Finetune a perfect email generator in GPT-3 - take any input and generate a great email
David Shapiro
Research Update: Nexus microservice for Artificial Cognition + microservices architecture (MARAGI)
David Shapiro
Research Update: Microservices! Text-based simulation, Embeddings, and Nexus
David Shapiro
It's alive! The first 3 microservices are up and running!
David Shapiro
What is a Microservice? What does it have to do with AGI?
David Shapiro
More on: LLM Foundations
View skill →Related Reads
📰
📰
📰
📰
Claude Sonnet 5 Just Launched. Is It Actually Better Or Just Newer?
Medium · AI
Claude Sonnet 5 Just Launched. Is It Actually Better Or Just Newer?
Medium · Machine Learning
Claude Sonnet 5 Just Launched. Is It Actually Better Or Just Newer?
Medium · LLM
Claude Sonnet 5 Didn’t Just Get Smarter. It Changed the Economics of AI.
Medium · LLM
🎓
Tutor Explanation
DeepCamp AI