Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
model = AutoModelForCausalLM.from_pretrained("cris177/Qwen2-Simple-Arguments")
|
| 5 |
+
tokenizer = AutoTokenizer.from_pretrained("cris177/Qwen2-Simple-Arguments")
|
| 6 |
+
|
| 7 |
+
argument = "If it's wednesday it's cold, and it's cold, therefore it's wednesday."
|
| 8 |
+
def analyze_argument(argument):
|
| 9 |
+
instruction = 'Based on the following argument, identify the following elements: premises, conclusion, propositions, type of argument, negation of propositions and validity.'
|
| 10 |
+
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
| 11 |
+
|
| 12 |
+
### Instruction:
|
| 13 |
+
{}
|
| 14 |
+
|
| 15 |
+
### Input:
|
| 16 |
+
{}
|
| 17 |
+
|
| 18 |
+
### Response:"""
|
| 19 |
+
prompt = alpaca_prompt.format(instruction, argument)
|
| 20 |
+
input_ids = tokenizer(prompt, return_tensors="pt")
|
| 21 |
+
|
| 22 |
+
outputs = model.generate(**input_ids, max_length=1000, num_return_sequences=1)
|
| 23 |
+
return tokenizer.decode(outputs[0])
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
gr.Interface(analyze_argument, inputs="text", outputs="text").launch()
|