pcs-annotator 0.1.5__tar.gz → 0.1.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pcs-annotator
3
- Version: 0.1.5
3
+ Version: 0.1.7
4
4
  Summary: A Python library for classification tasks using multiple LLMs
5
5
  Project-URL: Homepage, https://github.com/salsina/PCS-Python-Library
6
6
  Project-URL: Issues, https://github.com/salsina/PCS-Python-Library/issues
@@ -53,7 +53,7 @@ class LLM:
53
53
 
54
54
  model = HuggingFaceEndpoint(
55
55
  repo_id=self.model_name,
56
- task="text-generation",
56
+ # task="conversational",
57
57
  temperature=0.1,
58
58
  huggingfacehub_api_token=self.key,
59
59
  )
@@ -187,44 +187,26 @@ class PCS:
187
187
  num_labels = len(possible_labels)
188
188
  pcs_labels = np.zeros(num_labels)
189
189
 
190
+ print(llm_labels)
190
191
  for i in range(len(w_llms)):
191
- # Step 1: Rank MRs based on their weights
192
- mrs_indices = np.argsort(w_mrs)[::-1] # Sort in descending order
193
-
194
- # Get the labels from each MR for this LLM
195
- mr_predictions = [llm_labels[i][j].strip().lower() for j in range(len(w_mrs))]
196
-
197
- # Reorder predictions by MR weight
198
- ranked_predictions = [mr_predictions[j] for j in mrs_indices]
199
-
200
- # Step 2-4: Implement the voting logic for 4 MRs
201
- selected_label = None
202
-
203
- # Check if top two MRs choose the same label
204
- if ranked_predictions[0] == ranked_predictions[1]:
205
- selected_label = ranked_predictions[0]
206
- # Check if the other two MRs (3rd and 4th) choose the same label
207
- elif ranked_predictions[2] == ranked_predictions[3]:
208
- selected_label = ranked_predictions[2]
209
- else:
210
- # Default to first (highest weighted) MR's label
211
- selected_label = ranked_predictions[0]
212
-
213
- # Convert the selected label to one-hot encoding
214
192
  pcs_label_llm = np.zeros(num_labels)
215
- if selected_label:
216
- for k in range(num_labels):
217
- if selected_label == possible_labels[k].strip().lower():
218
- pcs_label_llm[k] = 1.0
219
- break
193
+ for j in range(len(llm_labels[i])): #Iterate through MR labels
194
+ for k in range(len(pcs_label_llm)):
195
+ if llm_labels[i][j]:
196
+ if llm_labels[i][j].strip().lower() == possible_labels[k].strip().lower():
197
+ pcs_label_llm[k] += w_mrs[j]
198
+
199
+ # Normalize by sum of MR weights
200
+ if sum(w_mrs) != 0:
201
+ pcs_label_llm = pcs_label_llm / sum(w_mrs)
220
202
 
221
203
  # Weight by LLM weights and accumulate
222
204
  pcs_labels += w_llms[i] * pcs_label_llm
223
-
205
+
224
206
  # Normalize by sum of LLM weights
225
207
  if sum(w_llms) != 0:
226
208
  pcs_labels = pcs_labels / sum(w_llms)
227
-
209
+
228
210
  return pcs_labels
229
211
 
230
212
  def Objective(self, params, llm_preds, NUM_LLMS, NUM_MRS, manual_labels):
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
5
5
 
6
6
  [project]
7
7
  name = "pcs-annotator"
8
- version = "0.1.5"
8
+ version = "0.1.7"
9
9
  authors = [
10
10
  { name = "Sina Salimian", email = "sina99.sn@gmail.com" }
11
11
  ]
File without changes
File without changes