new input arg introduced
Browse files- app.py +10 -1
- helper/utils.py +2 -1
app.py
CHANGED
@@ -66,6 +66,11 @@ with st.sidebar:
|
|
66 |
"Insert an integer (for size of chunks):", value=20, step=1
|
67 |
)
|
68 |
|
|
|
|
|
|
|
|
|
|
|
69 |
# Input filter
|
70 |
top_n = st.number_input(
|
71 |
"Insert a number (top n rows to be selected):", value=3, step=1
|
@@ -118,7 +123,11 @@ elif uploaded_files:
|
|
118 |
|
119 |
# Create reference table
|
120 |
refs_tab = query_search(
|
121 |
-
"pful for understanding federal income",
|
|
|
|
|
|
|
|
|
122 |
)
|
123 |
refs_tab = refs_tab.head(math.ceil(top_n))
|
124 |
|
|
|
66 |
"Insert an integer (for size of chunks):", value=20, step=1
|
67 |
)
|
68 |
|
69 |
+
# Quantization
|
70 |
+
q_levels = st.number_input(
|
71 |
+
"Insert an integer for levels of quantization:", value=1, step=1
|
72 |
+
)
|
73 |
+
|
74 |
# Input filter
|
75 |
top_n = st.number_input(
|
76 |
"Insert a number (top n rows to be selected):", value=3, step=1
|
|
|
123 |
|
124 |
# Create reference table
|
125 |
refs_tab = query_search(
|
126 |
+
"pful for understanding federal income",
|
127 |
+
documents,
|
128 |
+
query_database,
|
129 |
+
sources,
|
130 |
+
q_levels,
|
131 |
)
|
132 |
refs_tab = refs_tab.head(math.ceil(top_n))
|
133 |
|
helper/utils.py
CHANGED
@@ -217,6 +217,7 @@ def query_search(
|
|
217 |
sentences: list[str],
|
218 |
query_database: list[list[float]],
|
219 |
sources: list[str],
|
|
|
220 |
) -> pd.DataFrame:
|
221 |
"""
|
222 |
Takes a text prompt and searches a predefined database by converting the prompt
|
@@ -239,7 +240,7 @@ def query_search(
|
|
239 |
query_database[i], # Embedding of the sentence
|
240 |
sources[i], # Source of the sentence
|
241 |
quantized_influence(
|
242 |
-
prompt_embed_[0], query_database[i], k=
|
243 |
), # Score calculation
|
244 |
]
|
245 |
for i in range(len(query_database))
|
|
|
217 |
sentences: list[str],
|
218 |
query_database: list[list[float]],
|
219 |
sources: list[str],
|
220 |
+
levels: int,
|
221 |
) -> pd.DataFrame:
|
222 |
"""
|
223 |
Takes a text prompt and searches a predefined database by converting the prompt
|
|
|
240 |
query_database[i], # Embedding of the sentence
|
241 |
sources[i], # Source of the sentence
|
242 |
quantized_influence(
|
243 |
+
prompt_embed_[0], query_database[i], k=levels, use_dagger=False
|
244 |
), # Score calculation
|
245 |
]
|
246 |
for i in range(len(query_database))
|