nttwt1597 commited on
Commit
c8bd82f
·
verified ·
1 Parent(s): cb69176

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -27
app.py CHANGED
@@ -22,7 +22,7 @@ import pandas as pd
22
 
23
  import gradio as gr
24
 
25
- model_name = "meta-llama/Meta-Llama-3-8B-Instruct"
26
 
27
  tokenizer = AutoTokenizer.from_pretrained(
28
  model_name,
@@ -44,8 +44,8 @@ quantization_config = BitsAndBytesConfig(
44
 
45
  # Get the model
46
  llm = HuggingFaceLLM(
47
- model_name="meta-llama/Meta-Llama-3-8B-Instruct",
48
- tokenizer_name="meta-llama/Meta-Llama-3-8B-Instruct",
49
  model_kwargs={
50
  "token": token_r,
51
  "quantization_config": quantization_config
@@ -57,7 +57,7 @@ llm = HuggingFaceLLM(
57
  # "temperature": 0.1,
58
  # "top_p": 0.9,
59
  'repetition_penalty': 1.175,
60
- 'early_stopping' : True
61
  },
62
  stopping_ids=stopping_ids,
63
  )
@@ -84,6 +84,8 @@ query_engine_get_study = CitationQueryEngine.from_args(
84
  index_es,
85
  similarity_top_k=5,
86
  citation_chunk_size=2048,
 
 
87
  verbose=True,
88
  )
89
 
@@ -106,13 +108,12 @@ query_engine_get_study = CitationQueryEngine.from_args(
106
 
107
  def get_prompt(text):
108
  studies_response = query_engine_get_study.query(f"""
109
- Based on the provided instructions and clinical trial information, What are the eligibility criteria based on the given clinical trial information, delimited by ### Clinical Trial Information.
110
  Ensure the studies are relevant and have similar study information. Prioritize the following topics when finding related studies:
111
  1. Conditions
112
  2. Intervention/Treatment
113
  3. Study Objectives
114
- 4. Study Design and Phases
115
-
116
 
117
  ### Clinical Trial Information:
118
  {text}
@@ -131,44 +132,42 @@ def get_prompt(text):
131
  Based on the provided instructions and clinical trial information, generate the eligibility criteria for the study.
132
 
133
  ## Instruction:
134
- You are a clinical researcher able to generate new comprehensive eligibility criteria for clinical research based on the given clinical trial information.
135
- By analyze clinical trial information, delimited by ### Clinical Trial Information, and the information from the following papers, delimited by ### Related data, by choose the suitable criteria and optimize for the given clinical trial information for more precise new eligibility criteria generation.
136
- And please giving us an NCT IDs and study names using the following papers, delimited by ### Reference Papers.
137
- The pattern of the output is delimited by ### Pattern of the output.
138
  Ensure the criteria are clear, specific, and suitable for a clinical research information.
139
-
140
- Prioritize the following topics from the clinical trial information
141
- 1. Conditions
142
- 2. Intervention/Treatment
143
- 3. Study Objectives
144
- 4. Study Design and Phase
145
-
146
  ### Clinical Trial Information
147
  {text}
148
-
149
  ### Related data
150
  {study_ref}
151
-
152
  ### Reference Papers
153
  {metadata_list}
154
-
155
  ### Pattern of the output
156
  Inclusion Criteria
157
  1.
158
  2.
159
-
160
  Exclusion Criteria
161
  1.
162
  2.
163
-
164
  Reference Papers
165
  1. NCT ID:
166
- Study Name:
167
  2. NCT ID:
168
- Study Name:
169
  3. NCT ID:
170
- Study Name:
171
- """)
 
 
172
 
173
  # # Extract and clean data
174
  # inclusion_criteria = clean_text(re.search(inclusion_pattern, text, flags).group(1))
 
22
 
23
  import gradio as gr
24
 
25
+ model_name = "meta-llama/Meta-Llama-3.1-8B-Instruct"
26
 
27
  tokenizer = AutoTokenizer.from_pretrained(
28
  model_name,
 
44
 
45
  # Get the model
46
  llm = HuggingFaceLLM(
47
+ model_name=model_name,
48
+ tokenizer_name=model_name,
49
  model_kwargs={
50
  "token": token_r,
51
  "quantization_config": quantization_config
 
57
  # "temperature": 0.1,
58
  # "top_p": 0.9,
59
  'repetition_penalty': 1.175,
60
+ # 'early_stopping': True
61
  },
62
  stopping_ids=stopping_ids,
63
  )
 
84
  index_es,
85
  similarity_top_k=5,
86
  citation_chunk_size=2048,
87
+ node_postprocessors=[SimilarityPostprocessor(similarity_cutoff=0.8)],
88
+ use_async=True
89
  verbose=True,
90
  )
91
 
 
108
 
109
  def get_prompt(text):
110
  studies_response = query_engine_get_study.query(f"""
111
+ Based on the provided instructions and clinical trial information, delimited by ### Clinical Trial Information, which study has similar study information?
112
  Ensure the studies are relevant and have similar study information. Prioritize the following topics when finding related studies:
113
  1. Conditions
114
  2. Intervention/Treatment
115
  3. Study Objectives
116
+ 4. Study Design and Phases
 
117
 
118
  ### Clinical Trial Information:
119
  {text}
 
132
  Based on the provided instructions and clinical trial information, generate the eligibility criteria for the study.
133
 
134
  ## Instruction:
135
+ As a clinical researcher, generate new eligibility criteria for clinical research based on the given clinical trial information.
136
+ Please analyze the given clinical trial information, delimited by ### Clinical Trial Information, and analyze the information from the following papers, delimited by ### Related data, for more precise new eligibility criteria generation. Do not copy the ### Related data.
137
+ Please give us NCT IDs and study names using the following papers, delimited by ### Reference Papers.
138
+ Please follow the pattern of the output, delimited by ### Pattern of the output.
139
  Ensure the criteria are clear, specific, and suitable for a clinical research information.
140
+ Do not generate any other topic, explain text, python code, or any step of thought except the pattern of the output.
141
+
142
+ --------------------------------------------------
 
 
 
 
143
  ### Clinical Trial Information
144
  {text}
145
+ --------------------------------------------------
146
  ### Related data
147
  {study_ref}
148
+ --------------------------------------------------
149
  ### Reference Papers
150
  {metadata_list}
151
+ --------------------------------------------------
152
  ### Pattern of the output
153
  Inclusion Criteria
154
  1.
155
  2.
156
+
157
  Exclusion Criteria
158
  1.
159
  2.
160
+
161
  Reference Papers
162
  1. NCT ID:
163
+ Study Name:
164
  2. NCT ID:
165
+ Study Name:
166
  3. NCT ID:
167
+ Study Name:
168
+
169
+ """
170
+ )
171
 
172
  # # Extract and clean data
173
  # inclusion_criteria = clean_text(re.search(inclusion_pattern, text, flags).group(1))