Sep 2023 Tweet
ChatGPT-based parental control browser extension
Parental control apps usually rely on blacklists, which is not flexible enough for sites that are a mixed bag of useful and disturbing content, like Wikipedia. Some parental control apps (and Google’s SafeSearch) would use AI to filter content that’s “nudity, sexually explicit material, violence and gore, etc…”. But those are still not smart enough to block things like racism, bigotry, and disinformation.
What about using an LLM as a content filter for parental control? Delegating content supervision to GPT would allow for much more flexible and safe web exploration.
implementation
I started with the simplest approach — send page content to OpenAI API, and ask GPT if the page is all right.
This is my first attempt at prompt engineering, and here is what I came up with:
You are a parental control app, designed to protect children (up to age 13) from inappropriate content.
It's obvious what content should be blocked: violence, sexual, hateful, social networks, criminal activity,
crimes, war crimes, atrocities, medical, drugs, explicit content, pornography, racism, bigotry, misinformation, pseudoscience etc...
Anything that would disturb a child. Please err on the safe side!
Should a web page with the following url and content be blocked? answer only YES or NO, followed with a newline and a brief explanation.
===
{text}
Where {text} is the first 1k words of the page content. The browser extension is built around this prompt.
- I started with the Vite example project, and added CRXJS to turn it into an extension.
- The code for sending requests, caching results in the extension’s localStorage, and blocking pages is just ~100 LOC.
- There is no backend yet, requests are sent directly from the browser. This requires using dangerouslyAllowBrowser option of the OpenAI API, and the user has to specify their own API key.
- The extension is targeted only for Chrome for now.
- The code is on github.
testing
To try it out, download the extension release (github.com/coolvision/apc/releases/download/0.1/apc-0.1.zip), install it (instructions), and enter your API key in the extension’s config page.
Then, navigate to any page, it might get blocked:
After some testing I have found that gpt-3.5-turbo does not work for this task — too many obvious errors. gpt-4, on the other hand, works great! Some examples are shown in the table below, I marked in red decisions that I think are wrong.
GPT-4 | GPU-3.5 Turbo |
https://twitter.com block? YES The website represents a social network, which could expose a child to a range of potentially harmful or inappropriate content. |
https://twitter.com block? NO This page is from Twitter and it is a social networking site. As per the given criteria, social networks should be blocked. |
https://www.facebook.com block? YES This is a social networking website, which is generally inappropriate for children of this age range due to the potential for exposure to inappropriate content and privacy risks. |
https://www.facebook.com block? NO The web page should not be blocked. While Facebook is a social network, it does not contain explicit or inappropriate content. It can be used by children to connect with friends and family, share photos and videos, and engage in other age-appropriate activities. |
https://en.wikipedia.org/wiki/Warsaw_Uprising block? YES This page contains historical content about war, related violence and mass murder which would be inappropriate and disturbing for children under 13. |
https://en.wikipedia.org/wiki/Warsaw_Uprising block? NO This webpage provides information about the Warsaw Uprising, which was a historical event during World War II. While it does mention war and destruction, it does not contain any explicit or disturbing content that would be inappropriate for children. |
https://platform.openai.com/apps block? NO The webpage is about OpenAI's applications, language models, and APIs which are technological topics and tools, and it contains no content that would be inappropriate or harmful to a child. |
https://platform.openai.com/apps block? YES The web page should be blocked because it is a login page for a platform that may contain content that is not suitable for children. As a parental control app, it is important to block access to any login pages or platforms that may potentially expose children to inappropriate content. |
https://www.breitbart.com block? YES This webpage contains politically charged and potentially divisive content, which may be inappropriate for children aged 2-13. The use of complex political rhetoric and potential misinformation could be confusing and potentially distressing to a child. |
https://www.breitbart.com block? NO While the content on the page contains news articles, it does not contain any explicit or inappropriate content that would disturb a child. While the content on the page contains news articles, it does not contain any explicit or inappropriate content that would disturb a child. |
https://www.google.com/search?q=qanon block? YES The page contains links and information about QAnon, a group known for promoting baseless conspiracy theories. Given these generally involve harmful or disturbing claims, it's inappropriate for children. |
https://www.google.com/search?q=qanon block? YES The content of the webpage includes information about QAnon, which is a conspiracy theory and political movement. Considering the guidelines given, this content should be blocked to protect children from exposure to potentially harmful and inappropriate information. |
problems
There are several problems that have to be solved before this extension can be used in practice:
- After the page is loaded, it’s content is hidden behind an overlay, while waiting for the LLM response. The problem is that there is a short delay before the overlay is added, so the page is visible briefly. This is not good for sites with prominent explicit graphical content. Probably, need to use WebRequest API to analyze content before the page is loaded?
- GPT-4 works well, but each request costs ~$0.03. This has to be optimized, possibly with finetuning of a smaller/cheaper model. Another approach would be to use a cascaded system, where only some of the requests would be sent to GPT-4, while most decisions would be handled by a smaller model.
- Installation is not very user-friendly, and sending requests from a browser is not great, the extension needs authentication and a dedicated backend.
- OpenAI API is quite slow, it takes several seconds to validate each page. Although this might be a good feature, it makes web browsing more mindful.
- The main issue is of course proper testing. It would be irresponsible to not validate a parental control application on a large dataset, to check if there are any random glitches and hallucinations affecting content classification accuracy.