abrakjamson commited on
Commit
a7d5317
·
1 Parent(s): d8d631a

more updates

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -23,7 +23,7 @@ tokenizer = AutoTokenizer.from_pretrained(mistral_path)
23
  tokenizer.pad_token_id = 0
24
 
25
  global model
26
-
27
 
28
  global isModelDefined
29
  isModelDefined = False
@@ -31,6 +31,7 @@ isModelDefined = False
31
  def defineModel():
32
  global model
33
  global isModelDefined
 
34
  cuda = torch.cuda.is_available()
35
  if not isModelDefined:
36
  model = AutoModelForCausalLM.from_pretrained(
@@ -164,6 +165,7 @@ def generate_response(system_prompt, user_message, history, max_new_tokens, repi
164
  }
165
 
166
  timeout = 120.0
 
167
  if cuda:
168
  timeout = 15.0
169
  _streamer = TextIteratorStreamer(tokenizer, timeout=timeout, skip_prompt=True, skip_special_tokens=False,)
@@ -488,10 +490,8 @@ with gr.Blocks(
488
  label="Use"
489
  ):
490
  # Header
491
- if cuda:
492
- gr.Markdown("# 🧠 LLM Mind Control")
493
- else:
494
- gr.Markdown("""# 🧠 LLM Mind Control
495
 
496
  *Warning: this space won't work well on CPU. Use the [Llama 1B version](https://huggingface.co/spaces/Abrak/Controlled_Chat_CPU) instead, or duplicate this space onto GPU hardware.""")
497
  gr.Markdown("""Unlike prompting, direct weight manipulation lets you fine-tune the amount of a personality
 
23
  tokenizer.pad_token_id = 0
24
 
25
  global model
26
+ global cuda
27
 
28
  global isModelDefined
29
  isModelDefined = False
 
31
  def defineModel():
32
  global model
33
  global isModelDefined
34
+ global cuda
35
  cuda = torch.cuda.is_available()
36
  if not isModelDefined:
37
  model = AutoModelForCausalLM.from_pretrained(
 
165
  }
166
 
167
  timeout = 120.0
168
+ global cuda
169
  if cuda:
170
  timeout = 15.0
171
  _streamer = TextIteratorStreamer(tokenizer, timeout=timeout, skip_prompt=True, skip_special_tokens=False,)
 
490
  label="Use"
491
  ):
492
  # Header
493
+
494
+ gr.Markdown("""# 🧠 LLM Mind Control
 
 
495
 
496
  *Warning: this space won't work well on CPU. Use the [Llama 1B version](https://huggingface.co/spaces/Abrak/Controlled_Chat_CPU) instead, or duplicate this space onto GPU hardware.""")
497
  gr.Markdown("""Unlike prompting, direct weight manipulation lets you fine-tune the amount of a personality