Tonic commited on
Commit
432f817
1 Parent(s): 0a0db1b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import os
2
  import math
3
  import transformers
4
- from transformers import AutoModelForCausalLM, AutoTokenizer
5
  import torch
6
  import gradio as gr
7
  import sentencepiece
@@ -14,6 +14,7 @@ device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
14
  model_name = "Intel/neural-chat-7b-v3-1"
15
  tokenizer = AutoTokenizer.from_pretrained("Intel/neural-chat-7b-v3-1")
16
  model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
 
17
 
18
  class IntelChatBot:
19
  def __init__(self, model, tokenizer, system_message="You are 🧠🤌🏻Neuro, 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."):
@@ -42,6 +43,7 @@ class IntelChatBot:
42
  temperature=temperature,
43
  top_p=top_p,
44
  repetition_penalty=repetition_penalty,
 
45
  do_sample=do_sample
46
  )
47
 
 
1
  import os
2
  import math
3
  import transformers
4
+ from transformers import AutoModelForCausalLM, AutoTokenizer , TextStreamer
5
  import torch
6
  import gradio as gr
7
  import sentencepiece
 
14
  model_name = "Intel/neural-chat-7b-v3-1"
15
  tokenizer = AutoTokenizer.from_pretrained("Intel/neural-chat-7b-v3-1")
16
  model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
17
+ streamer = TextStreamer(tokenizer)
18
 
19
  class IntelChatBot:
20
  def __init__(self, model, tokenizer, system_message="You are 🧠🤌🏻Neuro, 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."):
 
43
  temperature=temperature,
44
  top_p=top_p,
45
  repetition_penalty=repetition_penalty,
46
+ streamer=streamer,
47
  do_sample=do_sample
48
  )
49