Meet TorontoBot: Torontoverse’s AI-powered municipal budget analyst
A user-friendly tool to help you dig through Toronto’s “mammoth and tricky beast” of a budget.
The City of Toronto’s annual operating budget is a mammoth and tricky beast. The spending plan passed by city council in February contains a whopping 20,127 expenditure and revenue lines. For residents, activists, journalists, and even elected politicians, it’s incredibly unwieldy — tracking every detail is way beyond the limits of the human brain.
But pssh, who cares about our tiny human brains? We live in a new AI age and I, for one, think it’s time to welcome our robot overlords to the exciting world of municipal finance.
TorontoBot was built with GPT, or Generative Pre-Trained Transformer technology. As transformers go, this one is less an Autobot or Decepticon and more a Large Language Model capable of processing natural-language queries and providing answers.
Trained on a series of Open Data files, TorontoBot can analyze, report on, and make comparisons about spending at Toronto City Hall.
And through Torontoverse’s Discord channel, it’s available to anyone who wants to use it.
Currently, TorontoBot holds in its cold android brain complete operating budgets for Toronto from 2014 to 2023. That decade’s worth of knowledge allows people to ask questions about City spending. Results come complete with charts.
Let’s start with a simple one. TorontoBot, show me Toronto’s total operating expenses by year.
Even a simple query like that is powerful. Currently, to pull up that kind of information, I’d need to visit the City’s Open Data portal, download several spreadsheet files, add them up, and make a comparison.
Prior to the appearance of the Open Data budget dataset, pulling this kind of information together required scouring the City’s website for PDF files and doing a manual comparison.
Let’s keep it going. What if we want to know about a specific spending area? TorontoBot, show me how much Toronto has spent on the cops per year.
In the context of the recent mayoral election, the utility of this should be obvious. For example, there was a lot of talk in the campaign about whether any of the candidates serving on Council, like Josh Matlow or Brad Bradford, had been part of an effort to “defund the police.”
On the other side of the spectrum, some people suggested the police budget has seen wild, unchecked growth over the last 10 years.
The numbers via TorontoBot present the nuanced reality, where police spending has indeed gone up consistently, but growth has been relatively constrained in recent years.
But to really complete the picture, it’s important to put those numbers in context.
Using TorontoBot, you can make all sorts of interesting comparisons, like stacking up police spending with library spending, or revving up a chart comparing spending on transportation — mostly roads — versus spending on transit.
There are some caveats here. So far, TorontoBot only knows about Toronto’s operating budget, not the separate capital budget. To understand the distinction, imagine the city is planning to build a new rec centre. The cost of designing and constructing the centre would fall under the capital budget. The cost of staffing the centre and providing swimming lessons, karate classes, and pickleball programs would fall under the operating budget.
Still, there’s a ton of power here. We can use TorontoBot to tell us stories. For example, asking about TTC fare revenue by year produces this chart:
This shows the impact the pandemic had on the transit system — an impact that’s still being felt this year, as ridership lags behind pre-pandemic levels.
It’s also very useful for searching through the shadowy corners of the budget, where surprising numbers lurk. Like, for example, how the city has spent an increasing amount on security guards in recent years.
Or that the city now spends $8.8 million on costs related to cellphones, up big from a year ago. (Boy, if only we knew someone who could get us a discount on those Rogers rates, am I right?)
It’s a tool that allows all of us to play municipal archeologists, digging through the depths of the budget to find interesting bits of data.
So, please, let us know what you find. Try out TorontoBot, and tag us on social media with your discoveries.
To get started, join us on the Torontoverse Discord. In the #open-data channel, ask a question using the “/torontobot” command.
I recommend starting simple, with a query like “/torontobot Show me Toronto’s 10 biggest expense categories for 2023.” That’ll give you both an answer and a shareable chart like the ones in this article.
From there, you can get more complex — and creative — by asking some of those burning questions you have about how the city spends your money.
TorontoBot is totally free to use. As more people use it, it’ll get smarter about understanding queries and how to map them to the budget data. If you have feedback or would like to contribute to the project, let us know.
TorontoBot is an Open Source project written using Go and OpenAI, and its source code is available on Github. You are encouraged to fork the project and contribute! If you don’t know where to start, just ask in the Discord. It’s a great way to learn LLM/AI basics.
Code and markup by Chris Dinn. ©Torontoverse, 2023