File size: 6,781 Bytes
ed9deac 5fd39d2 f5ed709 fedb6f2 4d4c18f 368c248 4d4c18f 5e04e4a 2e89e3e ed9deac 56a92e4 f99b5e6 56a92e4 8a51372 9e00862 8a51372 9e00862 8a51372 60e4c42 8a51372 1cc898c f5028da ed9deac 07f1ad6 ed9deac 07f1ad6 ed9deac 07f1ad6 5fd39d2 07f1ad6 ed9deac d05f802 2e89e3e fedb6f2 5fd39d2 fedb6f2 5fd39d2 fedb6f2 5fd39d2 fe56156 d05f802 ed9deac 3b27a9c 5fd39d2 3b27a9c 60e4c42 3b27a9c 7fb1ea3 60e4c42 7fb1ea3 3b27a9c 60e4c42 3b27a9c 1cc898c ed9deac 2e89e3e ed9deac a74e28e 5fd39d2 ed9deac 3b0896d 2e89e3e ed9deac 2e89e3e ed9deac 3b0896d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
---
license: mit
language:
- pt
tags:
- t5
- ul2
- pt
- pt-br
datasets:
- allenai/c4
library_name: transformers
---
## Model Details
### Model Description
<!-- Provide a longer summary of what this model is. -->
*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](https://arxiv.org/abs/2205.05131v1), 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](https://huggingface.co/tgsc/ult5-pt-small) | encoder-decoder | 65k |82.4M | 1024 |
| [sentence-transformer-ult5-pt-small](https://huggingface.co/tgsc/sentence-transformer-ult5-pt-small) | sentence-transformer | 65k | 51M | 1024 |
| [DeBERTina-base](https://huggingface.co/tgsc/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](https://github.com/thacio/LLM-Notebooks)
Tutorial fine-tune no colab: [](https://colab.research.google.com/github/thacio/LLM-Notebooks/blob/main/Finetunning-LanguageModel.ipynb)
## 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:*
```python
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*
```python
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](https://huggingface.co/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](https://huggingface.co/tgsc/sentence-transformer-ult5-pt-small).*
Embeddings:
```python
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](https://huggingface.co/gpt2).
*The same risks, biases, and limitations of other models apply to this one, as pointed out in [GPT2](https://huggingface.co/gpt2).*
## Citation
```bibtex
@misc{ult5-pt2023,
author = {Thacio Garcia Scandaroli},
title = {ULT5-pt: Portuguese Language Model trained with UL2},
year = {2023},
}
``` |