# Example output: Item,Galleons,Sickles,Knuts "Spell Book",3,14,0 "Chocolate Wand",0,2,3 Input: #. After visiting Diagon Alley, Harry bought a spell book for three Galleons and fourteen Sickles, as well as a wand made of chocolate which cost him two Sickles and three Knuts. Return a comma-separated table with the column headers Item, Galleons, Sickles, Knuts. One or several items are mentioned, together with their prices in galleons, sickles and knuts. After 10 minutes or so of prompt engineering, I settled on this version:įunction prompt(snippet) """ The following is a text snippet from Harry Potter. My goal was to make the model extract a CSV table of items with their price separated by Galleons, Sickles and Knuts. I briefly played around with the user interface on the site to come up with a suitable prompt. I settled on /playground which offers some free credits to start with and was relatively painless to get working. Would I be able to automate the task with them? Using GPT-3īecause I didn’t even want to attempt running models on my laptop, I looked into using a web API to feed my data to a language model. Therefore, I thought, why not try one of the fancy language models that are talked about so much these days. Sometimes the item is mentioned three sentences before the price, or only alluded to. Carefully constructed regexes are usually closer to my mode of thinking than more opaque machine learning methods, but in this case it was pretty clear that there was no generally exploitable sentence structure to extract both the price and the item. Of course I didn’t want to manually go through all 98 snippets, so I thought about ways to extract the data I needed automatically. “Look,” Harry heard one of them saĪn English speaker reading this should be able to extract the item of value being talked about in this paragraph: Dragon liver for sixteen Sickles. Several boys of about Harry’s age had their noses pressed against a window with broomsticks in it. A plump woman outside an Apothecary was shaking her head as they passed, saying, “Dragon liver, sixteen Sickles an ounce, they’re mad.” A low, soft hooting came from a dark shop with a sign saying Eeylops Owl Emporium - Tawny, Screech, Barn, Brown, and Snowy. He turned his head in every direction as they walked up the street, trying to look at everything at once : the shops, the things outside them, the people doing their shopping. Julia > snippet(corpus, snippet_ranges) |> print ht more eyes. Then, I loaded all seven of them into a string: (In the end, I could have just googled anyway, and would have found the table on this page, but that would not have been as much fun!) Preparing the dataįirst of all, I downloaded the Harry Potter plain text corpora from and extracted them into a folder, deleting the attached list of characters. However, I never got there because the more interesting part proved to be how to assemble the list of items of value in the first place, without manually going through all the books. My initial plan for this exercise was to extract all prices from the books and plot them over time (position in the books) or in a sorted bar graph on a logarithmic axis to related all the things you could buy in the wizarding world. For example, something relatively expensive in the first book (the wand) looks very cheap compared to later items (the fireworks). Rowling might have added more and more expensive things while she was writing, just to contrast them against previously introduced items. So I wanted to visualize how the value of items mentioned across the books develops over time, because my hypothesis was that J.K. I have sometimes wondered about how inconsistent the books really are in this point. We don’t know how much time or effort it takes to make a wand, but probably more than mass produced fireworks, and I hope the Weasleys would have been able to afford food and clothes equaling fireworks in value. For example, the Weasley family has only a single gold coin in their vault, while a wand costs seven Galleons, and special fireworks from the Weasley twins in the later books ten Galleons. Harry Potter and moneyĪnybody who has read the Harry Potter books has probably noticed how the monetary value of items in the wizarding world is a bit… inconsistent at times. In this blog post, I’ll show how I used Julia and a GPT-3 model (via an online API) in an attempt to analyze the monetary value of items in the Harry Potter novels, and what I learned in the process.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |