Spaces:
Running on Zero
Running on Zero
Score tab: clearer length prompt + friendly too-short error message
Browse files- app.py +6 -5
- byo_features.py +2 -1
app.py
CHANGED
|
@@ -133,7 +133,7 @@ def draw(dataset, which):
|
|
| 133 |
def predict(text, clf_name):
|
| 134 |
text = (text or "").strip()
|
| 135 |
if not text:
|
| 136 |
-
return "
|
| 137 |
if EXTRACTOR is None:
|
| 138 |
return f"⚠️ Base model unavailable: {_LOAD_ERR}", None
|
| 139 |
try:
|
|
@@ -176,10 +176,11 @@ with gr.Blocks(title="Predicting Memorization Before Fine-Tuning") as demo:
|
|
| 176 |
feat = gr.Plot(label="Where this example's features fall (memorized vs not-memorized)")
|
| 177 |
go.click(draw, [d_in, f_in], [pref, gen, verdict, feat])
|
| 178 |
with gr.Tab("Score your own text"):
|
| 179 |
-
gr.Markdown("
|
| 180 |
-
"Pythia-1.4B, our learned classifiers (one per fine-tuning
|
| 181 |
-
"Pythia-1.4B would be to memorize it if you fine-tuned on
|
| 182 |
-
"your text's features fall relative to memorized and
|
|
|
|
| 183 |
txt = gr.Textbox(label="Your text", lines=6)
|
| 184 |
clf_in = gr.Dropdown(sorted(CLFS.keys()), value=sorted(CLFS.keys())[0],
|
| 185 |
label="Choose a classifier")
|
|
|
|
| 133 |
def predict(text, clf_name):
|
| 134 |
text = (text or "").strip()
|
| 135 |
if not text:
|
| 136 |
+
return "Please enter some input text first.", None
|
| 137 |
if EXTRACTOR is None:
|
| 138 |
return f"⚠️ Base model unavailable: {_LOAD_ERR}", None
|
| 139 |
try:
|
|
|
|
| 176 |
feat = gr.Plot(label="Where this example's features fall (memorized vs not-memorized)")
|
| 177 |
go.click(draw, [d_in, f_in], [pref, gen, verdict, feat])
|
| 178 |
with gr.Tab("Score your own text"):
|
| 179 |
+
gr.Markdown("Please enter an input text that is at least 100 tokens (or 75 words). Using its "
|
| 180 |
+
"base-model features from Pythia-1.4B, our learned classifiers (one per fine-tuning "
|
| 181 |
+
"dataset) predict how likely Pythia-1.4B would be to memorize it if you fine-tuned on "
|
| 182 |
+
"it. The plots below show where your text's features fall relative to memorized and "
|
| 183 |
+
"not-memorized examples.")
|
| 184 |
txt = gr.Textbox(label="Your text", lines=6)
|
| 185 |
clf_in = gr.Dropdown(sorted(CLFS.keys()), value=sorted(CLFS.keys())[0],
|
| 186 |
label="Choose a classifier")
|
byo_features.py
CHANGED
|
@@ -33,7 +33,8 @@ class BYOExtractor:
|
|
| 33 |
ids = enc["input_ids"]
|
| 34 |
if ids.shape[1] < WINDOW_LEN:
|
| 35 |
raise ValueError(
|
| 36 |
-
f"
|
|
|
|
| 37 |
return self.features_from_ids(ids[:, :WINDOW_LEN])
|
| 38 |
|
| 39 |
def features_from_ids(self, ids):
|
|
|
|
| 33 |
ids = enc["input_ids"]
|
| 34 |
if ids.shape[1] < WINDOW_LEN:
|
| 35 |
raise ValueError(
|
| 36 |
+
f"The input should be at least {WINDOW_LEN} tokens (or about 75 words); "
|
| 37 |
+
f"you entered {ids.shape[1]} tokens.")
|
| 38 |
return self.features_from_ids(ids[:, :WINDOW_LEN])
|
| 39 |
|
| 40 |
def features_from_ids(self, ids):
|