georad commited on
Commit
52c1069
·
verified ·
1 Parent(s): a6a214d

Update pages/type_text.py

Browse files
Files changed (1) hide show
  1. pages/type_text.py +16 -12
pages/type_text.py CHANGED
@@ -34,14 +34,14 @@ def convert_json(df:pd.DataFrame):
34
  #st.json(json_string, expanded=True)
35
  return json_string
36
 
37
- INTdesc_input = st.text_input("Type internal description and hit Enter", key="user_input")
38
 
39
  createSBScodes, right_column = st.columns(2)
40
  createSBScodes_clicked = createSBScodes.button("Map to SBS codes", key="user_createSBScodes")
41
  right_column.button("Reset", on_click=on_click)
42
 
43
  numMAPPINGS_input = 5
44
- #numMAPPINGS_input = st.text_input("Type number of mappings and hit Enter", key="user_input_numMAPPINGS")
45
  #st.button("Clear text", on_click=on_click)
46
 
47
  @st.cache_resource
@@ -54,19 +54,23 @@ def load_model():
54
  return model
55
  model = load_model()
56
 
57
-
58
 
59
  INTdesc_embedding = model.encode(INTdesc_input)
60
 
61
  # Semantic search, Compute cosine similarity between all pairs of SBS descriptions
62
 
63
- #df_SBS = pd.read_csv("SBS_V2_Table.csv", index_col="SBS_Code", usecols=["Long_Description"]) # na_values=['NA']
64
- #df_SBS = pd.read_csv("SBS_V2_Table.csv", usecols=["SBS_Code_Hyphenated","Long_Description"])
65
- from_row_index = 7725 # Imaging services chapter start, adjust as needed
66
- to_row_index = 8239 # Imaging services chapter end, adjust as needed
67
- nrows = to_row_index - from_row_index + 1
68
- skiprows = list(range(1,from_row_index - 1))
69
- df_SBS = pd.read_csv("SBS_V2_Table.csv", header=0, skip_blank_lines=False, skiprows=skiprows, nrows=nrows)
 
 
 
 
70
  #st.write(df_SBS.head(5))
71
 
72
  SBScorpus = df_SBS['Long_Description'].values.tolist()
@@ -79,8 +83,8 @@ HF_model_results_displayed = HF_model_results_sorted[0:numMAPPINGS_input]
79
 
80
  @st.cache_resource
81
  def load_pipe():
82
- #pipe = pipeline("text-generation", model="meta-llama/Llama-3.2-1B-Instruct", device_map=device,) # device_map="auto", torch_dtype=torch.bfloat16
83
- pipe = pipeline("text-generation", model="Qwen/Qwen2-1.5B-Instruct", device_map=device,) # device_map="auto", torch_dtype="auto"
84
  return pipe
85
  pipe = load_pipe()
86
 
 
34
  #st.json(json_string, expanded=True)
35
  return json_string
36
 
37
+ INTdesc_input = st.text_input("Type internal description", key="user_input")
38
 
39
  createSBScodes, right_column = st.columns(2)
40
  createSBScodes_clicked = createSBScodes.button("Map to SBS codes", key="user_createSBScodes")
41
  right_column.button("Reset", on_click=on_click)
42
 
43
  numMAPPINGS_input = 5
44
+ #numMAPPINGS_input = st.text_input("Type number of mappings", key="user_input_numMAPPINGS")
45
  #st.button("Clear text", on_click=on_click)
46
 
47
  @st.cache_resource
 
54
  return model
55
  model = load_model()
56
 
57
+ selected_chapters_dict = {0: [], 1:[], 2:
58
 
59
  INTdesc_embedding = model.encode(INTdesc_input)
60
 
61
  # Semantic search, Compute cosine similarity between all pairs of SBS descriptions
62
 
63
+ #df_SBS = pd.read_csv("SBS/SBS_V2_Code_Table.csv", index_col="SBS_Code", usecols=["Long_Description"]) # na_values=['NA']
64
+ #df_SBS = pd.read_csv("SBS/SBS_V2_Code_Table.csv", usecols=["SBS_Code_Hyphenated","Long_Description"])
65
+ #from_row_index = 7725 # Imaging services chapter start, adjust as needed
66
+ #to_row_index = 8239 # Imaging services chapter end, adjust as needed
67
+ #nrows = to_row_index - from_row_index + 1
68
+ #skiprows = list(range(1,from_row_index - 1))
69
+
70
+
71
+ selected_rows_to_read =
72
+ df_SBS = pd.read_csv("SBS/SBS_V2_Code_Table.csv", skiprows = lambda x: x not in specific_rows)
73
+ #df_SBS = pd.read_csv("SBS/SBS_V2_Code_Table.csv", header=0, skip_blank_lines=False, skiprows=skiprows, nrows=nrows)
74
  #st.write(df_SBS.head(5))
75
 
76
  SBScorpus = df_SBS['Long_Description'].values.tolist()
 
83
 
84
  @st.cache_resource
85
  def load_pipe():
86
+ pipe = pipeline("text-generation", model="meta-llama/Llama-3.2-1B-Instruct", device_map=device,) # device_map="auto", torch_dtype=torch.bfloat16
87
+ #pipe = pipeline("text-generation", model="Qwen/Qwen2-1.5B-Instruct", device_map=device,) # device_map="auto", torch_dtype="auto"
88
  return pipe
89
  pipe = load_pipe()
90