Ben88 commited on
Commit
52e51a9
·
verified ·
1 Parent(s): a0a1a69

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -37,7 +37,7 @@ def expand_abbreviations(medical_report: str) -> str:
37
  input_ids=inputs.input_ids,
38
  attention_mask=inputs.attention_mask,
39
  max_new_tokens=500, # Adjust as needed for longer expansions
40
- #pad_token_id=tokenizer.eos_token_id # Important for generation
41
  )
42
 
43
  # Decode the generated text, skipping the input prompt and special tokens
@@ -74,7 +74,7 @@ def expand_abbreviations(medical_report: str) -> str:
74
  if full_prompt_in_output in decoded_output:
75
  #return decoded_output.replace(full_prompt_in_output, "", 1)
76
  #return "".join(decoded_output.split(full_prompt_in_output, 1)[1].strip().replace("Medical Report: ", "", 1).rsplit("\n.", 1))
77
- return "".join(decoded_output.split(full_prompt_in_output, 1)[1].strip().replace("Medical Report: ", "", 1)
78
  #return decoded_output.split(full_prompt_in_output, 1)[1].strip().replace("Complication: ", "", 1)
79
  else:
80
  # Fallback if the exact prompt with expansion token isn't found (e.g., model generates differently)
 
37
  input_ids=inputs.input_ids,
38
  attention_mask=inputs.attention_mask,
39
  max_new_tokens=500, # Adjust as needed for longer expansions
40
+ pad_token_id=tokenizer.eos_token_id # Important for generation
41
  )
42
 
43
  # Decode the generated text, skipping the input prompt and special tokens
 
74
  if full_prompt_in_output in decoded_output:
75
  #return decoded_output.replace(full_prompt_in_output, "", 1)
76
  #return "".join(decoded_output.split(full_prompt_in_output, 1)[1].strip().replace("Medical Report: ", "", 1).rsplit("\n.", 1))
77
+ return "".join(decoded_output.split(full_prompt_in_output, 1)[1].strip().replace("Medical Report: ", "", 1))
78
  #return decoded_output.split(full_prompt_in_output, 1)[1].strip().replace("Complication: ", "", 1)
79
  else:
80
  # Fallback if the exact prompt with expansion token isn't found (e.g., model generates differently)