Friends was a cultural phenomenon, pulling in millions of viewers during its 10 year run from 1994-2004. Even today you'll still find re-runs on Comedy Central and branded clothing on sale. A significant part of this success is because of the terrific writing staff. However, now the show has ended, would it be possible for an AI to fill the Friends-sized hole in the hearts of fans.
As always, all the R and Python code I've written for this project is all on my GitHub.
'The One with all the Data'
The data we'll be using for this project is taken from a 2020 edition of the popular weekly data visualisation challenge 'Tidy Tuesday'. This edition not only contains data about the success of the show (no. of viewers per episode, IMDB rating, etc), but also a dataset of every line spoken by a character in the show. We'll use the former dataset to identify what data we'll use to train our model as it is simply not posible to train a model on the entire Friends script (I tried).
For this, we'll look at the average IMDB rating by season, to see if we can identify any outliers we can use as our data.
Oh wow, a pretty strong consistency in the average quality between seasons. Perhaps this isn't the best approch for idetifying our data. Instead, maybe a better idea would be to look at the quality of individual episodes and select from the top 10 or so. Extracting the top episodes yields the following episodes that we'll use to train the model.
This looks promising. We can then extract the script data for these episodes and use that to train our model.
'The One with the LSTM'
For the model, we'll be using a type of neual network called an Long Short Term Memory (LSTM) model. This type of model is different to other types of neural networks in that it contains information about previous inputs when receiving further input information. This makes it particularly good for dealing with language data as the placement of words is vital when constructing a sentence, where the order of words is vital.
Without knowing the order of previous letters, predicting the next one would be particularly difficult. For example, what letter comes after 'i'? But if we know that the full sequence of letters was 'My name i', it becomes much easier to predict the next letter 's'. This is the benefit of using an LSTM model.
This model took quite a while to train (> 1 day) and I've detailed the underlying achitecture above.
'The One with the AI Generated Script'
With the model, we can then generate a scene using the model with a scene length and prompt. The average scene is around 1,681 words in length so we'll choose that length for our scene. While for the prompt we'll simply start with 'Scene Directions', as this is not only how pretty much all scenes start but because it'll also allow us to see what scene the model defines for the scene.
Now that now have these inputs, we can now generate the script. Running the model returns the following scene. I've formatted the generated text slightly so that it'll be easier to read, given that we had to remove the punctuation and capitalisation when cleaning the data.
AI Generated Friends Scene:
Scene Directions: Monica and Chandler's Apartment. Chandler is been as Chandler enters, Monica and Monica are sitting in the kitchen table
Rachel Green: Hey
Phoebe Buffay: Hey
Ross Geller: Hi
Rachel Green: Hi
Monica Geller: Hi
Rachel Green: Hi
Monica Geller: Hi
Rachel Green: Hi
Monica Geller: Hi
Rachel Green: Hi
Monica Geller: Oh My God
Monica Geller: What-what's the matter, was our late?
Ross Geller: Oh My God
Rachel Green: Oh My God
Rachel Green: Oh yeah, but you have to do you were in an country?
Monica Geller: That's right
Chandler Bing: Oh My God
Rachel Green: Oh My God
Rachel Green: Oh yeah, but you have to do you after me?
Monica Geller: Well I know, I shouldn't be so lucky to mess
Monica Geller: I'll see you getting married
Chandler Bing: I can't believe you guys. Mean we win, we have to do it
Monica Geller: What will Colbert? What do you say that?
Ross Geller: Oh yeah, Chandler you don't wanna get off the plane
Ross Geller: I know it was incredible but it was a couple of years or ago they are a big more
Richard Burke: Oh my god, I'm sorry I'm a one of me I think if you do I mean this was fair I mean i-i can be like it
Monica Geller: Oh My God
Rachel Green: I know I was a complete idiot. You won't bring him from there
Ross Geller: Okay
Rachel Green: Okay
Ross Geller: Hey
Rachel Green: Hi
Rachel Green: Okay
Ross Geller: Oh My God
Rachel Green: What?
Phoebe Buffay: Ahhh
Joey Tribbiani: Oh My God
Phoebe Buffay: Oh My God
Rachel Green: Oh yeah, but you have to do you after a little call them
Phoebe Buffay: Do you? Don't have to do it to know
Ross Geller: Yeah, yeah. I mean you should have to go up and...
Rachel Green: What?
Joey Tribbiani: Yeah, you know what? We have a bracelet but you don't do this
Ross Geller: Hey
Rachel Green: What?
Phoebe Buffay: Ahhh
Joey Tribbiani: Oh My God
Joey Tribbiani: What?
Joey Tribbiani: Yeah, you know what? We have a bracelet but you don't do this up now y'know y'know. I thought you might know that the baby's born would be at that they had a pact
Rachel Green: Oh My God! I'm sorry I'm a twenty person that is in the hardest Philange
Air Stewardess: Do you went into work on me? And I think you guys I am I was in love and I love them. I mean if I mean you are a little night if you do this
Ross Geller: Oh My God
Rachel Green: I don't know you liked Football
Phoebe Buffay: Yeah well I thought you should get a little more in Winter in life
Ross Geller: No, I can't believe you were sorry
Ross Geller: No No No No No No No No No No No No! Sure I've had a lot of fact that you said that is a little fun of Months
Phoebe Buffay: Oh My God! I can't believe this
Rachel Green: Okay
Joey Tribbiani: I know, I know I shouldn't. Know what I mean? You know I was any new name
Joey Tribbiani: Yeah I was. Never told them that was a Little Pig Club
Ross Geller: I know you know what. You're almost a movie of years in the tank one year
Ross Geller: Oh My God
Rachel Green: Yeah, I can't believe it
Rachel Green: I know! I had a idiot for the same time and tell it to be a girl to have to see it. And then I was a woman, and you don't mean I mean if you didnt mean do you bring it off
The Doctor: I mean, if you dont mean I was thinking I have to get rid of my life. Ya just chased the game and this is a twenty Philange
Ross Geller: I was backpacking across Western Europe, then...
Phoebe Buffay: Okay Oh Oh Oh My God I can't believe you guys. I can I was in the gift shop. I Mean, I'll never be great, it's you
Rachel Green: Oh My God, I can't believe you guys. I love it
Ross Geller: What? Will Colbert what?
Ross Geller: I'm sorry, I dont know Ross-really
Ross Geller: Oh My God
Rachel Green: What you need to get this
Ross Geller: Oh My God, I can't believe you guys. Mean I love your parents with me, with the plane
Rachel Green: Oh My God
Phoebe Buffay: Unbelievable
Joey Tribbiani: Hey
Phoebe Buffay: Oh My God
Rachel Green: Oh yeah
Ross Geller: I don't know what you're thinking
Dave Thomas Founder Of Wendys Gail: I'm Gail
Chandler Bing: Well, we have a little something
Chandler Bing: I don't know, maybe Churchcamp?
Monica Geller: That's true, but I saw you were in an honest having time
Joey Tribbiani: Yeah
Chandler Bing: Well, you know what? We do
Chandler Bing: Well, I'm just being a deal time and a time. And I mean, I'm gonna be okay good time you dont know that is, you know. They dont know what do you know what he wants me to me
Monica Geller: No no, we talked to do
Monica Geller: I don't know what do you say me like it
Monica Geller: Oh yeah, well I've know that I was backpacking across Western Europe
Joey Tribbiani: You know what? We have to do it up
Chandler Bing: Well, I thought you know what? You're just gonna get pregnant
Monica Geller: Oh God
Chandler Bing: Oh My God
Joey Tribbiani: What?
Joey Tribbiani: Yeah, you know what? We have to do this is fair
Monica Geller: Oh My God
Joey Tribbiani: No No No No No Great No No No...
Looking at the output what is really interesting is how the model has picked up on some of the linguistic ideosyncrasies from the show (particularly the repeated use of 'Oh My God'). Generally though, the model output is pretty nonsensical.
'The One with the Final Thoughts'
I don't think that the model is going to be competing for a writer's room spot anytime soon. However, this has been a really interesting project and I hope you've learnt a little bit about NLP modelling along the way.
All the code for this project is contained on my 'Friends' repo on GitHub here.