Downloads · 30 days
3
14% of all-time downloads
thepinkdrummer/maayavi
maayavi is a machine learning model from thepinkdrummer. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft.
Downloads · 30 days
3
14% of all-time downloads
All-time downloads
22
Public
Repo size
185 MB
Likes
0
Public
Click a slice to open those files.
.safetensors168 MB · 91%
From the Hugging Face model README
from huggingface_hub import notebook_login notebook_login()
from peft import PeftModel, PeftConfig from transformers import AutoModelForCausalLM, AutoTokenizer
base_model_name = "unsloth/meta-llama-3.1-8b-bnb-4bit" base_model = AutoModelForCausalLM.from_pretrained(base_model_name) tokenizer = AutoTokenizer.from_pretrained(base_model_name)
peft_model_name = "thepinkdrummer/maayavi" config = PeftConfig.from_pretrained(peft_model_name) model = PeftModel.from_pretrained(base_model, peft_model_name)
import torch
def chat_with_model(prompt, max_length=512): inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
output = model.generate(
inputs['input_ids'],
max_length=max_length,
num_return_sequences=1,
temperature=0.7,
top_p=0.9,
top_k=50,
do_sample=True,
pad_token_id=tokenizer.eos_token_id,
eos_token_id=tokenizer.eos_token_id
)
response = tokenizer.decode(output[0], skip_special_tokens=True)
return response
user_input = "Hello! How are you?" response = chat_with_model(user_input) print(response)