Edit model card

Model Details

Model Description

ULT5-pt is a T5-v1.1 architecture model trained using the UL2 - Unifying Language Learning Paradigms framework, which uses Mixture-of-Denoisers (MoD), combining Causal Language Modeling (CLM) objective with Span Corruption.

ULT5-pt é um modelo de arquitetura T5-v1.1/google-ul2 treinado com o framework UL2 - Unifying Language Learning Paradigms, que utiliza Mixture-of-Denoisers (MoD), o qual combina o objetivo de Causal Language Modeling (CLM) com Span Corruption.

Model type Vocabulary Parameters Context length
ult5-pt-small encoder-decoder 65k 82.4M 1024
sentence-transformer-ult5-pt-small sentence-transformer 65k 51M 1024
DeBERTina-base encoder 32k 100M 512
  • Developed by: Thacio Garcia Scandaroli
  • Model type: T5
  • Language(s) (NLP): Português
  • License: MIT

Benchmarks e tutorial de fine-tune: https://github.com/thacio/LLM-Notebooks

Tutorial fine-tune no colab: Open In Colab

Fine-tunning

Alguns datasets (algumas classificações ou score de similaridade) possuem melhor desempenho com o dropout desligado. Para carregar sem dropout, use o código:

Some datasets (e.g. some classifcation or similarity score) work better without dropout. To load the model without dropout:

from transformers import  AutoModelForSeq2SeqLM

model = AutoModelForSeq2SeqLM.from_pretrained("tgsc/ult5-pt-small",dropout_rate=0.0)

Pretraining and model characteristics

O modelo foi treinado com uma parte do corpus C4 em português utilizando o UL2 (https://huggingface.co/google/ul2), utilizando R-Denoising, S-Denoising e X-Denoising, e com dropout 0.0. De forma diferente do paper original, não se utilizou token específico de prefixo para o S-Denoising. Para o R-Denoising e o X-Denoising, foram utilizados, respectivamente, os tokens <|NLU|> e <|NLG|>.

Utilizou-se uma janela de contexto para 1024 tokens e um tokenizador do GPT2 com vocabulário em português treinado com o wikipedia, aumentando a quantidade de texto que pode ser processada.

The model was trained with a portion of the C4 corpus in Portuguese using UL2 (https://huggingface.co/google/ul2), using R-Denoising, S-Denoising, and X-Denoising, and with dropout rate of 0.0. Unlike the original work of UL2, a prefix token for S-Denoising was not used. For R-Denoising and X-Denoising, the tokens '<|NLU|>' and '<|NLG|>' and were used, respectively.

A context window of 1024 tokens was used. Also, a GPT2 tokenizer with a Portuguese vocabulary trained with Wikipedia was used to increase the amount of text that can be processed.

Uses

O uso recomendado é para fine-tunning.

Foi disponibilizado um tutorial em formato de notebook para fine-tune de modelos decoder e encoder-decoder (T5): [Fine-tune Large Language Models](endereço aqui)

Os modos de span corruption podem ser acionados adicionado ao início do text os prefixos '<|NLU|>' e '<|NLG|>'. Os autores do UL2 apontam uma possivel diferença no resultado do fine-tune dependendo do modo ativado. Porém, para o ult5-pt, não se notou diferença nos testes de benchmark.

Fine-tunning is the recommended use for the model.

A tutorial (in portuguse) in notebook format for decoder and encoder-decoder (T5) model fine-tuning was provided: [Fine-tune Large Language Models](link here).

Span corruption modes can be activated by adding the prefixes '<|NLU|>' and '<|NLG|>' to the beginning of the text. The UL2 authors point out a possible difference in the fine-tuning result depending on the activated mode. However, for ult5-pt, no difference was noticed in benchmark tests.

Special tokens:

  • pad: '<|pad|>'
  • end of text: '<|endoftext|>'
  • R denoising: '<|NLU|>'
  • S denoising: '<|NLG|>'

Direct Use

Exemplo de geração de texto com top_k de 30 Example of text generation with top_k of 30

from transformers import GPT2TokenizerFast, AutoModelForSeq2SeqLM

tokenizer = GPT2TokenizerFast.from_pretrained("tgsc/ult5-pt-small")
model = AutoModelForSeq2SeqLM.from_pretrained("tgsc/ult5-pt-small")

text='Um modelo de linguagem é um sistema de inteligência artificial que'

pred=model.generate(tokenizer.encode(text,return_tensors='pt'),max_new_tokens=30, eos_token_id=tokenizer.eos_token_id, top_k=30, do_sample=True)
print('input:',text)
print('generated:',tokenizer.batch_decode(pred, skip_special_tokens=True))
# input: Um modelo de linguagem é um sistema de inteligência artificial que
# generated: [' geraria a quantidade de informações por clique. Além das capacidades humanas, elas seriam muito mais produtivas do que as do cérebro humano.\nO que']

Embora seja possível obter embeddings com o modelo, melhores embeddings podem ser obtidos com o modelo tgsc/sentence-transformer-ult5-pt-small. Altough you can get embeddings from this model, better embeddings can be obtained with tgsc/sentence-transformer-ult5-pt-small.

Embeddings:

from transformers import T5EncoderModel, GPT2TokenizerFast

tokenizer = GPT2TokenizerFast.from_pretrained("tgsc/ult5-pt-small")
model = T5EncoderModel.from_pretrained("tgsc/ult5-pt-small")

text = 'Um modelo de linguagem é um sistema de inteligência artificial que aprende a gerar ou processar texto baseado em exemplos de treinamento.'
input_ids = tokenizer(text, return_tensors="pt").input_ids
outputs = model(input_ids)
last_hidden_states = outputs.last_hidden_state
print(last_hidden_states)

Bias, Risks, and Limitations

Os mesmos riscos, vieses e limitações dos outros modelos se aplicam a este, como o apontado em GPT2.

The same risks, biases, and limitations of other models apply to this one, as pointed out in GPT2.

Citation

@misc{ult5-pt2023,
  author = {Thacio Garcia Scandaroli},
  title = {ULT5-pt: Portuguese Language Model trained with UL2},
  year = {2023},
}
Downloads last month
12
Safetensors
Model size
82.4M params
Tensor type
F32
·

Dataset used to train tgsc/ult5-pt-small