Downloads · 30 days
7
2% of all-time downloads
somosnlp-hackathon-2023/opt-6.7b-lora-sag-t3000-v300-v2
opt-6.7b-lora-sag-t3000-v300-v2 is a text generation model from somosnlp-hackathon-2023. Use it when you need the model to write or continue text. It is set up for adapter-transformers. The card lists the license as apache-2.0.
This adapter was created as part of the SomosNLP Hackathon 2023 with the PEFT library and allowed the base model facebook/opt-6.7b to be fine-tuned on the SQUADES (v1.1.0) and MLSUM by using the method LoRA.
Downloads · 30 days
7
2% of all-time downloads
All-time downloads
402
Public
Repo size
33.6 MB
Likes
3
Public
Click a slice to open those files.
.bin33.6 MB · 100%
From the Hugging Face model README
This adapter was created as part of the SomosNLP Hackathon 2023 with the PEFT library and allowed the base model facebook/opt-6.7b to be fine-tuned on the SQUAD_ES (v1.1.0) and MLSUM by using the method LoRA.
This model is designed for use in Spanish language instruction, specifically for tasks such as generating summaries, creating questions, and generating answers based on a given context and question.
Please note that this model inherits biases from its original base model. You can review these biases by visiting the following link.
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
Use the code below to get started with the model.
import torch
from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
peft_model_id = "hackathon-somos-nlp-2023/opt-6.7b-lora-sag-t3000-v300-v2"
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)
model.config.use_cache = True
generation_config = GenerationConfig(temperature=.8,
top_p=0.75,
top_k=40)
def gen_summary(text):
input_text = f'<s>Instruction: Elabora un resume del siguiente texto.\nInput: {text}\nOutput: '
batch = tokenizer(input_text, return_tensors='pt')
with torch.cuda.amp.autocast():
output_tokens = model.generate(**batch,
max_new_tokens=256,
generation_config=generation_config)
output = tokenizer.decode(output_tokens[0], skip_special_tokens=True)
return output
def gen_question(text):
input_text = f'<s>Instruction: Dado el siguiente texto quiero que generes una pregunta cuya respuesta se encuentre en él.\nInput: {text}\nOutput: '
batch = tokenizer(input_text, return_tensors='pt')
with torch.cuda.amp.autocast():
output_tokens = model.generate(**batch,
max_new_tokens=256,
generation_config=generation_config)
output = tokenizer.decode(output_tokens[0], skip_special_tokens=True)
return output
def gen_qna(context, question):
input_text = f"""<s>Instruction: Te voy a proporcionar un texto del cual deseo que me respondas una pregunta.
El texto es el siguiente: `{context}`\nInput: {question}\nOutput: """
batch = tokenizer(input_text, return_tensors='pt')
with torch.cuda.amp.autocast():
output_tokens = model.generate(**batch,
max_new_tokens=256,
generation_config=generation_config)
output = tokenizer.decode(output_tokens[0], skip_special_tokens=True)
return output
We selected 1000 examples for each of the three tasks in the training dataset, and 100 examples for each task in the validation dataset. This resulted in a total of 3000 examples for training and 300 examples for validation.
The Colab used for training is here.
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).