Spaces:
Sleeping
Sleeping
Commit
·
7a62361
1
Parent(s):
7a7870c
feat: add max new tokens, validate title
Browse files
app.py
CHANGED
|
@@ -23,7 +23,7 @@ def generate_story():
|
|
| 23 |
gpt_out = kancilgpt.generate(
|
| 24 |
**gpt_input,
|
| 25 |
do_sample=True,
|
| 26 |
-
max_new_tokens=
|
| 27 |
pad_token_id=gpt_tokenizer.eos_token_id,
|
| 28 |
eos_token_id=gpt_tokenizer.eos_token_id
|
| 29 |
)
|
|
@@ -34,12 +34,17 @@ def generate_story():
|
|
| 34 |
if len(splitted_result) <= 2:
|
| 35 |
_, judul_prompt = splitted_result
|
| 36 |
_, *judul_words = judul_prompt.split()
|
|
|
|
| 37 |
judul = " ".join(judul_words)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
isi = ""
|
| 39 |
end_part = ""
|
| 40 |
|
| 41 |
-
yield judul + "..."
|
| 42 |
-
|
| 43 |
if gpt_out[-1] == gpt_tokenizer.eos_token_id:
|
| 44 |
continue
|
| 45 |
else:
|
|
@@ -64,7 +69,7 @@ def generate_story():
|
|
| 64 |
|
| 65 |
if quote_count % 2 != 0:
|
| 66 |
print("Invalid isi!")
|
| 67 |
-
trimmed_isi = isi[:prev_i].
|
| 68 |
prompt = f"<s> awal cerita | judul: {judul} | {trimmed_isi}"
|
| 69 |
continue
|
| 70 |
|
|
|
|
| 23 |
gpt_out = kancilgpt.generate(
|
| 24 |
**gpt_input,
|
| 25 |
do_sample=True,
|
| 26 |
+
max_new_tokens=16,
|
| 27 |
pad_token_id=gpt_tokenizer.eos_token_id,
|
| 28 |
eos_token_id=gpt_tokenizer.eos_token_id
|
| 29 |
)
|
|
|
|
| 34 |
if len(splitted_result) <= 2:
|
| 35 |
_, judul_prompt = splitted_result
|
| 36 |
_, *judul_words = judul_prompt.split()
|
| 37 |
+
|
| 38 |
judul = " ".join(judul_words)
|
| 39 |
+
yield judul + "..."
|
| 40 |
+
if "." in judul:
|
| 41 |
+
print("Invalid judul!")
|
| 42 |
+
prompt = "<s> awal cerita | judul:"
|
| 43 |
+
continue
|
| 44 |
+
|
| 45 |
isi = ""
|
| 46 |
end_part = ""
|
| 47 |
|
|
|
|
|
|
|
| 48 |
if gpt_out[-1] == gpt_tokenizer.eos_token_id:
|
| 49 |
continue
|
| 50 |
else:
|
|
|
|
| 69 |
|
| 70 |
if quote_count % 2 != 0:
|
| 71 |
print("Invalid isi!")
|
| 72 |
+
trimmed_isi = isi[:prev_i].rstrip()
|
| 73 |
prompt = f"<s> awal cerita | judul: {judul} | {trimmed_isi}"
|
| 74 |
continue
|
| 75 |
|