link to model ?
Browse files
app.py
CHANGED
@@ -1,7 +1,18 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
#from transformers import pipeline
|
3 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
4 |
|
5 |
+
#model = AutoModel.from_pretrained("kolbeins/model")
|
6 |
+
#pipeline = pipeline(task="text-generation", model="kolbeins/model")
|
7 |
+
model = AutoModelForCausalLM.from_pretrained("kolbeins/model")
|
8 |
+
tokenizer = AutoTokenizer.from_pretrained("kolbeins/model")
|
9 |
|
10 |
+
def chat(input_txt):
|
11 |
+
# response = pipeline(input_txt)
|
12 |
+
inputs = tokenizer(input_txt, return_tensors="pt")
|
13 |
+
outputs = model.generate(inputs["input_ids"], max_length=150, num_return_sequences=1)
|
14 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
15 |
+
return response
|
16 |
+
|
17 |
+
demo = gr.Interface(fn=chat, inputs="text", outputs="text")
|
18 |
+
demo.launch(share=True)
|