nafisneehal commited on
Commit
e0b2faf
·
verified ·
1 Parent(s): 2d715b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -14
app.py CHANGED
@@ -13,37 +13,26 @@ tokenizer = AutoTokenizer.from_pretrained(model_name)
13
  # Default values for system and user input
14
  test_instruction_string = """
15
  You are a helpful assistant with experience in the clinical domain and clinical trial design. You'll be asked queries related to clinical trials. These inquiries will be delineated by a '##Question' heading. Inside these queries, expect to find comprehensive details about the clinical trial structured within specific subsections, indicated by '<>' tags. These subsections include essential information such as the trial's title, brief summary, condition under study, inclusion and exclusion criteria, intervention, and outcomes.
16
-
17
  In answer to this question, return a list of probable baseline features (each feature should be enclosed within a pair of backticks and each feature should be separated by commas from other features) of the clinical trial. Baseline features are the set of baseline or demographic characteristics that are assessed at baseline and used in the analysis of the primary outcome measure(s) to characterize the study population and assess validity. Clinical trial-related publications typically include a table of baseline features assessed by arm or comparison group and for the entire population of participants in the clinical trial.
18
-
19
  Do not give any additional explanations or use any tags or headers, only return the list of baseline features.
20
  """
21
 
22
  test_input_string = """
23
  ###Question:
24
-
25
  <Title:>Vinorelbine in Treating Patients With Advanced Solid Tumors That Have Not Responded to Treatment and Liver Dysfunction <BriefSummary:>RATIONALE: Drugs used in chemotherapy, such as vinorelbine, work in different ways to stop the growth of tumor cells, either by killing the cells or by stopping them from dividing.
26
-
27
  PURPOSE: This pilot trial is studying the side effects and best dose of vinorelbine in treating patients with advanced solid tumors that have not responded to treatment and liver dysfunction. <EligibilityCriteria:>DISEASE CHARACTERISTICS:
28
-
29
  * Histologically confirmed advanced solid tumor
30
-
31
  * Any histology allowed
32
  * Refractory to standard therapy OR no standard therapy exists
33
-
34
  * Previously untreated non-small cell lung cancer allowed, provided abnormal liver function is present, defined as moderate (group 3) or severe (group 4)
35
  * Measurable disease not required
36
-
37
  * Present measurable disease requires baseline measurements within 4 weeks of study entry
38
  * Patients with acute hepatitis from viral or drug etiologies should recover to a stable baseline prior to study therapy
39
  * History of brain metastasis allowed, provided the following criteria are met:
40
-
41
  * Metastasis has been controlled by radiotherapy or surgery
42
  * Patient is not currently on corticosteroids
43
  * Neurologic status is stable
44
-
45
  PATIENT CHARACTERISTICS:
46
-
47
  * Karnofsky performance status 70-100%
48
  * Life expectancy ≥ 2 months
49
  * ANC = 1,500/mm³
@@ -57,9 +46,7 @@ PATIENT CHARACTERISTICS:
57
  * No concurrent illness (e.g., cardiovascular, pulmonary, or central nervous system) that is poorly controlled or of such severity that the investigator deems unwise to enter the patient on protocol
58
  * Must have ability to comply with study treatment and required tests
59
  * Obstructive jaundice requires a drainage procedure prior to study treatment
60
-
61
  PRIOR CONCURRENT THERAPY:
62
-
63
  * See Disease Characteristics
64
  * Recovered from prior therapy
65
  * At least 3 weeks since prior chemotherapy (6 weeks for mitomycin or nitrosourea therapy)
@@ -79,7 +66,8 @@ def generate_response(system_instruction, user_input):
79
  # Generate model response
80
  with torch.no_grad():
81
  generated_ids = model.generate(model_inputs, max_new_tokens=1000, do_sample=True)
82
- response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0].split("Bot:")[-1].strip()
 
83
 
84
  return response
85
 
 
13
  # Default values for system and user input
14
  test_instruction_string = """
15
  You are a helpful assistant with experience in the clinical domain and clinical trial design. You'll be asked queries related to clinical trials. These inquiries will be delineated by a '##Question' heading. Inside these queries, expect to find comprehensive details about the clinical trial structured within specific subsections, indicated by '<>' tags. These subsections include essential information such as the trial's title, brief summary, condition under study, inclusion and exclusion criteria, intervention, and outcomes.
 
16
  In answer to this question, return a list of probable baseline features (each feature should be enclosed within a pair of backticks and each feature should be separated by commas from other features) of the clinical trial. Baseline features are the set of baseline or demographic characteristics that are assessed at baseline and used in the analysis of the primary outcome measure(s) to characterize the study population and assess validity. Clinical trial-related publications typically include a table of baseline features assessed by arm or comparison group and for the entire population of participants in the clinical trial.
 
17
  Do not give any additional explanations or use any tags or headers, only return the list of baseline features.
18
  """
19
 
20
  test_input_string = """
21
  ###Question:
 
22
  <Title:>Vinorelbine in Treating Patients With Advanced Solid Tumors That Have Not Responded to Treatment and Liver Dysfunction <BriefSummary:>RATIONALE: Drugs used in chemotherapy, such as vinorelbine, work in different ways to stop the growth of tumor cells, either by killing the cells or by stopping them from dividing.
 
23
  PURPOSE: This pilot trial is studying the side effects and best dose of vinorelbine in treating patients with advanced solid tumors that have not responded to treatment and liver dysfunction. <EligibilityCriteria:>DISEASE CHARACTERISTICS:
 
24
  * Histologically confirmed advanced solid tumor
 
25
  * Any histology allowed
26
  * Refractory to standard therapy OR no standard therapy exists
 
27
  * Previously untreated non-small cell lung cancer allowed, provided abnormal liver function is present, defined as moderate (group 3) or severe (group 4)
28
  * Measurable disease not required
 
29
  * Present measurable disease requires baseline measurements within 4 weeks of study entry
30
  * Patients with acute hepatitis from viral or drug etiologies should recover to a stable baseline prior to study therapy
31
  * History of brain metastasis allowed, provided the following criteria are met:
 
32
  * Metastasis has been controlled by radiotherapy or surgery
33
  * Patient is not currently on corticosteroids
34
  * Neurologic status is stable
 
35
  PATIENT CHARACTERISTICS:
 
36
  * Karnofsky performance status 70-100%
37
  * Life expectancy ≥ 2 months
38
  * ANC = 1,500/mm³
 
46
  * No concurrent illness (e.g., cardiovascular, pulmonary, or central nervous system) that is poorly controlled or of such severity that the investigator deems unwise to enter the patient on protocol
47
  * Must have ability to comply with study treatment and required tests
48
  * Obstructive jaundice requires a drainage procedure prior to study treatment
 
49
  PRIOR CONCURRENT THERAPY:
 
50
  * See Disease Characteristics
51
  * Recovered from prior therapy
52
  * At least 3 weeks since prior chemotherapy (6 weeks for mitomycin or nitrosourea therapy)
 
66
  # Generate model response
67
  with torch.no_grad():
68
  generated_ids = model.generate(model_inputs, max_new_tokens=1000, do_sample=True)
69
+ # Extract only the bot's response, omitting the prompt
70
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0].split("\n")[-1].strip()
71
 
72
  return response
73