research14 commited on
Commit
a2797f8
·
1 Parent(s): 971271a

redo vicuna prompt and change model

Browse files
Files changed (1) hide show
  1. app.py +6 -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.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,8 +60,10 @@ def vicuna_respond(tab_name, message, chat_history):
60
  print('Vicuna - 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
 
67
  chat_history.append((formatted_prompt, bot_message))
@@ -73,7 +75,7 @@ def llama_respond(tab_name, message, chat_history):
73
  print('Llama - 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
  # Remove formatted prompt from bot_message
79
  bot_message = bot_message.replace(formatted_prompt, '')
 
5
  import openai
6
 
7
  # Load the Vicuna 7B model and tokenizer
8
+ vicuna_tokenizer = AutoTokenizer.from_pretrained("lmsys/vicuna-7b-v1.5-16k")
9
+ vicuna_model = AutoModelForCausalLM.from_pretrained("lmsys/vicuna-7b-v1.5-16k")
10
 
11
  # Load the LLaMA 7b model and tokenizer
12
  llama_tokenizer = AutoTokenizer.from_pretrained("daryl149/llama-2-7b-chat-hf")
 
60
  print('Vicuna - 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=1024, num_beams=5, no_repeat_ngram_size=2)
64
  bot_message = vicuna_tokenizer.decode(output_ids[0], skip_special_tokens=True)
65
+ # Remove formatted prompt from bot_message
66
+ bot_message = bot_message.replace(formatted_prompt, '')
67
  print(bot_message)
68
 
69
  chat_history.append((formatted_prompt, bot_message))
 
75
  print('Llama - Prompt + Context:')
76
  print(formatted_prompt)
77
  input_ids = llama_tokenizer.encode(formatted_prompt, return_tensors="pt")
78
+ output_ids = llama_model.generate(input_ids, do_sample=True, max_length=1024, num_beams=5, no_repeat_ngram_size=2)
79
  bot_message = llama_tokenizer.decode(output_ids[0], skip_special_tokens=True)
80
  # Remove formatted prompt from bot_message
81
  bot_message = bot_message.replace(formatted_prompt, '')