Downloads · 30 days
0
furquan/llama2-sentiment-prompt-tuned
llama2-sentiment-prompt-tuned is a machine learning model from furquan. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
should probably proofread and complete it, then remove this comment. --
Downloads · 30 days
0
Access
Public
Updated Nov 9, 2023
Repo size
7.8 MB
Likes
0
Public
Click a slice to open those files.
.json1.8 MB · 61%
From the Hugging Face model README
This model is a fine-tuned version of meta-llama/Llama-2-7b-chat-hf on an unknown dataset.
This model is Parameter Effecient Fine-tuned using Prompt Tuning. Our goal was to evaluate bias within LLama 2, and prompt-tuning is a effecient way to weed out the biases while keeping the weights frozen.
Classification Report of LLama 2 on original sentence:
precision recall f1-score support
negative 1.00 1.00 1.00 576
neutral 0.92 0.95 0.93 640
positive 0.94 0.91 0.92 576
accuracy 0.95 1792
macro avg 0.95 0.95 0.95 1792
weighted avg 0.95 0.95 0.95 1792
Classification Report of LLama 2 on preturbed sentence:
precision recall f1-score support
negative 0.93 0.74 0.82 576
neutral 0.68 0.97 0.80 640
positive 0.80 0.58 0.67 576
accuracy 0.77 1792
macro avg 0.80 0.76 0.76 1792
weighted avg 0.80 0.77 0.77 1792
You can use this model for your own sentiment-analysis task.
from transformers import AutoTokenizer
from peft import PeftModel
model_name = "furquan/llama2-sentiment-prompt-tuned"
model = PeftModel.from_pretrained(
model_name,
device_map = 'auto'
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
model.eval()
def get_pred(text):
inputs = tokenizer(f"\n### Text: {text}\n### Sentiment:", return_tensors="pt").to(model.device)
outputs = model.generate(input_ids=inputs["input_ids"].to(model.device), attention_mask=inputs["attention_mask"], max_new_tokens=1,do_sample=False)
return tokenizer.decode(outputs[0], skip_special_tokens=True).split(' ')[-1]
prediction = get_pred("The weather is lovely today.")
print(prediction)
>>positive
More information needed
The following hyperparameters were used during training: