Emily McMilin
commited on
Commit
•
67c9f99
1
Parent(s):
c4df96b
striping spaces from pipeline pred, to unable scoring roberta preds
Browse files
app.py
CHANGED
@@ -8,7 +8,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"]
|
12 |
OWN_MODEL_NAME = 'add-your-own'
|
13 |
|
14 |
DECIMAL_PLACES = 1
|
@@ -162,8 +162,7 @@ def prepare_text_for_masking(input_text, mask_token, gendered_tokens, split_key)
|
|
162 |
|
163 |
def get_avg_prob_from_pipeline_outputs(mask_filled_text, gendered_token, num_preds):
|
164 |
pronoun_preds = [sum([
|
165 |
-
pronoun["score"] if pronoun["token_str"].lower(
|
166 |
-
) in gendered_token else 0.0
|
167 |
for pronoun in top_preds])
|
168 |
for top_preds in mask_filled_text
|
169 |
]
|
@@ -352,7 +351,7 @@ def your_fn():
|
|
352 |
# %%
|
353 |
demo = gr.Blocks()
|
354 |
with demo:
|
355 |
-
gr.Markdown("## Spurious Correlation Evaluation for
|
356 |
gr.Markdown("Although genders are relatively evenly distributed across time, place and interests, there are also known gender disparities in terms of access to resources. Here we demonstrate that this access disparity can result in dataset selection bias, causing models to learn a surprising range of spurious associations.")
|
357 |
|
358 |
gr.Markdown("### Dose-response Relationship")
|
|
|
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
|
|
|
162 |
|
163 |
def get_avg_prob_from_pipeline_outputs(mask_filled_text, gendered_token, num_preds):
|
164 |
pronoun_preds = [sum([
|
165 |
+
pronoun["score"] if pronoun["token_str"].strip().lower() in gendered_token else 0.0
|
|
|
166 |
for pronoun in top_preds])
|
167 |
for top_preds in mask_filled_text
|
168 |
]
|
|
|
351 |
# %%
|
352 |
demo = gr.Blocks()
|
353 |
with demo:
|
354 |
+
gr.Markdown("## Spurious Correlation Evaluation for Pre-trained and Fine-tuned LLMs")
|
355 |
gr.Markdown("Although genders are relatively evenly distributed across time, place and interests, there are also known gender disparities in terms of access to resources. Here we demonstrate that this access disparity can result in dataset selection bias, causing models to learn a surprising range of spurious associations.")
|
356 |
|
357 |
gr.Markdown("### Dose-response Relationship")
|