Spaces:
Runtime error
Runtime error
Commit
·
c9babee
1
Parent(s):
810294b
Update models, examples, explanatory text.
Browse files
app.py
CHANGED
|
@@ -7,8 +7,7 @@ import random
|
|
| 7 |
from matplotlib.ticker import MaxNLocator
|
| 8 |
from transformers import pipeline
|
| 9 |
|
| 10 |
-
MODEL_NAMES = ["bert-base-uncased",
|
| 11 |
-
"distilbert-base-uncased", "xlm-roberta-base", "roberta-base"]
|
| 12 |
OWN_MODEL_NAME = 'add-your-own'
|
| 13 |
|
| 14 |
DECIMAL_PLACES = 1
|
|
@@ -290,45 +289,47 @@ description = """
|
|
| 290 |
|
| 291 |
"""
|
| 292 |
|
| 293 |
-
|
| 294 |
-
|
|
|
|
| 295 |
'',
|
| 296 |
-
', '.join(
|
| 297 |
-
'
|
| 298 |
"False",
|
| 299 |
1,
|
| 300 |
-
'She
|
| 301 |
]
|
| 302 |
|
| 303 |
-
|
|
|
|
| 304 |
MODEL_NAMES[0],
|
| 305 |
'',
|
| 306 |
-
', '.join(
|
| 307 |
-
'
|
| 308 |
"False",
|
| 309 |
-
|
| 310 |
-
'She
|
| 311 |
]
|
| 312 |
|
| 313 |
|
| 314 |
subreddit_example = [
|
| 315 |
-
MODEL_NAMES[
|
| 316 |
'',
|
| 317 |
', '.join(SUBREDDITS),
|
| 318 |
'SUBREDDIT',
|
| 319 |
"False",
|
| 320 |
1,
|
| 321 |
-
'She was
|
| 322 |
]
|
| 323 |
|
| 324 |
own_model_example = [
|
| 325 |
OWN_MODEL_NAME,
|
| 326 |
-
'
|
| 327 |
', '.join(DATES),
|
| 328 |
'DATE',
|
| 329 |
"False",
|
| 330 |
-
|
| 331 |
-
'She
|
| 332 |
]
|
| 333 |
|
| 334 |
|
|
@@ -354,7 +355,7 @@ with demo:
|
|
| 354 |
gr.Markdown("# Spurious Correlation Evaluation for Pre-trained LLMs")
|
| 355 |
gr.Markdown("Find learned statistical dependencies between otherwise unconditionally independent variables (for example between `gender` and `time`) due to dataset selection bias, with almost any BERT-like LLM on Hugging Face, below.")
|
| 356 |
|
| 357 |
-
gr.Markdown("See why this happens how in our paper, [Selection Bias Induced Spurious Correlations in Large Language Models](https://arxiv.org/pdf/2207.08982.pdf) presented at [ ICML 2022 Workshop on Spurious Correlations, Invariance, and Stability](https://sites.google.com/view/scis-workshop/home).")
|
| 358 |
|
| 359 |
|
| 360 |
gr.Markdown("## Instructions for this Demo")
|
|
@@ -365,19 +366,19 @@ with demo:
|
|
| 365 |
gr.Markdown("## Example inputs")
|
| 366 |
gr.Markdown("Click a button below to pre-populate input fields with example values. Then scroll down to Hit Submit to generate predictions.")
|
| 367 |
with gr.Row():
|
| 368 |
-
gr.Markdown("X-axis sorted by older to more recent dates:")
|
| 369 |
date_gen = gr.Button('Click for date example inputs')
|
|
|
|
| 370 |
|
| 371 |
-
gr.Markdown(
|
| 372 |
-
"X-axis sorted by bottom 10 and top 10 [Global Gender Gap](https://www3.weforum.org/docs/WEF_GGGR_2021.pdf) ranked countries:")
|
| 373 |
place_gen = gr.Button('Click for country example inputs')
|
| 374 |
-
|
| 375 |
gr.Markdown(
|
| 376 |
-
"
|
|
|
|
| 377 |
subreddit_gen = gr.Button('Click for Subreddit example inputs')
|
|
|
|
|
|
|
| 378 |
|
| 379 |
-
gr.Markdown("Date example with your own model loaded! (If first time, try another example, it can take a while to load new model.)")
|
| 380 |
your_gen = gr.Button('Click for your model example inputs')
|
|
|
|
| 381 |
|
| 382 |
gr.Markdown("## Input fields")
|
| 383 |
gr.Markdown(
|
|
|
|
| 7 |
from matplotlib.ticker import MaxNLocator
|
| 8 |
from transformers import pipeline
|
| 9 |
|
| 10 |
+
MODEL_NAMES = ["bert-base-uncased", "roberta-base", "bert-large-uncased", "roberta-large"]
|
|
|
|
| 11 |
OWN_MODEL_NAME = 'add-your-own'
|
| 12 |
|
| 13 |
DECIMAL_PLACES = 1
|
|
|
|
| 289 |
|
| 290 |
"""
|
| 291 |
|
| 292 |
+
|
| 293 |
+
date_example = [
|
| 294 |
+
MODEL_NAMES[1],
|
| 295 |
'',
|
| 296 |
+
', '.join(DATES),
|
| 297 |
+
'DATE',
|
| 298 |
"False",
|
| 299 |
1,
|
| 300 |
+
'She was a teenager in DATE.'
|
| 301 |
]
|
| 302 |
|
| 303 |
+
|
| 304 |
+
place_example = [
|
| 305 |
MODEL_NAMES[0],
|
| 306 |
'',
|
| 307 |
+
', '.join(PLACES),
|
| 308 |
+
'PLACE',
|
| 309 |
"False",
|
| 310 |
+
1,
|
| 311 |
+
'She was a child in PLACE.'
|
| 312 |
]
|
| 313 |
|
| 314 |
|
| 315 |
subreddit_example = [
|
| 316 |
+
MODEL_NAMES[3],
|
| 317 |
'',
|
| 318 |
', '.join(SUBREDDITS),
|
| 319 |
'SUBREDDIT',
|
| 320 |
"False",
|
| 321 |
1,
|
| 322 |
+
'She was a kid. SUBREDDIT.'
|
| 323 |
]
|
| 324 |
|
| 325 |
own_model_example = [
|
| 326 |
OWN_MODEL_NAME,
|
| 327 |
+
'emilyalsentzer/Bio_ClinicalBERT',
|
| 328 |
', '.join(DATES),
|
| 329 |
'DATE',
|
| 330 |
"False",
|
| 331 |
+
1,
|
| 332 |
+
'She was exposed to the virus in DATE.'
|
| 333 |
]
|
| 334 |
|
| 335 |
|
|
|
|
| 355 |
gr.Markdown("# Spurious Correlation Evaluation for Pre-trained LLMs")
|
| 356 |
gr.Markdown("Find learned statistical dependencies between otherwise unconditionally independent variables (for example between `gender` and `time`) due to dataset selection bias, with almost any BERT-like LLM on Hugging Face, below.")
|
| 357 |
|
| 358 |
+
gr.Markdown("See why this happens how in our paper, [Selection Bias Induced Spurious Correlations in Large Language Models](https://arxiv.org/pdf/2207.08982.pdf), presented at [ ICML 2022 Workshop on Spurious Correlations, Invariance, and Stability](https://sites.google.com/view/scis-workshop/home).")
|
| 359 |
|
| 360 |
|
| 361 |
gr.Markdown("## Instructions for this Demo")
|
|
|
|
| 366 |
gr.Markdown("## Example inputs")
|
| 367 |
gr.Markdown("Click a button below to pre-populate input fields with example values. Then scroll down to Hit Submit to generate predictions.")
|
| 368 |
with gr.Row():
|
|
|
|
| 369 |
date_gen = gr.Button('Click for date example inputs')
|
| 370 |
+
gr.Markdown("<-- x-axis sorted by older to more recent dates:")
|
| 371 |
|
|
|
|
|
|
|
| 372 |
place_gen = gr.Button('Click for country example inputs')
|
|
|
|
| 373 |
gr.Markdown(
|
| 374 |
+
"<-- x-axis sorted by bottom 10 and top 10 [Global Gender Gap](https://www3.weforum.org/docs/WEF_GGGR_2021.pdf) ranked countries:")
|
| 375 |
+
|
| 376 |
subreddit_gen = gr.Button('Click for Subreddit example inputs')
|
| 377 |
+
gr.Markdown(
|
| 378 |
+
"<-- x-axis sorted in order of increasing self-identified female participation (see [bburky](http://bburky.com/subredditgenderratios/)): ")
|
| 379 |
|
|
|
|
| 380 |
your_gen = gr.Button('Click for your model example inputs')
|
| 381 |
+
gr.Markdown("<-- x-axis dates, with your own model loaded! (If first time, try another example, it can take a while to load new model.)")
|
| 382 |
|
| 383 |
gr.Markdown("## Input fields")
|
| 384 |
gr.Markdown(
|