Spaces:
Build error
Build error
trying to use zerogpu
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import json
|
|
2 |
import os
|
3 |
import shutil
|
4 |
import requests
|
|
|
5 |
|
6 |
import gradio as gr
|
7 |
from huggingface_hub import Repository
|
@@ -17,14 +18,6 @@ device = "cuda"
|
|
17 |
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
18 |
model = AutoModelForCausalLM.from_pretrained(checkpoint, trust_remote_code=True).to(device)
|
19 |
|
20 |
-
prompt = '<fim_prefix>def print_hello_world():\n """<fim_suffix>\n print("Hello world!")<fim_middle>'
|
21 |
-
|
22 |
-
inputs = tokenizer.encode(prompt, return_tensors="pt").to(device)
|
23 |
-
outputs = model.generate(inputs, max_length=100, temperature=0.2)
|
24 |
-
#print("-"*80)
|
25 |
-
print(tokenizer.decode(outputs[0]))
|
26 |
-
|
27 |
-
|
28 |
FIM_PREFIX = "<fim_prefix>"
|
29 |
FIM_MIDDLE = "<fim_middle>"
|
30 |
FIM_SUFFIX = "<fim_suffix>"
|
@@ -46,7 +39,7 @@ theme = gr.themes.Monochrome(
|
|
46 |
|
47 |
inputs = tokenizer.encode(prompt, return_tensors="pt").to(device)
|
48 |
outputs = model.generate(inputs, max_length=100, temperature=0.2)
|
49 |
-
|
50 |
def generate(
|
51 |
prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0, version="StarCoder",
|
52 |
):
|
|
|
2 |
import os
|
3 |
import shutil
|
4 |
import requests
|
5 |
+
import spaces
|
6 |
|
7 |
import gradio as gr
|
8 |
from huggingface_hub import Repository
|
|
|
18 |
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
19 |
model = AutoModelForCausalLM.from_pretrained(checkpoint, trust_remote_code=True).to(device)
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
FIM_PREFIX = "<fim_prefix>"
|
22 |
FIM_MIDDLE = "<fim_middle>"
|
23 |
FIM_SUFFIX = "<fim_suffix>"
|
|
|
39 |
|
40 |
inputs = tokenizer.encode(prompt, return_tensors="pt").to(device)
|
41 |
outputs = model.generate(inputs, max_length=100, temperature=0.2)
|
42 |
+
@spaces.GPU
|
43 |
def generate(
|
44 |
prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0, version="StarCoder",
|
45 |
):
|