Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
8 |
-
|
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 =
|
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)
|