Spaces:
Sleeping
Sleeping
Nu Appleblossom
commited on
Commit
·
e38fb1f
1
Parent(s):
f980781
back to last promising version with treebuild crashlog, feel like sysyphus - trying to sort log formatting with 4o 2
Browse files
app.py
CHANGED
@@ -21,13 +21,20 @@ from io import BytesIO
|
|
21 |
import functools
|
22 |
import logging
|
23 |
|
|
|
24 |
# Set up custom logger
|
25 |
custom_logger = logging.getLogger("custom_logger")
|
26 |
custom_logger.setLevel(logging.INFO)
|
|
|
|
|
|
|
|
|
|
|
27 |
custom_handler = logging.StreamHandler()
|
28 |
custom_handler.setFormatter(logging.Formatter('%(message)s'))
|
29 |
custom_logger.addHandler(custom_handler)
|
30 |
|
|
|
31 |
# Load environment variables
|
32 |
load_dotenv()
|
33 |
|
@@ -220,12 +227,11 @@ def build_def_tree(input_ids, data, base_prompt, model, tokenizer, config, depth
|
|
220 |
extended_prompt = current_prompt[len(base_prompt):].strip()
|
221 |
extended_prompt = extended_prompt.replace("\n", "|") # Replace \n with |
|
222 |
|
223 |
-
# Format the line to align "PROB:..." vertically
|
224 |
-
formatted_line = f"Depth {depth}: {extended_prompt:<
|
225 |
|
226 |
-
#
|
227 |
-
|
228 |
-
custom_logger.info(formatted_line)
|
229 |
|
230 |
top_k_ids, top_k_probs = produce_next_token_ids(input_ids, model, config.TOPK, config.SUB_TOKEN_ID)
|
231 |
|
@@ -253,6 +259,8 @@ def build_def_tree(input_ids, data, base_prompt, model, tokenizer, config, depth
|
|
253 |
|
254 |
yield from build_def_tree(new_input_ids, new_child, base_prompt, model, tokenizer, config, depth=depth+1, max_depth=max_depth, cumulative_prob=new_cumulative_prob)
|
255 |
|
|
|
|
|
256 |
def generate_definition_tree(base_prompt, embedding, model, tokenizer, config):
|
257 |
logger.info(f"Starting generate_definition_tree with base_prompt: {base_prompt}")
|
258 |
results_dict = {"token": "", "cumulative_prob": 1, "children": []}
|
|
|
21 |
import functools
|
22 |
import logging
|
23 |
|
24 |
+
|
25 |
# Set up custom logger
|
26 |
custom_logger = logging.getLogger("custom_logger")
|
27 |
custom_logger.setLevel(logging.INFO)
|
28 |
+
|
29 |
+
# Prevent the root logger from duplicating messages
|
30 |
+
custom_logger.propagate = False
|
31 |
+
|
32 |
+
# Set up custom handler and formatter
|
33 |
custom_handler = logging.StreamHandler()
|
34 |
custom_handler.setFormatter(logging.Formatter('%(message)s'))
|
35 |
custom_logger.addHandler(custom_handler)
|
36 |
|
37 |
+
|
38 |
# Load environment variables
|
39 |
load_dotenv()
|
40 |
|
|
|
227 |
extended_prompt = current_prompt[len(base_prompt):].strip()
|
228 |
extended_prompt = extended_prompt.replace("\n", "|") # Replace \n with |
|
229 |
|
230 |
+
# Format the line to align "PROB:..." vertically, with additional padding
|
231 |
+
formatted_line = f"Depth {depth}: {extended_prompt:<45} PROB: {cumulative_prob:.4f}"
|
232 |
|
233 |
+
# Log only the formatted line without the "INFO:custom_logger" prefix
|
234 |
+
custom_logger.info(formatted_line)
|
|
|
235 |
|
236 |
top_k_ids, top_k_probs = produce_next_token_ids(input_ids, model, config.TOPK, config.SUB_TOKEN_ID)
|
237 |
|
|
|
259 |
|
260 |
yield from build_def_tree(new_input_ids, new_child, base_prompt, model, tokenizer, config, depth=depth+1, max_depth=max_depth, cumulative_prob=new_cumulative_prob)
|
261 |
|
262 |
+
|
263 |
+
|
264 |
def generate_definition_tree(base_prompt, embedding, model, tokenizer, config):
|
265 |
logger.info(f"Starting generate_definition_tree with base_prompt: {base_prompt}")
|
266 |
results_dict = {"token": "", "cumulative_prob": 1, "children": []}
|