Tonic commited on
Commit
3d2716e
1 Parent(s): fc295cf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -10,10 +10,13 @@ from tokenization_xgen import XgenTokenizer
10
  title = "Welcome to 🙋🏻‍♂️Tonic's😈Xgen-8K Chat!"
11
  description = "Interestingly there simply wasnt a public demo for Xgen, So I made one. You can use [Salesforce/xgen-7b-8k-inst](https://huggingface.co/Salesforce/xgen-7b-8k-inst) via API using Gradio by scrolling down and clicking Use 'Via API' or privately by [cloning this space on huggingface](https://huggingface.co/spaces/Tonic1/Xgen?duplicate=true) . [Join my active builders' server on discord](https://discord.gg/VqTxc76K3u). Let's build together!."
12
 
 
13
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
14
  model_name = "Salesforce/xgen-7b-8k-base"
15
  tokenizer = XgenTokenizer.from_pretrained("./")
16
- model = AutoModelForCausalLM.from_pretrained(model_name, dtype=torch.bfloat16, device_map="auto")
 
 
17
 
18
  class XgenChatBot:
19
  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."):
 
10
  title = "Welcome to 🙋🏻‍♂️Tonic's😈Xgen-8K Chat!"
11
  description = "Interestingly there simply wasnt a public demo for Xgen, So I made one. You can use [Salesforce/xgen-7b-8k-inst](https://huggingface.co/Salesforce/xgen-7b-8k-inst) via API using Gradio by scrolling down and clicking Use 'Via API' or privately by [cloning this space on huggingface](https://huggingface.co/spaces/Tonic1/Xgen?duplicate=true) . [Join my active builders' server on discord](https://discord.gg/VqTxc76K3u). Let's build together!."
12
 
13
+ 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
+ model = model.to(dtype=torch.bfloat16)
19
+ model = model.to(device)
20
 
21
  class XgenChatBot:
22
  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."):