File size: 3,014 Bytes
0379cb7
 
 
 
 
cab9dba
0379cb7
3017384
 
0379cb7
 
 
 
 
cab9dba
0379cb7
 
 
 
 
690a314
105b861
361e5a8
 
dd6dbc9
361e5a8
 
 
 
 
9117be9
 
361e5a8
 
 
 
dd6dbc9
361e5a8
 
 
 
 
9117be9
 
105b861
0379cb7
 
 
3017384
1b64cc5
3017384
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
690a314
 
1b64cc5
0379cb7
 
 
 
 
 
 
 
 
 
cab9dba
 
0379cb7
 
cab9dba
 
0379cb7
 
cab9dba
0379cb7
 
 
 
 
 
 
 
 
 
3017384
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---
base_model: meta-llama/Llama-2-7b-chat-hf
tags:
- generated_from_trainer
model-index:
- name: Llama2-sentiment-prompt-tuned
  results: []
datasets:
- mteb/tweet_sentiment_extraction
---

<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->

# Llama2-sentiment-prompt-tuned

This model is a fine-tuned version of [meta-llama/Llama-2-7b-chat-hf](https://huggingface.co/meta-llama/Llama-2-7b-chat-hf) on an unknown dataset.

## Model description

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


## Intended uses & limitations

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
```

## Training and evaluation data

More information needed

## Training procedure

### Training hyperparameters

The following hyperparameters were used during training:
- learning_rate: 0.001
- train_batch_size: 4
- eval_batch_size: 8
- seed: 42
- gradient_accumulation_steps: 2
- total_train_batch_size: 8
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- num_epochs: 2

### Training results



### Framework versions

- Transformers 4.36.0.dev0
- Pytorch 2.1.0+cu121
- Datasets 2.14.6
- Tokenizers 0.14.1