jaydeepb commited on
Commit
929bb2f
·
verified ·
1 Parent(s): 6916d7e

Score tab: clearer length prompt + friendly too-short error message

Browse files
Files changed (2) hide show
  1. app.py +6 -5
  2. 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 "Paste a passage first.", None
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("Paste a passage (at least ~100 tokens). Using its base-model features from "
180
- "Pythia-1.4B, our learned classifiers (one per fine-tuning dataset) predict how likely "
181
- "Pythia-1.4B would be to memorize it if you fine-tuned on it. The plots below show where "
182
- "your text's features fall relative to memorized and not-memorized examples.")
 
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"Need at least {WINDOW_LEN} tokens (got {ids.shape[1]}). Paste a longer passage.")
 
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):