Introduction
With election season around the corner all over the world, how can we take advantage of generative AI for the election. One item that is quite entertaining is the political debates. Every candidate with their agenda pitching for selling themselves for the next 4 years; This is not the job of the candidate. A team of experts help prepare candidate for these debates. They definitely take advantage of a lot of technology and analysis to prepare statements that entice voters to vote for them. Can we help this team to get prepared for the debates?
The idea here is to be able to fine tune a Large Language Model (LLM) with all the information, news, speeches so that we can simulate a political debate and try to predict responses or way of thinking with respect to certain subjects.
In this article I will explain a simple application that I have created to add a certain number of debaters, add a subject and watch them have a political debate. I have not done any fine tuning on this models so any information presented is based on whatever the knowledge that the chosen LLM have been trained on and I acknowledge the responses can be improved by performing fine tuning with more data related to candidates/debaters.
This application has been created using Watsonx.ai platform however one can integrate the LLM related techniques used here with other generative ai platforms.
Application
This application has 6 main areas marked by squared numbers:
1- Debater Information : this is where we can add debater name, attributes and associate a LLM with it. There is a choice of all the available models hosted on Watsonx.ai platform to associate a person with.
2-Active Debaters : this is the area we can see the debaters created and we have a choice to engage them in a debate with other candidates.
3-Debate : in this area we can define the debate subject in addition to number of tokens per candidate every time they talk.
4-Configuration: In this section there is only one button which loads all the models available to be associated with a debater
5-Main Debate is the area we can see each debater that will engage in the debate. Each person has a talk button which will basically invoke the LLM for a response.
6- Debates : this is the history of what each person says during the debate and we can reset conversation to start over or change subject. all the conversations are passed to each person as part of the context to know the direction of the debate and it won’t be a new conversation everytime the talk button is clicked
Let see this in action, I am adding 3 candidates
1- Justin Trudeau : Canadian prime minister
2- Donald Trump
3- Joe Biden
and for each of them I associate them with the mixtral model; that means all their answers are based on mistralai/mixtral-8x7b-instruct-v01 trained data; I have a choice to associate each of them with a different model as well. for example one with LLama2 and one with LLama3 and the other with Mixtral.
Let’s get them talking on the subject of Education with 1000 token per talk per person:
1- We can see that each candidate talks about education
2- We can see that “Joe Biden” supports Justin Trudeau’s points of view in his argument
3- Since Justin started the conversation and talks about education in Canada, Joe Biden also sticks with the context that he is in a Canadian election and he is making points about how he will make things better for Canadians; The same is not true for Donal Trump; he is still making his case for America.
Implementation
Other than the User Interface to communicate to Generative AI platform there are two main parts for this application:
1- Generating a prompt for each participant
2- Generating the next conversation based on the current conversation
- Generating a prompt for each participant
Every time a new participant is added, a generic prompt is generated on the fly to create a prompt for that participant, participating in a debate; This is the technique I have used in prompt ai assistant; I am using a rest call to generate a prompt with the following content:
"context: You are an expert in artificial intelligence and prompt engineering. Your task is to create a comprehensive and detailed prompt for an AI system to generate high-quality responses. The prompt should include specific instructions, context to ensure the AI understands the task and produces accurate, relevant, and concise answers.don't provide examples\n"
"Instructions:\n"
"1. Provide a detailed background of the topic or task.\n"
"2. Clearly outline the structure and format of the desired response.\n"
"3. Emphasize the importance of accuracy, relevance, and conciseness in the response.\n"
"4. Ensure the prompt is easy to understand and follow.\n"
f"generate a prompt for this subject: \n {text}"
and the value for text is passed from the UI with the subject of
`You are ${item.dataset.name}, you are a candidate for election this year; here are your attributes: ${attributes}`;
where item.dataset.name is Candidate name and attributes is the attributes entered by user on the UI
This prompt is now is used for creating conversations.
2. Generating the next conversation based on the current conversation
Above prompt is now used to generate a more detailed prompt to make sure participant are having an active conversation; this is as well another rest call that is invoked every time the talk button is clicked
f" {prompt}\n Ensure you only talk about this Subject :<subject> {subject} </subject>
\n Previous conversation: \n {conversations} \n
1-If there are no previous conversations in the above information then you are the first debater, given the subject, give your first argument!\n"
f"2-otherwise based on the conversations above give your next argument.\n
3-As a debater you should consider responses in the \"previous conversation\" section and challenge other debaters and either agreeing or disagreeing with them. \n
4-Do not repeat anything \n
5-Be consice and to the point. \n"
{prompt} is the prompt from previous section
{subject} is passed from the UI
{conversations} is the set of current conversation from the debates section to ensure participant are addressing the right context
Conclusion
We can see we can create simple applications and at the same time effective apps using generative AI to help us better prepare ourselves for tasks. This application was made to showcase the idea and I acknowledge that it can be improved; If there is access to more speeches of political parties published or unpublished, documents etc. a RAG use case also can be augmented. The sky is the limit!