Mihaiii commited on
Commit
4c52a93
·
verified ·
1 Parent(s): dc2d79c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
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.6,
25
- top_k_threshold_flat = 10,
26
- eos_penalty = 0.7)
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, add_special_tokens=False, add_generation_prompt=True)
42
-
43
- inputs = tokenizer.encode(wrapped_prompt, add_special_tokens=True, return_tensors="pt").to("cuda")
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 = []