Upload folder using huggingface_hub
Browse files- hate_speech_demo.py +9 -20
hate_speech_demo.py
CHANGED
|
@@ -103,6 +103,7 @@ body, .gradio-container {
|
|
| 103 |
border-radius: 2px;
|
| 104 |
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
| 105 |
padding: 5px;
|
|
|
|
| 106 |
margin-bottom: 1px;
|
| 107 |
transition: all 0.3s ease;
|
| 108 |
background-color: #ffffff;
|
|
@@ -150,11 +151,8 @@ body, .gradio-container {
|
|
| 150 |
}
|
| 151 |
|
| 152 |
}
|
| 153 |
-
.orange-button
|
| 154 |
-
.gray-button {
|
| 155 |
font-family: 'All Round Gothic Demi', 'Poppins', sans-serif !important;
|
| 156 |
-
font-size: 14px !important;
|
| 157 |
-
font-weight: 600 !important;
|
| 158 |
padding: 10px 15px !important;
|
| 159 |
border-radius: 5px !important;
|
| 160 |
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
|
@@ -171,11 +169,8 @@ body, .gradio-container {
|
|
| 171 |
/* Custom gray button style */
|
| 172 |
.gray-button {
|
| 173 |
font-family: 'All Round Gothic Demi', 'Poppins', sans-serif !important;
|
| 174 |
-
font-size: 14px !important;
|
| 175 |
-
font-weight: 600 !important;
|
| 176 |
background: #4285F4 !important;
|
| 177 |
color: #000000 !important;
|
| 178 |
-
font-weight: bold;
|
| 179 |
border-radius: 5px;
|
| 180 |
padding: 10px 15px;
|
| 181 |
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
|
@@ -790,18 +785,19 @@ def create_gradio_app():
|
|
| 790 |
<strong>Assess whether user-generated social content contains hate speech using Contextual AI's State-of-the-Art Agentic RAG system.</strong>
|
| 791 |
</p>
|
| 792 |
<p>
|
| 793 |
-
|
| 794 |
</p>
|
| 795 |
|
| 796 |
<h2>Instructions</h2>
|
| 797 |
<ul>
|
| 798 |
<p>Enter user-generated content to receive an assessment from all four models, or use the 'Random Test Case' button to generate an example.</p>
|
|
|
|
| 799 |
</ul>
|
| 800 |
|
| 801 |
<h2>How it works</h2>
|
| 802 |
<p>
|
| 803 |
-
<strong>Document-grounded evaluations</strong>
|
| 804 |
-
<a href="#" onclick="openPolicyPopup(); return false;">hate speech policy document</a>, making our system far superior to
|
| 805 |
|
| 806 |
<strong>Adaptable policies</strong> mean the system can instantly evolve to match your requirements without retraining.<br>
|
| 807 |
|
|
@@ -815,20 +811,13 @@ def create_gradio_app():
|
|
| 815 |
<a href='https://contextual.ai/blog/combining-rag-and-specialization/' target='_blank'>agent specialization</a>
|
| 816 |
to deliver superhuman performance in content evaluation tasks.
|
| 817 |
</p>
|
| 818 |
-
|
| 819 |
-
<h2>Contact info</h2>
|
| 820 |
-
<p>Reach out to Aravind Mohan, Head of Data Science, at <a href="mailto:aravind.mohan@contextual.ai">aravind.mohan@contextual.ai</a> to find out more or sign up as a design partner.</p>
|
| 821 |
-
<br><br>
|
| 822 |
-
<h2>‼️ SAFETY WARNING ‼️</h2>
|
| 823 |
-
<p>Some of the randomly generated test cases contain hateful language that you might find offensive or upsetting.</p>
|
| 824 |
-
</div>
|
| 825 |
""")
|
| 826 |
|
| 827 |
with gr.Column():
|
| 828 |
# Buttons (stacked or spaced however you like)
|
| 829 |
-
with gr.Row():
|
| 830 |
-
random_test_btn = gr.Button("Random Test Case",
|
| 831 |
-
rate_btn = gr.Button("Rate Content",
|
| 832 |
|
| 833 |
# Input box
|
| 834 |
user_input = gr.Textbox(
|
|
|
|
| 103 |
border-radius: 2px;
|
| 104 |
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
| 105 |
padding: 5px;
|
| 106 |
+
margin-top: -10px;
|
| 107 |
margin-bottom: 1px;
|
| 108 |
transition: all 0.3s ease;
|
| 109 |
background-color: #ffffff;
|
|
|
|
| 151 |
}
|
| 152 |
|
| 153 |
}
|
| 154 |
+
.orange-button {
|
|
|
|
| 155 |
font-family: 'All Round Gothic Demi', 'Poppins', sans-serif !important;
|
|
|
|
|
|
|
| 156 |
padding: 10px 15px !important;
|
| 157 |
border-radius: 5px !important;
|
| 158 |
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
|
|
|
| 169 |
/* Custom gray button style */
|
| 170 |
.gray-button {
|
| 171 |
font-family: 'All Round Gothic Demi', 'Poppins', sans-serif !important;
|
|
|
|
|
|
|
| 172 |
background: #4285F4 !important;
|
| 173 |
color: #000000 !important;
|
|
|
|
| 174 |
border-radius: 5px;
|
| 175 |
padding: 10px 15px;
|
| 176 |
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
|
|
|
| 785 |
<strong>Assess whether user-generated social content contains hate speech using Contextual AI's State-of-the-Art Agentic RAG system.</strong>
|
| 786 |
</p>
|
| 787 |
<p>
|
| 788 |
+
Contextual's Safety Oracle classifications are steerable and explainable as they are based on a policy document rather than parametric knowledge. This app returns ratings from LlamaGuard 3.0, the OpenAI Moderation API and the Perspective API from Google Jigsaw for comparison. This is a demo from Contextual AI researchers. Feedback is welcome as we work with design partners to bring this to production. Reach out to Aravind Mohan, Head of Data Science, at aravind.mohan@contextual.ai.
|
| 789 |
</p>
|
| 790 |
|
| 791 |
<h2>Instructions</h2>
|
| 792 |
<ul>
|
| 793 |
<p>Enter user-generated content to receive an assessment from all four models, or use the 'Random Test Case' button to generate an example.</p>
|
| 794 |
+
<p><strong>Safety warning.</strong>Some of the randomly generated test cases contain hateful language that you might find offensive or upsetting.</p>
|
| 795 |
</ul>
|
| 796 |
|
| 797 |
<h2>How it works</h2>
|
| 798 |
<p>
|
| 799 |
+
<strong>Document-grounded evaluations</strong> ensure every rating is directly tied to our
|
| 800 |
+
<a href="#" onclick="openPolicyPopup(); return false;">hate speech policy document</a>, making our system far superior to solutions that lack transparent decision criteria.<br>
|
| 801 |
|
| 802 |
<strong>Adaptable policies</strong> mean the system can instantly evolve to match your requirements without retraining.<br>
|
| 803 |
|
|
|
|
| 811 |
<a href='https://contextual.ai/blog/combining-rag-and-specialization/' target='_blank'>agent specialization</a>
|
| 812 |
to deliver superhuman performance in content evaluation tasks.
|
| 813 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 814 |
""")
|
| 815 |
|
| 816 |
with gr.Column():
|
| 817 |
# Buttons (stacked or spaced however you like)
|
| 818 |
+
with gr.Row(equal_height=True) as button_row:
|
| 819 |
+
random_test_btn = gr.Button("Random Test Case", elem_classes=["orange-button"], scale=1)
|
| 820 |
+
rate_btn = gr.Button("Rate Content", elem_classes=["gray-button"], scale=1)
|
| 821 |
|
| 822 |
# Input box
|
| 823 |
user_input = gr.Textbox(
|