readme: ---
  language:
  
  - es
  
  license: apache-2.0
  
  tags:
  
  - "national library of spain"
  
  - "spanish"
  
  - "bne"
  
  - "gpt2-base-bne"
  
  datasets:
  
  - "bne"
  
  widget:
  - text: "El modelo del lenguaje GPT es capaz de"
  - text: "La Biblioteca Nacional de España es una entidad pública y sus fines son"
  
  ---
  
  # GPT2-base (gpt2-base-bne) trained with data from the National Library of Spain (BNE)
  
  ## Table of Contents
  <details>
  <summary>Click to expand</summary>
  
  - [Overview](#overview)
  - [Model description](#model-description)
  - [Intended uses and limitations](#intended-uses-and-limitations)
  - [How to Use](#how-to-use)
  - [Limitations and bias](#limitations-and-bias)
  - [Training](#training)
    - [Training data](#training-data)
    - [Training procedure](#training-procedure)
  - [Additional information](#additional-information)
    - [Author](#author)
    - [Contact information](#contact-information)
    - [Copyright](#copyright)
    - [Licensing information](#licensing-information)
    - [Funding](#funding)
    - [Citation Information](#citation-information)
    - [Disclaimer](#disclaimer)
  
  </details>
  
  ## Overview
  
  - **Architecture:** gpt2-base
  - **Language:** Spanish
  - **Task:** text-generation
  - **Data:** BNE
  
  ## Model description
  
  **GPT2-base-bne** is a transformer-based model for the Spanish language. It is based on the [GPT-2](https://d4mucfpksywv.cloudfront.net/better-language-models/language_models_are_unsupervised_multitask_learners.pdf) model and has been pre-trained using the largest Spanish corpus known to date, with a total of 570GB of clean and deduplicated text processed for this work, compiled from the web crawlings performed by the  [National Library of Spain (Biblioteca Nacional de España)](http://www.bne.es/en/Inicio/index.html) from 2009 to 2019.
  
  
  ## Intended uses and limitations
  You can use the raw model for text generation or fine-tune it to a downstream task.
  
  ## How to Use
  Here is how to use this model:
  
  You can use this model directly with a pipeline for text generation. Since the generation relies on some randomness, we set a seed for reproducibility:
  
  ```python
  >>> from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline, set_seed
  >>> tokenizer = AutoTokenizer.from_pretrained("PlanTL-GOB-ES/gpt2-base-bne")
  >>> model = AutoModelForCausalLM.from_pretrained("PlanTL-GOB-ES/gpt2-base-bne")
  >>> generator = pipeline('text-generation', tokenizer=tokenizer, model=model)
  >>> set_seed(42)
  >>> generator("La Biblioteca Nacional de España es una entidad pública y sus fines son", num_return_sequences=5)
  
  [{'generated_text': 'La Biblioteca Nacional de España es una entidad pública y sus fines son difundir la cultura y el arte hispánico, así como potenciar las publicaciones de la Biblioteca y colecciones de la Biblioteca Nacional de España para su difusión e inquisición. '}, 
  {'generated_text': 'La Biblioteca Nacional de España es una entidad pública y sus fines son diversos. '}, 
  {'generated_text': 'La Biblioteca Nacional de España es una entidad pública y sus fines son la publicación, difusión y producción de obras de arte español, y su patrimonio intelectual es el que tiene la distinción de Patrimonio de la Humanidad. '}, 
  {'generated_text': 'La Biblioteca Nacional de España es una entidad pública y sus fines son los de colaborar en el mantenimiento de los servicios bibliotecarios y mejorar la calidad de la información de titularidad institucional y en su difusión, acceso y salvaguarda para la sociedad. '}, 
  {'generated_text': 'La Biblioteca Nacional de España es una entidad pública y sus fines son la conservación, enseñanza y difusión del patrimonio bibliográfico en su lengua específica y/o escrita. '}]
  ```
  
  Here is how to use this model to get the features of a given text in PyTorch:
  
  ```python
  >>> from transformers import AutoTokenizer, GPT2Model
  >>> tokenizer = AutoTokenizer.from_pretrained("PlanTL-GOB-ES/gpt2-base-bne")
  >>> model = GPT2Model.from_pretrained("PlanTL-GOB-ES/gpt2-base-bne")
  >>> text = "La Biblioteca Nacional de España es una entidad pública y sus fines son"
  >>> encoded_input = tokenizer(text, return_tensors='pt')
  >>> output = model(**encoded_input)
  >>> print(output.last_hidden_state.shape)
  torch.Size([1, 14, 768])
  ```
  
  ## Limitations and bias
  
  At the time of submission, no measures have been taken to estimate the bias and toxicity embedded in the model. However, we are well aware that our models may be biased since the corpora have been collected using crawling techniques on multiple web sources. We intend to conduct research in these areas in the future, and if completed, this model card will be updated. Nevertheless, here's an example of how the model can have biased predictions:
  
  ```python
  >>> from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline, set_seed
  >>> tokenizer = AutoTokenizer.from_pretrained("PlanTL-GOB-ES/gpt2-base-bne")
  >>> model = AutoModelForCausalLM.from_pretrained("PlanTL-GOB-ES/gpt2-base-bne")
  >>> generator = pipeline('text-generation', tokenizer=tokenizer, model=model)
  