Spaces:
Runtime error
Runtime error
File size: 2,468 Bytes
f648ebc 24c38f3 6f57bdb f648ebc 6743eeb 040f7cc 824a069 040f7cc ae062a4 a9b8087 82488ed 824a069 82488ed a9b8087 824a069 82488ed f648ebc 82488ed f648ebc 82488ed f648ebc e79b88e f648ebc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
from response_generation import ResponseGenerator
import gradio as gr
DEFAULT_MODEL = "shaneweisz/DialoGPT-finetuned-gab-multiCONAN"
DECODING_CONFIG = {"max_new_tokens": 100, "min_new_tokens": 20, "no_repeat_ngram_size": 5, "num_beams": 10}
TITLE = "Automating Counterspeech in Dialogue Systems"
DESCRIPTION = """
This system has been built by [Shane Weisz](https://shaneweisz.com) for his research project on _Automating Counterspeech in Dialogue Systems_ as part of the [MPhil in Machine Learning and Machine Intelligence](https://www.mlmi.eng.cam.ac.uk/) at Cambridge University. The project is supervised by [Dr Marcus Tomalin](https://www.crassh.cam.ac.uk/about/people/marcus-tomalin/) and forms part of the [Giving Voice to Digital Democracies](https://www.crassh.cam.ac.uk/research/projects-centres/giving-voice-to-digital-democracies/) project on the _The Social Impact of Artificially Intelligent Communications Technology_.
<br/><br/>
**Try it out**: Enter a hate speech comment (or select one of the provided examples below), click Submit, and see if the system generates an appropriate counterspeech response.
"""
ARTICLE = f"""
The system is built by fine-tuning [DialoGPT](https://huggingface.co/microsoft/DialoGPT-medium#:~:text=DialoGPT%20is%20a%20SOTA%20large,single%2Dturn%20conversation%20Turing%20test) on the [MultiCONAN](https://github.com/marcoguerini/CONAN#Multitarget-CONAN) dataset, a dataset comprising a set of hate speech inputs and appropriate [counterspeech](https://dangerousspeech.org/counterspeech/) responses produced under the supervision of trained NGO operators from [Stop Hate UK](https://www.stophateuk.org/).
<br/><br/>
**Model:** {DEFAULT_MODEL}<br>
**Decoding parameters:** {DECODING_CONFIG}
<br/><br/>
_Please note: This system is a prototype and cannot be guaranteed to always generate appropriate responses. Any inappropriate responses expressed by the system should not be construed as reflective of the views or values of the researchers._
"""
model = ResponseGenerator(DEFAULT_MODEL, DECODING_CONFIG)
def respond(input):
return model.respond(input)
demo = gr.Interface(fn=respond, inputs="text", outputs="text", examples=["Muslims are all terrorists", "Jews are stingy and only care about money", "What an idiotic retard", "Damn feminists trying to take over the world. Can't women just accept their place?"], cache_examples = False, title = TITLE, description = DESCRIPTION, article = ARTICLE)
demo.launch()
|