Spaces:
Runtime error
Runtime error
mikemin027
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
2 |
+
|
3 |
+
checkpoint_name="ArmelR/starcoder-gradio-v0"
|
4 |
+
model = AutoModelForCausalLM.from_pretrained(checkpoint_name)
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint_name)
|
6 |
+
|
7 |
+
prompt = "Create a gradio application that help to convert temperature in celcius into temperature in Fahrenheit"
|
8 |
+
inputs = tokenizer(f"Question: {prompt}\n\nAnswer: ", return_tensors="pt")
|
9 |
+
|
10 |
+
outputs = model.generate(
|
11 |
+
inputs["input_ids"],
|
12 |
+
temperature=0.2,
|
13 |
+
top_p=0.95,
|
14 |
+
max_new_tokens=200
|
15 |
+
)
|
16 |
+
|
17 |
+
input_len=len(inputs["input_ids"])
|
18 |
+
print(tokenizer.decode(outputs[0][input_len:]))
|