srijaydeshpande commited on
Commit
4c95250
·
1 Parent(s): 74d1783

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -88,7 +88,6 @@ def txt_to_html(text):
88
  def deidentify_doc(llm_type, pdftext, maxtokens, temperature, top_probability):
89
 
90
  prompt = "In the following text, perform the following actions: 1. Replace only the calendar dates with term [date]. Example: if input is 'Date of birth: 15/5/1959 calculated BP (Systolic 158.00 mm, Diastolic 124.95 mm)' output should be 'Date of birth: [date] calculated BP (Systolic 158.00 mm, Diastolic 124.95 mm)' 2. Replace location or address, such as '3970 Longview Drive, CV36HE' with term [address]. Replace complete GP address, such as 'Phanton Medical Centre, Birmingham, CV36HE' with term [address]. It is important that all addresses are completely replaced with [address]. 3. Replace any person name with term [name]. It is important that all person names are replaced with term [name]. Remove any gender terms 'male' or 'female' if exists. 4. Replace the nhs number and the case note number with term [ID]. Replace Hospital number with [ID]. 4. Replace age of person with [age]. It is important that all age numbers are completely replaced with [age]."
91
- print('LLM TYPE IS ', llm_type)
92
 
93
  if(llm_type == 'Fine tuned LLama3'):
94
 
@@ -176,10 +175,10 @@ def pdf_to_text(files, llm_type, maxtokens=2048, temperature=0, top_probability=
176
  pdftext = page2content[page_id]
177
  response_generator = deidentify_doc(llm_type, pdftext, maxtokens, temperature, top_probability)
178
  print('RESPONSE GENERATOR IS ',response_generator)
179
- for chunk in response_generator:
180
- accumulated_text += chunk
181
- yield accumulated_text # Keep updating output
182
- yield accumulated_text + "\n\n"
183
  # return anonymized_text
184
 
185
  css = ".gradio-container {background: 'logo.png'}"
 
88
  def deidentify_doc(llm_type, pdftext, maxtokens, temperature, top_probability):
89
 
90
  prompt = "In the following text, perform the following actions: 1. Replace only the calendar dates with term [date]. Example: if input is 'Date of birth: 15/5/1959 calculated BP (Systolic 158.00 mm, Diastolic 124.95 mm)' output should be 'Date of birth: [date] calculated BP (Systolic 158.00 mm, Diastolic 124.95 mm)' 2. Replace location or address, such as '3970 Longview Drive, CV36HE' with term [address]. Replace complete GP address, such as 'Phanton Medical Centre, Birmingham, CV36HE' with term [address]. It is important that all addresses are completely replaced with [address]. 3. Replace any person name with term [name]. It is important that all person names are replaced with term [name]. Remove any gender terms 'male' or 'female' if exists. 4. Replace the nhs number and the case note number with term [ID]. Replace Hospital number with [ID]. 4. Replace age of person with [age]. It is important that all age numbers are completely replaced with [age]."
 
91
 
92
  if(llm_type == 'Fine tuned LLama3'):
93
 
 
175
  pdftext = page2content[page_id]
176
  response_generator = deidentify_doc(llm_type, pdftext, maxtokens, temperature, top_probability)
177
  print('RESPONSE GENERATOR IS ',response_generator)
178
+ # for chunk in response_generator:
179
+ # accumulated_text += chunk
180
+ # yield accumulated_text # Keep updating output
181
+ yield response_generator + "\n\n"
182
  # return anonymized_text
183
 
184
  css = ".gradio-container {background: 'logo.png'}"