Downloads · 30 days
0
zimyu/llama2-13b-zsee-lora
llama2-13b-zsee-lora is a machine learning model from zimyu. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This LoRA model was fine-tuned using the zeolite synthesis dataset ZSEE.
Downloads · 30 days
0
Access
Public
Updated Jan 8, 2025
Repo size
1 GB
Likes
0
Public
Click a slice to open those files.
.safetensors1 GB · 100%
From the Hugging Face model README
This LoRA model was fine-tuned using the zeolite synthesis dataset ZSEE.
Usage:
import torch
from transformers import (
AutoConfig,
AutoTokenizer,
AutoModelForCausalLM,
GenerationConfig
)
from peft import PeftModel
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model_path = 'meta-llama/Llama-2-13b-chat-hf'
lora_path = 'zimyu/llama2-13b-zsee-lora'
config = AutoConfig.from_pretrained(model_path, trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_path,
config=config,
device_map="auto",
torch_dtype=torch.bfloat16,
trust_remote_code=True,
)
model = PeftModel.from_pretrained(
model,
lora_path,
)
model.eval()
system_prompt = "<<SYS>>\nYou are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\n\nIf a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.\n<</SYS>>\n\n"
sintruct = "{\"instruction\": \"You are an expert in event argument extraction. Please extract event arguments and their roles from the input that conform to the schema definition, which already includes event trigger words. If an argument does not exist, return NAN or an empty dictionary. Please respond in the format of a JSON string.\", \"schema\": [{\"event_type\": \"Add\", \"trigger\": [\"added\"], \"arguments\": [\"container\", \"material\", \"temperature\"]}, {\"event_type\": \"Stir\", \"trigger\": [\"stirred\"], \"arguments\": [\"sample\", \"revolution\", \"temperature\", \"duration\"]}], \"input\": \"Subsequently , the pre-prepared silicalite-1 seed was added to the above mixture and stirred for another 1 h , and the quantity of seed equals to 7.0 wt% of the total SiO2 in the starting gel .\"}"
sintruct = '[INST] ' + system_prompt + sintruct + ' [/INST]'
input_ids = tokenizer.encode(sintruct, return_tensors="pt").to(device)
input_length = input_ids.size(1)
generation_output = model.generate(input_ids=input_ids, generation_config=GenerationConfig(max_length=512, max_new_tokens=256, return_dict_in_generate=True))
generation_output = generation_output.sequences[0]
generation_output = generation_output[input_length:]
output = tokenizer.decode(generation_output, skip_special_tokens=True)
print(output)
Output:
{"Add": [{"container": "NAN", "material": ["above mixture", "pre-prepared silicalite-1 seed"], "temperature": "NAN"}], "Stir": [{"sample": "NAN", "revolution": "NAN", "temperature": "NAN", "duration": "1 h"}]}