vahidthegreat commited on
Commit
44e7110
1 Parent(s): fabd526

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +29 -1
README.md CHANGED
@@ -41,6 +41,9 @@ from transformers import (
41
  TrainingArguments,
42
  AutoConfig,
43
  )
 
 
 
44
  ```
45
 
46
 
@@ -77,7 +80,7 @@ base_model = SiameseNetworkMPNet(model_name=base_model_name, tokenizer=tokenizer
77
 
78
  # Load and apply LoRA weights
79
  lora_model = SiameseNetworkMPNet(model_name=base_model_name, tokenizer=tokenizer)
80
- lora_model = PeftModel.from_pretrained(base_model_copy, "vahidthegreat/StanceAware-SBERT")
81
  lora_model = lora_model.merge_and_unload()
82
 
83
  base_model.eval()
@@ -109,14 +112,39 @@ def two_sentence_similarity(model, tokenizer, text1, text2):
109
  text1 = "I love pineapple on pizza"
110
  text2 = "I hate pineapple on pizza"
111
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  print(f"For Base Model sentences: '{text1}' and '{text2}'")
113
  two_sentence_similarity(base_model, tokenizer, text1, text2)
114
  print(f"\n\nFor FineTuned Model sentences: '{text1}' and '{text2}'")
115
  two_sentence_similarity(lora_model, tokenizer, text1, text2)
116
  ```
 
 
 
 
 
 
117
 
118
 
119
 
 
 
 
 
 
 
 
120
  ## Key Applications
121
 
122
  This stance-aware sentence transformer model can be applied to various fields within social computing and opinion analysis. Here are some key applications:
 
41
  TrainingArguments,
42
  AutoConfig,
43
  )
44
+ import torch
45
+ import torch.nn as nn
46
+ import torch.nn.functional as F
47
  ```
48
 
49
 
 
80
 
81
  # Load and apply LoRA weights
82
  lora_model = SiameseNetworkMPNet(model_name=base_model_name, tokenizer=tokenizer)
83
+ lora_model = PeftModel.from_pretrained(lora_model, "vahidthegreat/StanceAware-SBERT")
84
  lora_model = lora_model.merge_and_unload()
85
 
86
  base_model.eval()
 
112
  text1 = "I love pineapple on pizza"
113
  text2 = "I hate pineapple on pizza"
114
 
115
+ print(f"For Base Model sentences: '{text1}' and '{text2}'")
116
+ two_sentence_similarity(base_model, tokenizer, text1, text2)
117
+ print(f"\nFor FineTuned Model sentences: '{text1}' and '{text2}'")
118
+ two_sentence_similarity(lora_model, tokenizer, text1, text2)
119
+
120
+ print('\n\n')
121
+
122
+
123
+ # Example sentences
124
+ text1 = "I love pineapple on pizza"
125
+ text2 = "I like pineapple on pizza"
126
+
127
  print(f"For Base Model sentences: '{text1}' and '{text2}'")
128
  two_sentence_similarity(base_model, tokenizer, text1, text2)
129
  print(f"\n\nFor FineTuned Model sentences: '{text1}' and '{text2}'")
130
  two_sentence_similarity(lora_model, tokenizer, text1, text2)
131
  ```
132
+ ```output
133
+ For Base Model sentences: 'I love pineapple on pizza' and 'I hate pineapple on pizza'
134
+ Cosine Similarity: 0.8590984344482422
135
+
136
+ For FineTuned Model sentences: 'I love pineapple on pizza' and 'I hate pineapple on pizza'
137
+ Cosine Similarity: 0.5732507705688477
138
 
139
 
140
 
141
+ For Base Model sentences: 'I love pineapple on pizza' and 'I like pineapple on pizza'
142
+ Cosine Similarity: 0.9773550033569336
143
+
144
+ For FineTuned Model sentences: 'I love pineapple on pizza' and 'I like pineapple on pizza'
145
+ Cosine Similarity: 0.9712905883789062
146
+ ```
147
+
148
  ## Key Applications
149
 
150
  This stance-aware sentence transformer model can be applied to various fields within social computing and opinion analysis. Here are some key applications: