Dune quote generator

1654479744542


Summary

OpenAI is an AI research company that is totally spearheading the field. Their DALL-E 2 and GPT-3 have dominated image and text comprehension/generation, respectively for the past couple years. Given a complex prompt, they can create a response that fits almost disturbingly well.

 Well, I was thinking about making a quote generator for the home page, and writing a whole ML model from scratch to accomplish it. But I saw some YouTube videos covering recent ML news, and although I would learn way more doing it the hard way, the only way I'd accomplish a project anytime soon was by leveraging their tech.

 I hopped over to their Beta and starting trying inputs, some classic Ex Machina stuff. The responses it could give blew my mind. It can even draw ASCII photos when prompted. It seems limited by vocabulary, but it kind of depends on the prompt. So I went with "Write a quote from the book Dune" and refreshed about 30 times. The responses were exactly what I needed. The API is pretty easy to use and I coded up a script in a Python notebook that queried one of the cheaper engines 1000 or so times for around $0.05 total. I store the responses locally in JSON format and then uploads them to a DynamoDB table in aggregate. The table isn't optimally formatted (NoSQL headaches) and some of the quotes are lame, but it's a functioning prototype! And the quotes actually (mostly) sound like their written by none other than Frank Herbert!!!

 From here, I can fine-tune a model to the collected works of Frank Herbert and filter out some of the sillier responses. Then broaden the project to some other novels or philosophers that I like.

 The hardest part by far was formatting the JS queries since the docs are unreadable and Stack Overflow responses are not very useful. It took literally around 3 hours to get the generated quotes and authors onto the Home page. But I whittled down the errors until it was running pretty smooth.

Improvements

Load time

 This is my biggest concern. The queries occur before the page is rendered, but it doesn't seem to have had too much of an impact. Regardless, I'll port the queries over to a separate script so the quote loads in after the rest of the page.

Relevance

 Some of the quotes are sort of gibberish. I can either use a better, more expensive engine or filter out the bad responses. I think the latter is the best decision, mostly because of the financials. The best engine, text-davinci-002, costs 50x more per word than the one I currently use, text-babbage-001.

Interactivity

 I want people to be able to 'generate' quotes on the fly i.e. press a button that queries the quote table. That'll likely be the first thing I throw in the Projects folder.