Update README.md
Browse files
README.md
CHANGED
@@ -21,7 +21,7 @@ The prompt has the following structure:
|
|
21 |
Determine if the student's answer is correct or not. It only returns True if the student's answer is correct with respect to the expected answer or False otherwise.
|
22 |
Add a brief comment explaining why the answer is correct or incorrect.\n\n
|
23 |
Question: {question}\n
|
24 |
-
|
25 |
Student Answer: {student_answer}<end_of_turn><start_of_turn>model"
|
26 |
```
|
27 |
|
@@ -34,11 +34,11 @@ In Google Colab:
|
|
34 |
!pip install -q -U git+https://github.com/huggingface/transformers.git
|
35 |
!pip install -q -U git+https://github.com/huggingface/peft.git
|
36 |
!pip install -q -U git+https://github.com/huggingface/accelerate.git
|
|
|
37 |
|
38 |
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, GemmaTokenizer
|
39 |
from peft import AutoPeftModelForCausalLM
|
40 |
import torch
|
41 |
-
import re
|
42 |
|
43 |
# Carga el modelo y el tokenizer
|
44 |
model_id = "google/gemma-7b-it"
|
@@ -60,7 +60,7 @@ def predict(question, best_answer, student_answer, language):
|
|
60 |
else: # Asumimos que cualquier otra opción será Español
|
61 |
system_message = "Analiza la pregunta, la respuesta esperada y la respuesta del estudiante. Determina si la respuesta del estudiante es conceptualmente correcta en relación con la respuesta esperada, independientemente de la redacción exacta. Devuelve Verdadero si la respuesta del estudiante es correcta o Falso en caso contrario. Añade un breve comentario explicando el razonamiento detrás de la corrección o incorrección de la respuesta."
|
62 |
|
63 |
-
prompt = f"{system_message}\n\nQuestion: {question}\
|
64 |
prompt_template=f"<start_of_turn>user{prompt}<end_of_turn><start_of_turn>model"
|
65 |
|
66 |
# Ajusta aquí para incluir attention_mask
|
@@ -75,7 +75,19 @@ def predict(question, best_answer, student_answer, language):
|
|
75 |
|
76 |
return response
|
77 |
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
```
|
81 |
|
|
|
21 |
Determine if the student's answer is correct or not. It only returns True if the student's answer is correct with respect to the expected answer or False otherwise.
|
22 |
Add a brief comment explaining why the answer is correct or incorrect.\n\n
|
23 |
Question: {question}\n
|
24 |
+
Expected Answer: {best_answer}\n
|
25 |
Student Answer: {student_answer}<end_of_turn><start_of_turn>model"
|
26 |
```
|
27 |
|
|
|
34 |
!pip install -q -U git+https://github.com/huggingface/transformers.git
|
35 |
!pip install -q -U git+https://github.com/huggingface/peft.git
|
36 |
!pip install -q -U git+https://github.com/huggingface/accelerate.git
|
37 |
+
!pip install -q -U gradio
|
38 |
|
39 |
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, GemmaTokenizer
|
40 |
from peft import AutoPeftModelForCausalLM
|
41 |
import torch
|
|
|
42 |
|
43 |
# Carga el modelo y el tokenizer
|
44 |
model_id = "google/gemma-7b-it"
|
|
|
60 |
else: # Asumimos que cualquier otra opción será Español
|
61 |
system_message = "Analiza la pregunta, la respuesta esperada y la respuesta del estudiante. Determina si la respuesta del estudiante es conceptualmente correcta en relación con la respuesta esperada, independientemente de la redacción exacta. Devuelve Verdadero si la respuesta del estudiante es correcta o Falso en caso contrario. Añade un breve comentario explicando el razonamiento detrás de la corrección o incorrección de la respuesta."
|
62 |
|
63 |
+
prompt = f"{system_message}\n\nQuestion: {question}\nExpected Answer: {best_answer}\nStudent Answer: {student_answer}"
|
64 |
prompt_template=f"<start_of_turn>user{prompt}<end_of_turn><start_of_turn>model"
|
65 |
|
66 |
# Ajusta aquí para incluir attention_mask
|
|
|
75 |
|
76 |
return response
|
77 |
|
78 |
+
import gradio as gr
|
79 |
+
|
80 |
+
iface = gr.Interface(
|
81 |
+
fn=predict,
|
82 |
+
inputs=[
|
83 |
+
gr.Textbox(lines=2, placeholder="Pregunta"),
|
84 |
+
gr.Textbox(lines=2, placeholder="Mejor Respuesta"),
|
85 |
+
gr.Textbox(lines=2, placeholder="Respuesta del Estudiante"),
|
86 |
+
gr.Radio(choices=["English", "Español"], label="Idioma")
|
87 |
+
],
|
88 |
+
outputs=gr.Textbox(label="Respuesta del Modelo")
|
89 |
+
)
|
90 |
+
iface.launch(share=True,debug=True)
|
91 |
|
92 |
```
|
93 |
|