sthenno commited on
Commit
5f5be0b
·
1 Parent(s): 4388d47

chore(misc): minor improvements

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +3 -4
  3. utils.py +2 -2
README.md CHANGED
@@ -8,7 +8,7 @@ sdk_version: 5.19.0
8
  app_file: app.py
9
  pinned: false
10
  license: gpl-3.0
11
- short_description: Perplexity calculations
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
8
  app_file: app.py
9
  pinned: false
10
  license: gpl-3.0
11
+ short_description: PPL calculations
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -41,11 +41,10 @@ def create_interface() -> gr.Blocks:
41
  manager = ModelManager()
42
 
43
  with gr.Blocks() as demo:
44
- gr.Markdown("# Language Model Perplexity Calculator (Sequential Version)")
45
- gr.Markdown("Enter Hugging Face model checkpoint names (comma-separated).")
46
 
47
  checkpoint_input = gr.Textbox(
48
- label="Checkpoints (e.g. Qwen/Qwen2.5-14B-Instruct)",
49
  value=", ".join(checkpoints),
50
  )
51
 
@@ -53,7 +52,7 @@ def create_interface() -> gr.Blocks:
53
  perplexity_btn = gr.Button("Calculate Perplexity")
54
 
55
  load_output = gr.Textbox(label="Model Loading Status", interactive=False)
56
- perplexity_output = gr.JSON(label="Perplexity Results")
57
 
58
  # Connect event handlers
59
  load_btn.click(
 
41
  manager = ModelManager()
42
 
43
  with gr.Blocks() as demo:
44
+ gr.Markdown("# LLM Perplexity")
 
45
 
46
  checkpoint_input = gr.Textbox(
47
+ label="Checkpoints",
48
  value=", ".join(checkpoints),
49
  )
50
 
 
52
  perplexity_btn = gr.Button("Calculate Perplexity")
53
 
54
  load_output = gr.Textbox(label="Model Loading Status", interactive=False)
55
+ perplexity_output = gr.JSON(label="PPL Results")
56
 
57
  # Connect event handlers
58
  load_btn.click(
utils.py CHANGED
@@ -43,8 +43,8 @@ def _perplexity(model, tokenizer, text):
43
  return torch.exp(torch.tensor(loss)).item()
44
 
45
 
46
- num_samples: Final[int] = 1500 # Sample size for perplexity calculation
47
- sample_length: Final[int] = 128 # Maximum length of text to consider for perplexity
48
 
49
  loaded = load_model(checkpoints)
50
 
 
43
  return torch.exp(torch.tensor(loss)).item()
44
 
45
 
46
+ num_samples: Final[int] = 500 # Sample size for perplexity calculation
47
+ sample_length: Final[int] = 100 # Maximum length of text to consider for perplexity
48
 
49
  loaded = load_model(checkpoints)
50