one sec
- 5 minsSometime in summer 2020, my friend George pitched a side-project idea to me based on what he was learning in his accounting class.
He thought we could use openAI’s GPT-3 to let anyone generate accounting statements. We spent a weekend hacking it together and ultimately built this:
Built a GPT-3 bot that lets people with no accounting knowledge generate financial statements 📈 👀
— Yash Dani (@itsyashdani) July 21, 2020
Here it is creating balance sheets by turning everyday language into Python code: pic.twitter.com/pFnhmi5guM
Frankly, the results completely blew us away. Within a really small amount of time, we were able to build a demo with a really compelling use case.
Half a year later, we still weekly recieve emails/messages asking us to explain how exactly we built this. While we’ve briefly explained it in an article on InfoQ, we wanted to explain our thought process further here.
[If you’d rather do your own digging instead, the code is fully open source here. (ADD A LINK) (ADD ADD ADD LINK)]
GPT-3
If you have no idea what GPT-3 is, here’s a simple explaination from the openAI blog:
Given any text prompt, [GPT-3] will return a text completion, attempting to match the pattern you gave it.
So for example, you get GPT-3 to write code for you by prompting it with examples of code snippets.
In our case, we prompted GPT-3 with a text pattern containing 4-5 examples of input and output pairs. This what 1 input/output pair looks like:
From the demo, you can see that our input describes a transaction in plain English. This was pretty easy, we just described that as our “question”.
The output was a little more complicated. We knew we had to generate some command to update a spreadsheet. Frankly, this took many iterations to get right. Approaches like outputting a full Python script, a terminal command, and a csv file didn’t work well enough.
Ultimately, we decided the best option was to generate a 2D Python array. Each element in the larger array is an area of the balance sheet to be updated. The inner arrays contain three elements: add/remove from a section, by how much, and what section of the balance sheet respectively.
We then generated a few examples, and our fine-tuning data looked like this:
Once we had designed our prompts to a point where we were happy with them. We spent a bit of time tweaking parameters and ultimately created a basic API request to be called every time we wanted to ask a new question:
That’s pretty much it! Since we designed this bot, there’s been a lot of progress in the community to make prompt design much easier such as chronology. I’d also recommend reading Russel Foltz-Smith’s great article on the fundamentals of GPT-3 to help you better understand the ins and outs of effective prompt design.
This demo shows just how powerful GPT-3 can be in the field of accounting and finance. Despite it being just a demo, the results it provided were remarkable. This can further be expanded out to fill out more fields of an accounting balance sheet and further on to other financial statements, including income, cashflow, and shareholder’s equity statements. GPT-3 is showing us that things that we (even recently) thought were impossible can be done with the expansion of AI.