AI Debates
Tags: cloudflarechallenge, devchallenge, ai
Published: 2024-04-15 06:56:42

*This is a submission for the [Cloudflare AI Challenge](https://dev.to/devteam/join-us-for-the-cloudflare-ai-challenge-3000-in-prizes-5f99).*


## AI Debates
AI debates is an ai-powered debate platform. Users can add debate or discussion topics and ai agents like Aristotle, Steve Jobs, da Vinci, Elon Musk, Carl Sagan, Madam Curie, Economist will debate on your topic!!

- [https://ai-debates.pages.dev/](https://ai-debates.pages.dev/)
- [https://github.com/prabin-acharya/ai-debates](https://github.com/prabin-acharya/ai-debates)

<!-- Show us the code! Share a public link to your repo and be sure to include a README file with installation instructions. We also encourage you to add a license for your code.  --> 



## Demo

{% embed https://youtu.be/P9UNIcjHKKk %}
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k5qyj7s0rjn0b9bylzl7.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uhxk3tzwaff5mpt6drb8.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c2jp3m43car4vueju6z5.png)












## Background

With the recent advancements in LLMs, many new applications have become possible. I am particularly excited about the vast amount of knowledge they contain. These LLMs are trained on vast amount of data, this includes all the text on the internet, many books from different writers, essays and so on. This includes knowledge about vast amount of topics, from perspective of different writers. 

Despite the name "AI debates", this application can be used to learn about any topic. I wanted to build a build a application where you can give a topic and get different perspective/views on that topic. You can think of it more like a discussion where you set the topic and the world's greatest minds will discuss on that topic. 

We as a society struggle to make collective decisions. In a particular topic there are vast nuances and perspectives which are very hard to accommodate. AI Debates is a small step on that direction that attempts to use AI agents to explore different perspective on any given topic. This is no way near perfect but should get better as LLMs advances. Techniques like fine-tuning models are on the pipeline to improve the ai agents and this will only get better.


## How I Built it
This was my first time building with Cloudflare. I got to learn a lot about how serverless and edge computing works. I was pleasantly surprised by the extensive range of offerings from Cloudflare, which made building this project so much easier and faster.

Here are the technologies I used to build this project:
- Cloudflare Pages
- Cloudflare Workers AI
- Cloudflare D1 database
- Cloudflare R2 for image storage
- Nextjs, gpt-3.5, TailwindCSS

## Multiple Models and Triple Task Types

**Multiple Models(total 6 different models were used)**
It was crucial to incorporate various models in this AI Debates application. These models, each shaped by the datasets they're trained on, carry their own biases and perspectives. By integrating diverse language model types, each trained by different companies, we can harness the unique perspectives and insights they offer. As a result, users can immerse themselves in discussions enriched by a wide range of perspectives, fostering more nuanced and well-rounded debates.

This was made very simple to implement thanks to plethora of AI models offered by cloudflare platform.
Different models used: 

- **[llama-2-7b-chat-fp16](https://developers.cloudflare.com/workers-ai/models/llama-2-7b-chat-fp16/)**
- **[llama-2-13b-chat-awq](https://developers.cloudflare.com/workers-ai/models/llama-2-13b-chat-awq/)**
- **[mistral-7b-instruct-v0.1](https://developers.cloudflare.com/workers-ai/models/mistral-7b-instruct-v0.1/)**
- **[openhermes-2.5-mistral-7b-awq](https://developers.cloudflare.com/workers-ai/models/openhermes-2.5-mistral-7b-awq/)**

- **[stable-diffusion-xl-base-1.0](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-base-1.0/)**
- **[bart-large-cnn](https://developers.cloudflare.com/workers-ai/models/bart-large-cnn/)**

**Task Types Used(3 different task types were used):**
- **Text Generation(3 different models)** - used by ai agents to generate arguments
- **Summarization**: to generate summary of the debates
- **Text-to-Image**: to draw the banner image of the debate

## What's Next

Lots of things! I have barely started. I built it in a week during this challenge. This is the first version. I have lots of ideas to improve it. Here's a sneak peek into what's on the horizon (stay tuned!):

- **Search with cloudflare vectorize** : When users create a debate, suggest similar debates. We can implement this by creating embeddings of the debates and then searching similar ones. Cloudflare Vectorize enables this but I had little time and could not implement during this hackathon.
- **Personalize**: Allow users to create their own agents to take part in debates. Maybe allow them to comment, upvote, downvote?


<!-- Don't forget to add a cover image or an additional tag to this post (if you want). -->

<!-- Thanks for participating! -->