Tonic commited on
Commit
bc3a87b
·
1 Parent(s): 883a791

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -14,7 +14,7 @@ os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'max_split_size_mb:50'
14
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
15
  model_name = "Salesforce/xgen-7b-8k-base"
16
  tokenizer = XgenTokenizer.from_pretrained("./")
17
- model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")
18
 
19
  class XgenChatBot:
20
  def __init__(self, model, tokenizer, system_message="You are Xgen, an AI language model created by Tonic-AI. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior."):
@@ -47,11 +47,11 @@ class XgenChatBot:
47
  return response
48
 
49
  def gradio_predict(user_message, system_message, max_new_tokens, temperature, top_p, repetition_penalty):
50
- Orca_bot.set_system_message(system_message)
51
- response = Orca_bot.predict(user_message, temperature, max_new_tokens, top_p, repetition_penalty)
52
  return response
53
 
54
- Orca_bot = OrcaChatBot(model, tokenizer)
55
 
56
  iface = gr.Interface(
57
  fn=gradio_predict,
 
14
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
15
  model_name = "Salesforce/xgen-7b-8k-base"
16
  tokenizer = XgenTokenizer.from_pretrained("./")
17
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, use_flash_attention_2=True, device_map="auto", device_map="auto")
18
 
19
  class XgenChatBot:
20
  def __init__(self, model, tokenizer, system_message="You are Xgen, an AI language model created by Tonic-AI. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior."):
 
47
  return response
48
 
49
  def gradio_predict(user_message, system_message, max_new_tokens, temperature, top_p, repetition_penalty):
50
+ Xgen_bot.set_system_message(system_message)
51
+ response = Xgen_bot.predict(user_message, temperature, max_new_tokens, top_p, repetition_penalty)
52
  return response
53
 
54
+ Xgen_bot = XgenChatBot(model, tokenizer)
55
 
56
  iface = gr.Interface(
57
  fn=gradio_predict,