app.py
Browse files
app.py
CHANGED
@@ -131,8 +131,8 @@ print(f"Input file path: {INPUT_FILE}")
|
|
131 |
print(f"Output file path: {OUTPUT_FILE}")
|
132 |
PROMPT_ID = args.prompt_id if args.prompt_id else INPUT_FILE
|
133 |
PROMPT_TOPIC = args.prompt_topic if args.prompt_topic else INPUT_FILE
|
134 |
-
MULTI_PV = args.multi_pv if args.multi_pv else
|
135 |
-
NUM_WORDS = args.num_words if args.num_words else
|
136 |
NUM_TOKENS = args.num_tokens if args.num_tokens else 10000
|
137 |
BEAM_WIDTH = args.beam_width if args.beam_width else 1
|
138 |
ALPHA_MODE = args.alpha_mode if args.alpha_mode else 0
|
@@ -232,6 +232,7 @@ def main(INPUT_FILE, OUTPUT_FILE, PROMPT_ID, PROMPT_TOPIC, MULTI_PV, NUM_WORDS,
|
|
232 |
f.write("The quick brown fox jumps over the lazy dog")
|
233 |
|
234 |
# OUTPUT_FILE = "output.lif" # Changed output filename
|
|
|
235 |
MODEL_CONTEXT_WINDOW = 128_000 # Example context window, adjust if needed for the actual model
|
236 |
SAFETY_THRESHOLD = 2_000
|
237 |
MAX_INPUT_TOKENS = MODEL_CONTEXT_WINDOW - SAFETY_THRESHOLD # Max tokens per model *input slice*
|
@@ -360,6 +361,7 @@ def main(INPUT_FILE, OUTPUT_FILE, PROMPT_ID, PROMPT_TOPIC, MULTI_PV, NUM_WORDS,
|
|
360 |
with open(OUTPUT_FILE, 'w', encoding='utf-8') as writer:
|
361 |
print(" Writing header to output file...")
|
362 |
writer.write(''.join(header_lines))
|
|
|
363 |
print(" Header written. Starting word-by-word prediction.\n")
|
364 |
|
365 |
for turnCount in range(START_TURN, START_TURN + num_words_to_process):
|
@@ -526,6 +528,7 @@ def main(INPUT_FILE, OUTPUT_FILE, PROMPT_ID, PROMPT_TOPIC, MULTI_PV, NUM_WORDS,
|
|
526 |
# 9.7 Write to file
|
527 |
# print(" 9.7: Writing lines to output file...")
|
528 |
writer.write(''.join(lines))
|
|
|
529 |
# print(" Write complete.\n")
|
530 |
|
531 |
# 9.8 Update state
|
@@ -581,6 +584,8 @@ def main(INPUT_FILE, OUTPUT_FILE, PROMPT_ID, PROMPT_TOPIC, MULTI_PV, NUM_WORDS,
|
|
581 |
torch.cuda.empty_cache()
|
582 |
print("\nScript finished.")
|
583 |
|
|
|
|
|
584 |
|
585 |
### RUN MAIN ####
|
586 |
|
@@ -588,7 +593,8 @@ def main(INPUT_FILE, OUTPUT_FILE, PROMPT_ID, PROMPT_TOPIC, MULTI_PV, NUM_WORDS,
|
|
588 |
#START_TURN, MODEL_TAG)
|
589 |
|
590 |
def premain(ip):
|
591 |
-
|
|
|
592 |
|
593 |
demo = gr.Interface(fn=premain, inputs="text", outputs="text")
|
594 |
#demo = gr.Interface(fn=premain)
|
|
|
131 |
print(f"Output file path: {OUTPUT_FILE}")
|
132 |
PROMPT_ID = args.prompt_id if args.prompt_id else INPUT_FILE
|
133 |
PROMPT_TOPIC = args.prompt_topic if args.prompt_topic else INPUT_FILE
|
134 |
+
MULTI_PV = args.multi_pv if args.multi_pv else 100
|
135 |
+
NUM_WORDS = args.num_words if args.num_words else 20
|
136 |
NUM_TOKENS = args.num_tokens if args.num_tokens else 10000
|
137 |
BEAM_WIDTH = args.beam_width if args.beam_width else 1
|
138 |
ALPHA_MODE = args.alpha_mode if args.alpha_mode else 0
|
|
|
232 |
f.write("The quick brown fox jumps over the lazy dog")
|
233 |
|
234 |
# OUTPUT_FILE = "output.lif" # Changed output filename
|
235 |
+
textoutput = ""
|
236 |
MODEL_CONTEXT_WINDOW = 128_000 # Example context window, adjust if needed for the actual model
|
237 |
SAFETY_THRESHOLD = 2_000
|
238 |
MAX_INPUT_TOKENS = MODEL_CONTEXT_WINDOW - SAFETY_THRESHOLD # Max tokens per model *input slice*
|
|
|
361 |
with open(OUTPUT_FILE, 'w', encoding='utf-8') as writer:
|
362 |
print(" Writing header to output file...")
|
363 |
writer.write(''.join(header_lines))
|
364 |
+
textoutput += ''.join(header_lines)
|
365 |
print(" Header written. Starting word-by-word prediction.\n")
|
366 |
|
367 |
for turnCount in range(START_TURN, START_TURN + num_words_to_process):
|
|
|
528 |
# 9.7 Write to file
|
529 |
# print(" 9.7: Writing lines to output file...")
|
530 |
writer.write(''.join(lines))
|
531 |
+
textoutput += ''.join(lines)
|
532 |
# print(" Write complete.\n")
|
533 |
|
534 |
# 9.8 Update state
|
|
|
584 |
torch.cuda.empty_cache()
|
585 |
print("\nScript finished.")
|
586 |
|
587 |
+
return textoutput
|
588 |
+
|
589 |
|
590 |
### RUN MAIN ####
|
591 |
|
|
|
593 |
#START_TURN, MODEL_TAG)
|
594 |
|
595 |
def premain(ip):
|
596 |
+
txtoutput = main("Kangaroos.txt", "KangaroosByQ06.lif", "KangarooEssay", "The Mating Habits of Kangaroos", 100, 1000, 10000, 1, 0, 1, "Qwen")
|
597 |
+
return txtoutput
|
598 |
|
599 |
demo = gr.Interface(fn=premain, inputs="text", outputs="text")
|
600 |
#demo = gr.Interface(fn=premain)
|