Inspiration
Ever had a foot-in-the-mouth moment? Sometimes we see celebrities, organizations or just us ordinary folks facing backlash due to something we posted on social media (Twitter, LinkedIn, WhatsApp, etc.). Often such situations happen in the heat of the moment without thinking about potential consequences. For example, Elon Musk has made several impulsive posts which, in addition to impacting his reputation, resulted in expensive lawsuits and him having to step down as Tesla’s Chairman. Words once posted can never be taken back, until now. I have created a software application called ‘Speech Shield’ which alerts the user if the message they are sending contains insensitive or noninclusive content and offers an automatically generated alternative wording to still express the same sentiment or simply cancel sending the original message.
What it does
From a user perspective, they interact with their favorite social media app in the same manner as before. When they send a message or post something publicly, ‘Speech Shield’ uses AI to automatically analyze the text and determine if it contains any content that may reflect poorly on the user. If no offensive or inappropriate content is detected, the message is sent normally and the user experience remains unchanged.
On the other hand, if the message contains questionable content, the tool automatically generates an alternate phrasing of the message while attempting to preserve the original sentiment (happy, angry, upset) and presents the user with a choice to either use the alternate phrasing, cancel sending the message altogether, or, proceed with the original message. ‘Speech Shield’ encourages freedom of speech while at the same time promoting diversity and inclusion. ‘Speech Shield’ can be integrated into any messaging system including but not limited to emails, Slack, Twitter, Facebook, etc.
In the demo website I created and linked, chat between multiple users is supported. Going to the website from different windows or devices allows chat between the users. Messages from all senders will be run through Speech Shield, so feel free to try it out.
How we built it
To build my demo of Speech Shield, I created a JS, HTML, and CSS chat website that allows multiple users to chat. The chat is run using a Cloudflare database that stores the messages that have been sent.
For the actual content filtering, I use multiple layers of LLMs. In the first pass, I check if the text contains any content that should be removed. If it doesn’t, the message is sent freely. However, if it should be rewritten, it is fed into another LLM layer to create an alternative phrasing of the message. This is then displayed to the user attempting to send the message. After testing several LLMs, I found that the openAI GPT-3.5-turbo API worked best at generating alternative phrasings of messages.
Challenges we ran into
One of the main challenges was to get chat working between multiple users in the demo, since that wasn't something I've done before. I was not sure how to store the messages so that it is immediately visible to all users. Using the documentation, I was able to figure out how to use a Cloudflare database to handle chat between users and make messages immediately visible.
Accomplishments that we're proud of
I'm proud of the fact that instead of just asking the user to reconsider sending a message, the tool creates an alternative message that the user has the option of sending with just one click. It makes it extremely easy for users to make a better choice. I also like the fact that the tool can potentially save a child (or adult) from being cyberbullied.
What we learned
Previously, I’ve focused more on backend development and algorithms and have had limited experience with frontend HTML/CSS. In this project, I was doing everything on my own so needed to do both frontend and backend. In the process, I became more comfortable using HTML and CSS, and was happy with how the final frontend looked.
What's next for Speech Shield
The current version of Speech Shield is a demo chat, hosted on my own HTML/CSS/JS website. Next, I will work on integrating it into social media and chat platforms such as Twitter, Instagram, and WhatApp. Additionally, to further improve the authenticity of the automatically generated alternative, I would like to enhance ‘Speech Shield’ to take the user’s previous messages or posts as context to learn about their writing style. This will give me an opportunity to tinker with Retrieval Augmented Generation (RAG).
Built With
- api
- cloudflare
- css
- html
- javascript
- openai
Log in or sign up for Devpost to join the conversation.