This is a Spanish adapter generated by fine-tuning LLaMA-7B on a
Spanish Alpaca
dataset.
Usage
from peft import PeftModel
from transformers import LLaMATokenizer, LLaMAForCausalLM, GenerationConfig
base_model = "decapoda-research/llama-7b-hf"
tokenizer = LLaMATokenizer.from_pretrained(base_model)
model = LLaMAForCausalLM.from_pretrained(
base_model,
load_in_8bit=True,
device_map="auto",
)
model = PeftModel.from_pretrained(model, "bertin-project/bertin-alpaca-lora-7b")
Until
PEFT
is fully supported in Hugginface's pipelines, for generation we can either consolidate the LoRA weights into the LLaMA model weights, or use the adapter's
generate()
method. Remember that the prompt still needs the English template:
# Generate responsesdefgenerate(instruction, input=None):
ifinput:
prompt = f"""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request. # noqa: E501### Instruction:{instruction}### Input:{input}### Response:"""else:
prompt = f"""Below is an instruction that describes a task. Write a response that appropriately completes the request. # noqa: E501### Instruction:{instruction}### Response:"""
inputs = tokenizer(prompt, return_tensors="pt")
input_ids = inputs["input_ids"].cuda()
generation_output = model.generate(
input_ids=input_ids,
generation_config=GenerationConfig(temperature=0.2, top_p=0.75, num_beams=4),
return_dict_in_generate=True,
output_scores=True,
max_new_tokens=256
)
for seq in generation_output.sequences:
output = tokenizer.decode(seq)
print(output.split("### Response:")[1].strip())
generate("Escribe un correo electrónico dando la bienvenida a un nuevo empleado llamado Manolo.")
# Estimado Manolo,## ¡Bienvenido a nuestro equipo! Estamos muy contentos de que hayas decidido unirse a nosotros y estamos ansiosos por comenzar a trabajar juntos. ## Nos gustaría darte las gracias por tu interés en nuestro equipo y esperamos que tengas un gran tiempo aquí. ## Si tienes alguna pregunta o duda, no dudes en contactarnos. ## Atentamente, # Equipo de [Nombre del Departamento]
Data
The dataset is a translation to Spanish of
alpaca_data_cleaned.json
(a clean version of the
Alpaca dataset made at Stanford
) using OpenAI's
gpt-3.5-turbo
model. We translated using a full-sample prompt instead of per strings, which resulted in more coherent tuples of
(instruction, input, output)
and costed around $60.0.
This dataset cannot be used to create models that compete in any way with OpenAI.
Finetuning
To fine-tune the LLaMA model we used the code available on
Alpaca Lora
, which provides code to finetune the LLaMA model using PEFT from Hugging Face. We run finetuning for 3 epochs using sequence length of 512 with no gradient accumulation on a single A6000 with 48GB VRAM for 12 hours on top of LLaMA-7B.
Example outputs
Stanford Alpaca:
Instruction: Inventa una excusa creativa para decir que no tengo que ir a la fiesta.
Response: I'm sorry, I can't make it to the party. I have to stay home and take care of my sick pet.
BERTIN Alpaca LoRA:
Instruction: Inventa una excusa creativa para decir que no tengo que ir a la fiesta.
Response: No puedo ir a la fiesta porque tengo que terminar un proyecto urgente.
Stanford Alpaca:
Instruction: ¿Cómo puedo comenzar una carrera como científico de datos? Responde con una lista de pasos a seguir.
Response: To begin a career as a data scientist, there are a few steps to take. First, you should have a bachelor's degree in a STEM-related field, such as computer science, mathematics, statistics, or engineering. You should also have experience with programming languages such as Python, R, or Java. Additionally, it is helpful to have knowledge of machine learning, data visualization, and data analytics. Finally, it is important to stay up to date with the latest trends and technologies in the field.
BERTIN Alpaca LoRA:
Instruction: ¿Cómo puedo comenzar una carrera como científico de datos? Responde con una lista de pasos a seguir.
Response: Para comenzar una carrera como científico de datos, hay varios pasos a seguir. Primero, obtener una licenciatura en matemáticas, informática o ciencias de la computación. Luego, obtener una maestría o doctorado en ciencias de la computación, informática o alguna otra área relacionada. Finalmente, obtener experiencia en el campo trabajando en proyectos de investigación o desarrollando aplicaciones.
bertin-alpaca-lora-7b huggingface.co is an AI model on huggingface.co that provides bertin-alpaca-lora-7b's model effect (), which can be used instantly with this bertin-project bertin-alpaca-lora-7b model. huggingface.co supports a free trial of the bertin-alpaca-lora-7b model, and also provides paid use of the bertin-alpaca-lora-7b. Support call bertin-alpaca-lora-7b model through api, including Node.js, Python, http.
bertin-alpaca-lora-7b huggingface.co is an online trial and call api platform, which integrates bertin-alpaca-lora-7b's modeling effects, including api services, and provides a free online trial of bertin-alpaca-lora-7b, you can try bertin-alpaca-lora-7b online for free by clicking the link below.
bertin-project bertin-alpaca-lora-7b online free url in huggingface.co:
bertin-alpaca-lora-7b is an open source model from GitHub that offers a free installation service, and any user can find bertin-alpaca-lora-7b on GitHub to install. At the same time, huggingface.co provides the effect of bertin-alpaca-lora-7b install, users can directly use bertin-alpaca-lora-7b installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
bertin-alpaca-lora-7b install url in huggingface.co: