Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,15 +9,16 @@ model = AutoModelForCausalLM.from_pretrained("microsoft/DialoGPT-large")
|
|
| 9 |
|
| 10 |
# Cargar tu conjunto de datos
|
| 11 |
try:
|
| 12 |
-
dataset = load_dataset('csv', data_files='alpaca.csv')
|
| 13 |
print("Conjunto de datos cargado correctamente.")
|
|
|
|
| 14 |
except Exception as e:
|
| 15 |
print(f"Error al cargar el conjunto de datos: {e}")
|
| 16 |
|
| 17 |
# Preprocesar los datos
|
| 18 |
def preprocess_function(examples):
|
| 19 |
-
inputs = [ex for ex in examples
|
| 20 |
-
outputs = [ex for ex in examples
|
| 21 |
model_inputs = tokenizer(inputs, max_length=512, truncation=True)
|
| 22 |
|
| 23 |
# Configurar las etiquetas
|
|
@@ -27,6 +28,7 @@ def preprocess_function(examples):
|
|
| 27 |
model_inputs["labels"] = labels["input_ids"]
|
| 28 |
return model_inputs
|
| 29 |
|
|
|
|
| 30 |
tokenized_dataset = dataset.map(preprocess_function, batched=True)
|
| 31 |
|
| 32 |
# Configurar los argumentos de entrenamiento
|
|
@@ -79,4 +81,3 @@ def chat_with_bot(user_input):
|
|
| 79 |
# Crear la interfaz de Gradio
|
| 80 |
iface = gr.Interface(fn=chat_with_bot, inputs="text", outputs="text", title="Chatbot Entrenado")
|
| 81 |
iface.launch()
|
| 82 |
-
|
|
|
|
| 9 |
|
| 10 |
# Cargar tu conjunto de datos
|
| 11 |
try:
|
| 12 |
+
dataset = load_dataset('csv', data_files='alpaca.csv', delimiter='\t') # Especificar el delimitador como tabulaciΓ³n
|
| 13 |
print("Conjunto de datos cargado correctamente.")
|
| 14 |
+
print("Columnas disponibles:", dataset['train'].column_names) # Imprimir nombres de columnas
|
| 15 |
except Exception as e:
|
| 16 |
print(f"Error al cargar el conjunto de datos: {e}")
|
| 17 |
|
| 18 |
# Preprocesar los datos
|
| 19 |
def preprocess_function(examples):
|
| 20 |
+
inputs = [ex['instruction'] for ex in examples] # Usar solo la columna de instruction
|
| 21 |
+
outputs = [ex['output'] for ex in examples] # Usar solo la columna de output
|
| 22 |
model_inputs = tokenizer(inputs, max_length=512, truncation=True)
|
| 23 |
|
| 24 |
# Configurar las etiquetas
|
|
|
|
| 28 |
model_inputs["labels"] = labels["input_ids"]
|
| 29 |
return model_inputs
|
| 30 |
|
| 31 |
+
# Mapear el conjunto de datos
|
| 32 |
tokenized_dataset = dataset.map(preprocess_function, batched=True)
|
| 33 |
|
| 34 |
# Configurar los argumentos de entrenamiento
|
|
|
|
| 81 |
# Crear la interfaz de Gradio
|
| 82 |
iface = gr.Interface(fn=chat_with_bot, inputs="text", outputs="text", title="Chatbot Entrenado")
|
| 83 |
iface.launch()
|
|
|