research14 commited on
Commit
f2bf6a1
·
1 Parent(s): 98e9a40

enabled do_sample

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -5,8 +5,8 @@ import os
5
  import openai
6
 
7
  # Load the Vicuna 7B model and tokenizer
8
- vicuna_tokenizer = AutoTokenizer.from_pretrained("lmsys/vicuna-7b-v1.5")
9
- vicuna_model = AutoModelForCausalLM.from_pretrained("lmsys/vicuna-7b-v1.5")
10
 
11
  # Load the LLaMA 7b model and tokenizer
12
  llama_tokenizer = AutoTokenizer.from_pretrained("daryl149/llama-2-7b-chat-hf")
@@ -60,7 +60,7 @@ def vicuna_respond(tab_name, message, chat_history):
60
  print('Prompt + Context:')
61
  print(formatted_prompt)
62
  input_ids = vicuna_tokenizer.encode(formatted_prompt, return_tensors="pt")
63
- output_ids = vicuna_model.generate(input_ids, max_length=149, num_beams=5, no_repeat_ngram_size=2)
64
  bot_message = vicuna_tokenizer.decode(output_ids[0], skip_special_tokens=True)
65
  print(bot_message)
66
 
@@ -73,7 +73,7 @@ def llama_respond(tab_name, message, chat_history):
73
  print('Prompt + Context:')
74
  print(formatted_prompt)
75
  input_ids = llama_tokenizer.encode(formatted_prompt, return_tensors="pt")
76
- output_ids = llama_model.generate(input_ids, max_length=149, num_beams=5, no_repeat_ngram_size=2)
77
  bot_message = llama_tokenizer.decode(output_ids[0], skip_special_tokens=True)
78
  print(bot_message)
79
 
 
5
  import openai
6
 
7
  # Load the Vicuna 7B model and tokenizer
8
+ vicuna_tokenizer = AutoTokenizer.from_pretrained("lmsys/vicuna-7b-v1.3")
9
+ vicuna_model = AutoModelForCausalLM.from_pretrained("lmsys/vicuna-7b-v1.3")
10
 
11
  # Load the LLaMA 7b model and tokenizer
12
  llama_tokenizer = AutoTokenizer.from_pretrained("daryl149/llama-2-7b-chat-hf")
 
60
  print('Prompt + Context:')
61
  print(formatted_prompt)
62
  input_ids = vicuna_tokenizer.encode(formatted_prompt, return_tensors="pt")
63
+ output_ids = vicuna_model.generate(input_ids, do_sample=True, max_length=149, num_beams=5, no_repeat_ngram_size=2)
64
  bot_message = vicuna_tokenizer.decode(output_ids[0], skip_special_tokens=True)
65
  print(bot_message)
66
 
 
73
  print('Prompt + Context:')
74
  print(formatted_prompt)
75
  input_ids = llama_tokenizer.encode(formatted_prompt, return_tensors="pt")
76
+ output_ids = llama_model.generate(input_ids, do_sample=True, max_length=149, num_beams=5, no_repeat_ngram_size=2)
77
  bot_message = llama_tokenizer.decode(output_ids[0], skip_special_tokens=True)
78
  print(bot_message)
79