Spaces:
Sleeping
Sleeping
Elijahbodden
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -61,10 +61,11 @@ presets = {
|
|
61 |
}
|
62 |
|
63 |
|
64 |
-
def custom_lp_logits_processor(ids, logits, lp_start, lp_decay):
|
65 |
-
|
|
|
66 |
print(len(ids), lp_start, pow(lp_decay, len(ids)-lp_start))
|
67 |
-
logits[tokenizer.eos_token_id] *= pow(lp_decay,
|
68 |
return logits
|
69 |
|
70 |
def respond(
|
@@ -105,7 +106,7 @@ def respond(
|
|
105 |
max_tokens=128,
|
106 |
frequency_penalty=frequency_penalty,
|
107 |
presence_penalty=presence_penalty,
|
108 |
-
logits_processor=lambda ids, logits: custom_lp_logits_processor(ids, logits, lp_start, lp_decay)
|
109 |
):
|
110 |
token = message["choices"][0]["text"]
|
111 |
|
|
|
61 |
}
|
62 |
|
63 |
|
64 |
+
def custom_lp_logits_processor(ids, logits, lp_start, lp_decay, prompt_tok_len):
|
65 |
+
generated_tok_number = len(ids) - prompt_tok_len
|
66 |
+
if (generated_tok_number > lp_start):
|
67 |
print(len(ids), lp_start, pow(lp_decay, len(ids)-lp_start))
|
68 |
+
logits[tokenizer.eos_token_id] *= pow(lp_decay, generated_tok_number-lp_start)
|
69 |
return logits
|
70 |
|
71 |
def respond(
|
|
|
106 |
max_tokens=128,
|
107 |
frequency_penalty=frequency_penalty,
|
108 |
presence_penalty=presence_penalty,
|
109 |
+
logits_processor=lambda ids, logits: custom_lp_logits_processor(ids, logits, lp_start, lp_decay, len(convo))
|
110 |
):
|
111 |
token = message["choices"][0]["text"]
|
112 |
|