Downloads · 30 days
0
GrantC/alpaca-opt-1.3b-lora
alpaca-opt-1.3b-lora is a machine learning model from GrantC. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
I will give more info but this is how to generate text with the model. You will need to install
Downloads · 30 days
0
Access
Public
Updated Mar 26, 2023
Repo size
12.6 MB
Likes
0
Public
Click a slice to open those files.
.bin12.6 MB · 79%
From the Hugging Face model README
I will give more info but this is how to generate text with the model. You will need to install
pip install peft
To run in python
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftConfig, PeftModelForCausalLM
peft_model_id = 'GrantC/alpaca-opt-1.3b-lora'
BASE_MODEL = 'facebook/opt-1.3b'
config = PeftConfig.from_pretrained(peft_model_id)
model = AutoModelForCausalLM.from_pretrained(BASE_MODEL)
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
model = PeftModelForCausalLM.from_pretrained(model, peft_model_id, device_map="auto")
prompt = "Write a blog post about shaving cream:"
print(prompt)
inputs = tokenizer(prompt, return_tensors='pt')
output = model.generate(input_ids=inputs["input_ids"], do_sample= True, penalty_alpha=0.6, top_k=4, max_new_tokens=256)
outputs = tokenizer.decode(output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
print(outputs)