Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -21,9 +21,9 @@ model2 = AutoModelForCausalLM.from_pretrained(model_name)
|
|
21 |
|
22 |
provider = TransformersProvider(model2, tokenizer, device)
|
23 |
strategy = CreativeWritingStrategy(provider,
|
24 |
-
top_p_flat = 0.
|
25 |
-
top_k_threshold_flat =
|
26 |
-
eos_penalty = 0.
|
27 |
creative_sampler = BacktrackSampler(strategy, provider)
|
28 |
|
29 |
def create_chat_template_messages(history, prompt):
|
@@ -38,9 +38,9 @@ def create_chat_template_messages(history, prompt):
|
|
38 |
@spaces.GPU
|
39 |
def generate_responses(prompt, history):
|
40 |
messages = create_chat_template_messages(history, prompt)
|
41 |
-
wrapped_prompt = tokenizer.apply_chat_template(messages, tokenize=False,
|
42 |
-
|
43 |
-
inputs = tokenizer.encode(wrapped_prompt, add_special_tokens=
|
44 |
|
45 |
async def custom_sampler_task():
|
46 |
generated_list = []
|
|
|
21 |
|
22 |
provider = TransformersProvider(model2, tokenizer, device)
|
23 |
strategy = CreativeWritingStrategy(provider,
|
24 |
+
top_p_flat = 0.65,
|
25 |
+
top_k_threshold_flat = 9,
|
26 |
+
eos_penalty = 0.8)
|
27 |
creative_sampler = BacktrackSampler(strategy, provider)
|
28 |
|
29 |
def create_chat_template_messages(history, prompt):
|
|
|
38 |
@spaces.GPU
|
39 |
def generate_responses(prompt, history):
|
40 |
messages = create_chat_template_messages(history, prompt)
|
41 |
+
wrapped_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
42 |
+
#it already has special tokens from wrapped_prompt
|
43 |
+
inputs = tokenizer.encode(wrapped_prompt, add_special_tokens=False, return_tensors="pt").to("cuda")
|
44 |
|
45 |
async def custom_sampler_task():
|
46 |
generated_list = []
|