AI Dungeon 2, a revolutionary text adventure game powered by machine learning, started as a humble hackathon project. This article delves into the challenges and solutions encountered while scaling the game to support over 1,000,000 users. From initial limitations to innovative solutions, discover how AI Dungeon 2 overcame technical hurdles and achieved remarkable growth.
In March 2019, AI Dungeon was born as a twist on the classic text adventure game. What set it apart was the use of machine learning to generate the story and available actions. The initial version, while promising, had limitations:
These issues stemmed from the limitations of the then-largest GPT-2 model (355 million parameters). Despite improvements, a truly open world remained elusive.
The release of OpenAI's full 1.5 billion parameter GPT-2 model in November unlocked new possibilities. This breakthrough paved the way for AI Dungeon 2, a truly open-world text adventure. Players could now input any action, leading to unprecedented levels of creativity and unpredictable scenarios, such as starting a skeleton rock band or eating the moon! As the game's description says, anything is possible.
The game's innovative approach resonated with gamers. A surge of popularity followed taking AI Dungeon 2 to the top of Hacker News and popular gaming channels. Within a single week, the game was able to attract 100,000 players, resulting in over half a million play-throughs. However, this rapid growth came with a significant challenge: escalating costs.
Initially, AI Dungeon 2 ran on Google Colab, a free platform that provided GPU instances necessary for handling the AI model. This approach seemed cost-effective, but a critical oversight led to a financial crisis: data egress charges.
Each new game required downloading the 5GB AI Dungeon model, costing between $0.30 and $0.40 per download. These costs quickly spiraled out of control.
The daily expenses climbed rapidly:
Ultimately, the bill reached a staggering $50,000 in just three days, forcing a temporary shutdown of AI Dungeon 2.
Within 12 hours of the shutdown, the AI Dungeon 2 community demonstrated its resilience. They developed a peer-to-peer solution, distributing the model via torrent, a way of creating a network of computers where people can download and upload files from each other simultaneously. This ingenious workaround eliminated egress charges and brought the game back online, highlighting the community's crucial role in AI Dungeon 2's sustainability.
However, torrenting was a temporary fix. To reach a broader audience and build a sustainable product, AI Dungeon 2 needed to transition into a real application. They needed to deploy the AI model as a backend web service, essentially a "predict API" that the application could query with user inputs.
To streamline this process, the development team leveraged Cortex, an open-source tool designed for deploying machine learning models. Cortex automated key tasks:
This approach replaced a complex infrastructure built on Flask, Docker, Kubernetes, and various AWS services simplifying the deployment process while also lowering costs.
Deploying the model as a backend service opened up the game to more players. To make it affordable the team had to employ cost-optimization strategies:
These optimizations reduced costs by approximately 90% compared to the initial Colab setup. Within two weeks, the server count peaked at 715, supporting over 100,000 players. Six weeks later, AI Dungeon 2 surpassed 1,000,000 users and 6,000,000 unique stories which represents the power of machine learning and creative collaboration
The success of AI Dungeon 2 resulted from a community effort. From funding development through Patreon to providing technical solutions, the players, developers, and open-source contributors have all played a part in this success:
As AI Dungeon evolves and potentially expands into a broader platform for ML-driven games, the community will undoubtedly remain a crucial driver of innovation and growth.
The journey of scaling AI Dungeon 2 from a hackathon project to a platform enjoyed by over a million users showcases the power of community, innovation, and strategic problem-solving. While AI Dungeon 2 started as an experiment it has become a testimate to how AI can be implemented in gaming and how niche communities can keep a project afloat. By overcoming technical challenges and embracing community contributions, AI Dungeon 2 has carved a unique space in the world of interactive storytelling and machine learning.