Downloads · 30 days
0
koyeb/Meta-Llama-3.1-8B-Instruct-Apple-MLX-Adapter
Meta-Llama-3.1-8B-Instruct-Apple-MLX-Adapter is a question answering model from koyeb. Use it when the input is a question plus a passage. It is set up for transformers. The card lists the license as mit.
This model is QLORA adapater for Meta's LLaMa 3.1 8B model, trained to answer questions and provide guidance on Apple's latest machine learning framework, MLX. The fine-tuning was done using the LORA (Low-Rank Adaptat…
Downloads · 30 days
0
Access
Public
Updated Sep 26, 2024
Repo size
68.2 MB
Likes
0
Public
Click a slice to open those files.
.safetensors13.6 MB · 100%
From the Hugging Face model README
This model is QLORA adapater for Meta's LLaMa 3.1 8B model, trained to answer questions and provide guidance on Apple's latest machine learning framework, MLX. The fine-tuning was done using the LORA (Low-Rank Adaptation) method on a custom dataset of question-answer pairs derived from the MLX documentation.
Fine-tuned on a single epoch of Apple MLX QA.
To use the model, you need to install the required dependencies:
pip install peft transformers jinja2==3.1.0
Here’s a sample code snippet to load and interact with the model:
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load the base model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
"meta-llama/Llama-3.1-8B-Instruct", torch_dtype=torch.bfloat16
)
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.1-8B-Instruct")
# Load the fine-tuned model using LORA
model = PeftModel.from_pretrained(
model,
"koyeb/Meta-Llama-3.1-8B-Instruct-Apple-MLX",
).to("cuda")
# Define input using a chat template with a system prompt and user query
ids = tokenizer.apply_chat_template(
[
{
"role": "system",
"content": "You are a helpful AI coding assistant with expert knowledge of Apple's latest machine learning framework: MLX. You can help answer questions about MLX, provide code snippets, and help debug code.",
},
{
"role": "user",
"content": "How do you transpose a matrix in MLX?",
},
],
tokenize=True,
add_generation_prompt=True,
return_tensors="pt",
).to("cuda")
# Generate and print the response
print(
tokenizer.decode(
model.generate(input_ids=ids, max_new_tokens=256, temperature=0.5).tolist()[0][
len(ids) :
]
)
)