cnmoro commited on
Commit
9185f46
·
verified ·
1 Parent(s): fab7ce1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -4,6 +4,8 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
4
  from transformers import StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer
5
  from threading import Thread
6
 
 
 
7
  # Loading the tokenizer and model from Hugging Face's model hub.
8
  tokenizer = AutoTokenizer.from_pretrained("cnmoro/jack-68m-text-structurization")
9
  model = AutoModelForCausalLM.from_pretrained("cnmoro/jack-68m-text-structurization")
@@ -36,7 +38,8 @@ def predict(message, history):
36
  t.start() # Starting the generation in a separate thread.
37
  partial_message = ""
38
  for new_token in streamer:
39
- yield new_token
 
40
 
41
  # Setting up the Gradio chat interface.
42
  gr.ChatInterface(predict,
 
4
  from transformers import StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer
5
  from threading import Thread
6
 
7
+ torch.set_num_threads(2)
8
+
9
  # Loading the tokenizer and model from Hugging Face's model hub.
10
  tokenizer = AutoTokenizer.from_pretrained("cnmoro/jack-68m-text-structurization")
11
  model = AutoModelForCausalLM.from_pretrained("cnmoro/jack-68m-text-structurization")
 
38
  t.start() # Starting the generation in a separate thread.
39
  partial_message = ""
40
  for new_token in streamer:
41
+ partial_message += new_token
42
+ yield partial_message
43
 
44
  # Setting up the Gradio chat interface.
45
  gr.ChatInterface(predict,