Downloads · 30 days
14
15% of all-time downloads
jhonparra18/gpt2-med-sft-chat-spanish
gpt2-med-sft-chat-spanish is a text generation model from jhonparra18. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
GPT2-Medium trained using SFTTrainer using chat templates. Use a conversational dataset (Kukedlc/dpo-orpo-spanish-15k)
Downloads · 30 days
14
15% of all-time downloads
All-time downloads
95
Public
Parameters
355M
710 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors710 MB · 99%
From the Hugging Face model README
GPT2-Medium trained using SFTTrainer using chat templates. Use a conversational dataset (Kukedlc/dpo-orpo-spanish-15k)
Using AutoModel
from transformers import AutoModelForCausalLM, AutoTokenizer,BitsAndBytesConfig
import torch
sys_prompt="Eres un asistente de IA, debes responder amablemente a las preguntas que haga el usuario"
messages=[{'role':'system','content':sys_prompt},{'role':'user','content':'hola quién eres?'}]
base_model="jhonparra18/gpt2-med-sft-chat-spanish"
model = AutoModelForCausalLM.from_pretrained(base_model,torch_dtype=torch.float16,device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(base_model)
#define your generation args
generation_kwargs={
'num_beams':5,
'no_repeat_ngram_size':2,
'do_sample':True,
'early_stopping':True,
'top_p':0.95
}
tokenizer.padding_side="left"
model_inputs=tokenizer.apply_chat_template(messages,tokenize=True,return_tensors="pt",return_dict=True,padding=True)
outputs=model.generate(
**model_inputs,
**generation_kwargs
)
for i, output in enumerate(outputs):
print("{}: {}".format(i, tokenizer.decode(output, skip_special_tokens=True)))
Pipelines
from transformers import pipeline
pipe=pipeline("text-generation",model=base_model,device_map="auto",**generation_kwargs)
outputs=pipe(messages)
print(outputs[0]['generated_text'][-1]['content'])