Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoTokenizer, AutoModelForCausalLM, set_seed, pipeline
|
3 |
|
4 |
-
title = "SantaCoder π
|
5 |
-
description = "This is a subspace to make code generation with [SantaCoder fine-tuned on The Stack
|
6 |
-
EXAMPLE_0 = "
|
7 |
|
8 |
|
9 |
-
CKPT = "mrm8488/santacoder-finetuned-the-stack-
|
10 |
|
11 |
-
examples = [[EXAMPLE_0,
|
12 |
tokenizer = AutoTokenizer.from_pretrained(CKPT)
|
13 |
-
model = AutoModelForCausalLM.from_pretrained(CKPT, trust_remote_code=True)
|
14 |
|
15 |
|
16 |
def code_generation(gen_prompt, max_tokens, temperature=0.6, seed=42):
|
17 |
set_seed(seed)
|
18 |
-
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
19 |
generated_text = pipe(gen_prompt, do_sample=True, top_p=0.95, temperature=temperature, max_new_tokens=max_tokens)[0]['generated_text']
|
20 |
return generated_text
|
21 |
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoTokenizer, AutoModelForCausalLM, set_seed, pipeline
|
3 |
|
4 |
+
title = "SantaCoder π
Swift π Completion"
|
5 |
+
description = "This is a subspace to make code generation with [SantaCoder fine-tuned on The Stack Swift](https://huggingface.co/mrm8488/santacoder-finetuned-the-stack-swift)"
|
6 |
+
EXAMPLE_0 = """// Swift "Hello, World!" Program"""
|
7 |
|
8 |
|
9 |
+
CKPT = "mrm8488/santacoder-finetuned-the-stack-swift"
|
10 |
|
11 |
+
examples = [[EXAMPLE_0, 8, 0.6, 42]]
|
12 |
tokenizer = AutoTokenizer.from_pretrained(CKPT)
|
13 |
+
model = AutoModelForCausalLM.from_pretrained(CKPT, trust_remote_code=True).to("cuda")
|
14 |
|
15 |
|
16 |
def code_generation(gen_prompt, max_tokens, temperature=0.6, seed=42):
|
17 |
set_seed(seed)
|
18 |
+
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, device=0)
|
19 |
generated_text = pipe(gen_prompt, do_sample=True, top_p=0.95, temperature=temperature, max_new_tokens=max_tokens)[0]['generated_text']
|
20 |
return generated_text
|
21 |
|