Grant Project Reflection: Jason Shang on using AI to talk to the Brother's Karamazov

By Jason // May 10, 2024

The blog post below was written by Jason Shang, Trinity '24.  In the fall of 2024 he was provided a Co-Lab grant to work on this project.

Earlier this semester, I attended a lecture by Duke alum and Stanford professor Ge Wang, who posed interesting questions regarding our relationship with technology and AI – do we want AI to be an oracle or a tool? Is technology helping us to be happy, or is it just being used to make somebody somewhere stupid rich? Why is nobody questioning the deeply problematic assumptions that the tech industry is operating under, that everything that can be automated should be automated, that more convenience is always desirable, and that progress in AI should be measured by how close AI can get to be indistinguishable from humans?

Indeed, the logic underlying tech development has always been a profit-driven one. As metrics used to measure the wellbeing of capitalism and its corporations, such as productivity and efficiency, are increasingly confounded with measures that evaluate human wellbeing, we churn out new products and technologies that serve not human beings, but this omniscient and omnipotent economic system, the invisible hand of the market. App after app and website after website seek to make people more productive or attract people’s attention and screen time to boost ad revenue. Innovation efforts are poured into all sorts of different directions while important questions get swept under the rug - what does meaningful human interaction with technology even look like? How can technology be used to make us happier?

Why are we designing generative AI to replicate such deeply human forms of expression – writing, painting, and filmmaking? It seems that we’re turning artworks from avenues to offer different perspectives for perceiving the world into mere commodities that can be produced efficiently and at scale and are just good enough to be monetized.

These are the questions I’ve been pondering. As a very rudimentary answer to these very deep questions, I wanted to build something simply for people’s enjoyment without any career or profit motivations. I wanted to treat coding as a creativity outlet and as something more than a productivity or money-printing tool.

Completely separately from these existential thoughts as a programmer about my relationship with technology and the capitalist system, I found myself in this Russian literature class that does a close reading of The Brothers Karamazov. It was a mind-blowing read, an incredible Christian apologetic, and an inspiring tale of love and beauty despite the world’s suffering. I felt the dots connect and found the spark of creativity in me.  As a gift to my professor who is teaching her last semester ever after more than forty years at Duke, I wanted to make a gamified website based on the world that Dostoevsky constructed in The Brothers Karamazov. I wanted to animate the characters with AI and allow users to talk to them at different points in the novel. I was particularly excited by AI’s potential to fill in scenes that aren’t explicitly described in the book. I wanted the users to act like residents in the town of Skotoprigonyevsk and talk to these characters directly as if they’re friends/acquaintances, and thereby escape the confines of what was written and form their own stories and conversations with the characters. Perhaps take a glimpse inside the characters’ inner world to gain a deeper understanding of the characters’ feelings and motivations.

To make these characters come to live, I built a website on top of a retrieval-augmented generation (RAG) pipeline. I divided the entire text into 2,000-character chunks and stored them in a database. Then, I wrote prompts that described my interpretations of each character at each scene, including how they must be feeling, why they did what they did, what they’re perhaps thinking about. Every time the user submits a question on the website, I combine the question with the corresponding prompt to search for the relevant parts of the text in the database (the search is made efficient with embeddings and cosine similarity searches). I then pass the top results of the search, along with the user question, as input to a large language model (Anthropic Claude 3 Opus), which then returns the response that is shown on the website. As for the aesthetics of the website, that is in large part generated by ChatGPT.

screenshot of the application showing a Russian town at night, video game icons of characters

I had a blast designing the scenes and characters on the website. Allowing the users to role-play as Alyosha and Ivan as they engage in the Grand Inquisitor discussion, encountering Alyosha after his powerful wedding at Cana vision, talking to Smerdyakov right before he commits suicide, engaging with the devil from Ivan’s hallucinations, uncovering Katerina’s real thoughts about Dmitry and Ivan after her testimony that is full of contradictions… Sculpting these scenes and characters gave me the unique opportunity to really imagine myself in the character’s shoes and I love the reflections that came with that opportunity.

screenshot of chatbot

            Overall, the project rejuvenated me with two things I love – reading and building software. Different topics really came together for me: as I thought about what meaningful human interaction with technology looks like, the website offered me an avenue to “rebel” against the profit-driven modality that tech is completely subjugated under and to cultivate my curiosity and creativity simply for the sake of my enjoyment. As I did close readings of the text to sculpt out my AI characters, the ideas of community, love, and seeing beauty despite the world’s suffering shined through and are inspiring me to think more closely about how tech could be used in a non-profit-driven framework to facilitate a more loving and regenerative future… It’s been an inspiring journey, and I’m so glad I had the opportunity to work on this project.