JoPmt commited on
Commit
452b214
·
verified ·
1 Parent(s): 1ca0f5f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -1,15 +1,14 @@
1
  from accelerate import Accelerator
2
- from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
3
  import gradio as gr
4
  import os, random, gc
5
  import torch
6
  accelerator=Accelerator(cpu=True)
7
- mdl = "bigcode/starcoder2-3b"
8
- tokenizer = AutoTokenizer.from_pretrained(mdl)
9
- model = accelerator.prepare(AutoModelForCausalLM.from_pretrained(mdl, torch_dtype=torch.bfloat16))
10
  def plex(ynputs):
11
  onputs = tokenizer.encode(""+ynputs+"", return_tensors="pt").to("cpu")
12
- iutputs = model.generate(onputs, max_new_tokens=350)
13
  return tokenizer.decode(iutputs[0])
14
  with gr.Blocks() as iface:
15
  zutput=gr.Textbox(lines=5)
 
1
  from accelerate import Accelerator
2
+ from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
3
  import gradio as gr
4
  import os, random, gc
5
  import torch
6
  accelerator=Accelerator(cpu=True)
7
+ tokenizer = AutoTokenizer.from_pretrained("bigcode/starcoder2-3b")
8
+ pipe = accelerator.prepare(AutoModelForCausalLM.from_pretrained("bigcode/starcoder2-3b", torch_dtype=torch.bfloat16))
 
9
  def plex(ynputs):
10
  onputs = tokenizer.encode(""+ynputs+"", return_tensors="pt").to("cpu")
11
+ iutputs = pipe.generate(onputs, max_new_tokens=350)
12
  return tokenizer.decode(iutputs[0])
13
  with gr.Blocks() as iface:
14
  zutput=gr.Textbox(lines=5)