Model Card for Model ID

This modelcard aims to be a base template for new models. It has been generated using this raw template.

Model Details

Model Description

  • Developed by: [More Information Needed]
  • Funded by [optional]: [More Information Needed]
  • Shared by [optional]: [More Information Needed]
  • Model type: [More Information Needed]
  • Language(s) (NLP): [More Information Needed]
  • License: [More Information Needed]
  • Finetuned from model [optional]: [More Information Needed]

Model Sources [optional]

  • Repository: [More Information Needed]
  • Paper [optional]: [More Information Needed]
  • Demo [optional]: [More Information Needed]

Uses

!pip install transformers datasets

from IPython.display import HTML

def display_df(df, max_cols=15, header=True, index=True): return display(HTML(df.to_html(header=header,index=index, max_cols=max_cols)))

import torch from transformers import AutoTokenizer, AutoModelForCausalLM

device = "cuda" if torch.cuda.is_available() else "cpu" model_name = "DjSteker/spanish-gpt2" tokenizer = AutoTokenizer.from_pretrained(model_name)

Añadimos el token EOS como token PAD para evitar warnings

model = AutoModelForCausalLM.from_pretrained(model_name, pad_token_id=tokenizer.eos_token_id).to(device)

print(str(device))

def model_size(model): return sum(t.numel() for t in model.parameters())

print(f"Tamaño del GPT español: {model_size(model)/1000**2:.1f}M parámetros")

import pandas as pd

Aqui es el "prompt" para continuar

input_txt =" Le tiro una piedra a la cabeza" # "El amor es eterno mientras dura. "

input_ids = tokenizer(input_txt, return_tensors="pt")["input_ids"].to(device) iterations = [] n_steps = 12 choices_per_step = 5

with torch.no_grad(): for _ in range(n_steps): iteration = dict() iteration["Input"] = tokenizer.decode(input_ids[0]) output = model(input_ids=input_ids) # Seleccionar los logits del primer batch y del último token y aplicar softmax next_token_logits = output.logits[0, -1, :] next_token_probs = torch.softmax(next_token_logits, dim=-1) sorted_ids = torch.argsort(next_token_probs, dim=-1, descending=True) # Almacenar las tokens con mayores probabilidades for choice_idx in range(choices_per_step): token_id = sorted_ids[choice_idx] token_prob = next_token_probs[token_id].cpu().numpy() token_choice = ( f"{tokenizer.decode(token_id)} ({100 * token_prob:.2f}%)" ) iteration[f"Choice {choice_idx+1}"] = token_choice # Añadir el siguiente token previsto a los inputs input_ids = torch.cat([input_ids, sorted_ids[None, 0, None]], dim=-1) iterations.append(iteration)

display_df(pd.DataFrame.from_records(iterations), index=None)

input_ids = tokenizer(input_txt, return_tensors="pt")["input_ids"].to(device) output = model.generate(input_ids, max_length=20) print(tokenizer.decode(output[0]))

max_length = 256 input_txt ="""En un hallazgo sorprendente, los científicos descubrieron una manada de unicornios en la Luna
que vivía en un valle remoto, hasta ahora inexplorado, en la cordillera de Mons Agnes.
Más sorprendente aún para los investigadores fue el hecho de que los unicornios hablaban
un inglés perfecto. """ input_ids = tokenizer(input_txt, return_tensors="pt")["input_ids"].to(device) output_greedy = model.generate(input_ids, max_length=max_length, do_sample=False) print(tokenizer.decode(output_greedy[0]))

torch.manual_seed(42) output_temp = model.generate(input_ids, max_length=max_length, do_sample=True, temperature=2.0, top_k=0) print(tokenizer.decode(output_temp[0]))

Direct Use

[More Information Needed]

Downstream Use [optional]

[More Information Needed]

Out-of-Scope Use

[More Information Needed]

Bias, Risks, and Limitations

[More Information Needed]

Recommendations

Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.

How to Get Started with the Model

Use the code below to get started with the model.

[More Information Needed]

Training Details

Training Data

[More Information Needed]

Training Procedure

Preprocessing [optional]

[More Information Needed]

Training Hyperparameters

  • Training regime: [More Information Needed]

Speeds, Sizes, Times [optional]

[More Information Needed]

Evaluation

Testing Data, Factors & Metrics

Testing Data

[More Information Needed]

Factors

[More Information Needed]

Metrics

[More Information Needed]

Results

[More Information Needed]

Summary

Model Examination [optional]

[More Information Needed]

Environmental Impact

Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).

  • Hardware Type: [More Information Needed]
  • Hours used: [More Information Needed]
  • Cloud Provider: [More Information Needed]
  • Compute Region: [More Information Needed]
  • Carbon Emitted: [More Information Needed]

Technical Specifications [optional]

Model Architecture and Objective

[More Information Needed]

Compute Infrastructure

[More Information Needed]

Hardware

[More Information Needed]

Software

[More Information Needed]

Citation [optional]

BibTeX:

[More Information Needed]

APA:

[More Information Needed]

Glossary [optional]

[More Information Needed]

More Information [optional]

[More Information Needed]

Model Card Authors [optional]

[More Information Needed]

Model Card Contact

[More Information Needed]

Downloads last month
2
Safetensors
Model size
0.1B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Paper for DjSteker/spanish-gpt2