Spaces:
Runtime error
Runtime error
simple test app
Browse files- README.md +1 -1
- app.py +16 -0
- requirements.txt +1 -0
README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
title: Code Clippy Problem Solver
|
3 |
emoji: 💻
|
4 |
colorFrom: blue
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
app_file: app.py
|
8 |
pinned: false
|
|
|
2 |
title: Code Clippy Problem Solver
|
3 |
emoji: 💻
|
4 |
colorFrom: blue
|
5 |
+
colorTo: green
|
6 |
sdk: gradio
|
7 |
app_file: app.py
|
8 |
pinned: false
|
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
+
|
4 |
+
model_name = "EleutherAI/gpt-neo-125M"
|
5 |
+
# define model and tokenizer
|
6 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
+
tokenizer.pad_token = tokenizer.eos_token
|
9 |
+
|
10 |
+
def generate_solution(prompt, **kwargs):
|
11 |
+
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
|
12 |
+
start = len(input_ids)
|
13 |
+
output = model.generate(input_ids, pad_token_id=tokenizer.pad_token_id, *kwargs)
|
14 |
+
return tokenizer.decode(output[0][start:])
|
15 |
+
|
16 |
+
gr.Interface(generate_solution, inputs="text", outputs="text").launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
transformers
|