Update app.py
Browse files
app.py
CHANGED
|
@@ -6,16 +6,16 @@ import torch
|
|
| 6 |
import gradio as gr
|
| 7 |
import sentencepiece
|
| 8 |
|
| 9 |
-
title = "Welcome to Tonic's
|
| 10 |
-
description = "You can use [
|
| 11 |
|
| 12 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
| 13 |
-
model_name = "
|
| 14 |
tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=False)
|
| 15 |
-
model =
|
| 16 |
|
| 17 |
-
class
|
| 18 |
-
def __init__(self, model, tokenizer, system_message="You are
|
| 19 |
self.model = model
|
| 20 |
self.tokenizer = tokenizer
|
| 21 |
self.system_message = system_message
|
|
|
|
| 6 |
import gradio as gr
|
| 7 |
import sentencepiece
|
| 8 |
|
| 9 |
+
title = "Welcome to 🙋🏻♂️Tonic's😈Xgen-8K Chat!"
|
| 10 |
+
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!."
|
| 11 |
|
| 12 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
| 13 |
+
model_name = "Salesforce/xgen-7b-8k-base"
|
| 14 |
tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=False)
|
| 15 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, dtype=torch.bfloat16, device_map="auto")
|
| 16 |
|
| 17 |
+
class XgenChatBot:
|
| 18 |
+
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."):
|
| 19 |
self.model = model
|
| 20 |
self.tokenizer = tokenizer
|
| 21 |
self.system_message = system_message
|