Downloads · 30 days
0
lakieungocthang/Meta-Llama-3-8B-Fine-tuning
Meta-Llama-3-8B-Fine-tuning is a machine learning model from lakieungocthang. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
Downloads · 30 days
0
Access
Public
Updated May 29, 2024
Repo size
168 MB
Likes
0
Public
Click a slice to open those files.
.safetensors168 MB · 94%
From the Hugging Face model README

Meta has developed and launched the Meta Llama 3 family of Large Language Models (LLMs), comprising pretrained and instruction-tuned generative text models in 8 and 70 billion sizes. For details please refer to Meta Llama 3.
All the terms and conditions for using Llama 3 models list provided by Meta including of the License and Acceptable Use Policy and Meta's privacy policy.
In this project, I made fine-tune Meta-Llama-3-8B to achieve greater efficiency in text generation tasks. However, I do not fine-tune the model directly from Meta's project repository meta-llama/Meta-Llama-3-8B, I fine-tune that model with Quantization provided by Unsloth AI unsloth/llama-3-8b-bnb-4bit to save computational costs and take advantage of tools to increase mining performance created from Unsloth.
Regarding data, I chose the data set provided by NVIDIA including 37,120 samples nvidia/HelpSteer.
The step-by-step process invites readers to refer to my notebook here

This is the graph obtained after the training process.
Please implement the following code to be able to use this model.
from unsloth import FastLanguageModel
max_seq_length = 2048
dtype = None
load_in_4bit = True
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="lakieungocthang/Meta-Llama-3-8B-Fine-tuning",
max_seq_length=max_seq_length,
dtype=dtype,
device_map="auto",
load_in_4bit=load_in_4bit,
)
FastLanguageModel.for_inference(model)
def generate_response_with_question(question, max_tokens=100):
prompt = "### Question: {}\n ### Answer: {}"
inputs = tokenizer(
[prompt.format(question, "")],
return_tensors="pt"
).to("cuda")
outputs = model.generate(**inputs, max_new_tokens=max_tokens, use_cache=True)
decoded_output = tokenizer.decode(outputs[0], skip_special_tokens=True)
answer_index = decoded_output.rfind("### Answer:")
extracted_text = decoded_output[answer_index + len("### Answer:"):].strip() if answer_index != -1 else decoded_output
return extracted_text
print(generate_response_with_question("Who is Faker?"))