miqueldev commited on
Commit
9dfb17b
1 Parent(s): a4869ab

cambiar a español

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -5,14 +5,18 @@ import torch.nn.functional as F
5
  import pandas as pd
6
  from transformers import AutoTokenizer, AutoModelForCausalLM
7
 
8
- tokenizer = AutoTokenizer.from_pretrained('gpt2')
9
- model = AutoModelForCausalLM.from_pretrained('gpt2')
10
- text1 = solara.reactive("Never gonna give you up, never gonna let you")
 
 
 
 
11
  @solara.component
12
  def Page():
13
  with solara.Column(margin=10):
14
- solara.Markdown("#Next token prediction visualization")
15
- solara.Markdown("I built this tool to help me understand autoregressive language models. For any given text, it gives the top 10 candidates to be the next token with their respective probabilities. The language model I'm using is the smallest version of GPT-2, with 124M parameters.")
16
  def on_action_cell(column, row_index):
17
  text1.value += tokenizer.decode(top_10.indices[0][row_index])
18
  cell_actions = [solara.CellAction(icon="mdi-thumb-up", name="Select", on_click=on_action_cell)]
 
5
  import pandas as pd
6
  from transformers import AutoTokenizer, AutoModelForCausalLM
7
 
8
+ # Cargar el tokenizer y el modelo preentrenado en español
9
+ tokenizer = AutoTokenizer.from_pretrained("datificate/gpt2-small-spanish")
10
+ model = AutoModelForCausalLM.from_pretrained("datificate/gpt2-small-spanish")
11
+
12
+ # tokenizer = AutoTokenizer.from_pretrained('gpt2')
13
+ # model = AutoModelForCausalLM.from_pretrained('gpt2')
14
+ text1 = solara.reactive("Hola, ¿cómo estás")
15
  @solara.component
16
  def Page():
17
  with solara.Column(margin=10):
18
+ solara.Markdown("#Siguiente token prediction ")
19
+ solara.Markdown("Hemos creado esta herramienta para entender el funcionamiento de los modelos de lenguage autoregresivos... ")
20
  def on_action_cell(column, row_index):
21
  text1.value += tokenizer.decode(top_10.indices[0][row_index])
22
  cell_actions = [solara.CellAction(icon="mdi-thumb-up", name="Select", on_click=on_action_cell)]