File size: 1,864 Bytes
5028de7 d42693d 106dfc2 5028de7 d42693d 5028de7 64981e3 5028de7 64981e3 7d4764c 64981e3 5028de7 fe4c8cf 5028de7 64981e3 090d30d 64981e3 |
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 |
---
license: apache-2.0
datasets:
- mrm8488/CHISTES_spanish_jokes
language:
- es
pipeline_tag: text-generation
---
# Adapter for BERTIN-GPT-J-6B fine-tuned on Jokes for jokes generation
## Adapter Description
This adapter was created by using the [PEFT](https://github.com/huggingface/peft) library and allows the base model **BERTIN-GPT-J-6B** to be fine-tuned on the dataset **mrm8488/CHISTES_spanish_jokes** for **Spanish jokes generation** by using the method **LoRA**.
## Model Description
[BERTIN-GPT-J-6B](https://huggingface.co/bertin-project/bertin-gpt-j-6B) is a Spanish finetuned version of GPT-J 6B, a transformer model trained using Ben Wang's Mesh Transformer JAX. "GPT-J" refers to the class of model, while "6B" represents the number of trainable parameters.
## Training data
Dataset from [Workshop for NLP introduction with Spanish jokes](https://github.com/liopic/chistes-nlp)
[More Information needed](https://github.com/huggingface/datasets/blob/main/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
### Training procedure
TBA
## How to use
```py
import torch
from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM, AutoTokenizer
peft_model_id = "mrm8488/bertin-gpt-j-6B-es-finetuned-chistes_spanish_jokes-500"
config = PeftConfig.from_pretrained(peft_model_id)
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, return_dict=True, load_in_8bit=True, device_map='auto')
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
# Load the Lora model
model = PeftModel.from_pretrained(model, peft_model_id)
# Inference
batch = tokenizer("Esto son dos amigos", return_tensors='pt')
with torch.cuda.amp.autocast():
output_tokens = model.generate(**batch, max_new_tokens=50)
print('\n\n', tokenizer.decode(output_tokens[0], skip_special_tokens=True))
``` |