pcs-annotator 0.1.3__tar.gz → 0.1.4__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.
- {pcs_annotator-0.1.3 → pcs_annotator-0.1.4}/PKG-INFO +14 -16
- {pcs_annotator-0.1.3 → pcs_annotator-0.1.4}/README.md +13 -15
- {pcs_annotator-0.1.3 → pcs_annotator-0.1.4}/pcs_annotator/PCS.py +9 -6
- {pcs_annotator-0.1.3 → pcs_annotator-0.1.4}/pyproject.toml +1 -1
- {pcs_annotator-0.1.3 → pcs_annotator-0.1.4}/LICENSE +0 -0
- {pcs_annotator-0.1.3 → pcs_annotator-0.1.4}/pcs_annotator/Annotator.py +0 -0
- {pcs_annotator-0.1.3 → pcs_annotator-0.1.4}/pcs_annotator/LLM.py +0 -0
- {pcs_annotator-0.1.3 → pcs_annotator-0.1.4}/pcs_annotator/TextMutator.py +0 -0
- {pcs_annotator-0.1.3 → pcs_annotator-0.1.4}/pcs_annotator/Tools.py +0 -0
- {pcs_annotator-0.1.3 → pcs_annotator-0.1.4}/pcs_annotator/__init__.py +0 -0
- {pcs_annotator-0.1.3 → pcs_annotator-0.1.4}/requirements.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pcs-annotator
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
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
|
|
@@ -43,6 +43,9 @@ Respond only with the label and the reasoning.
|
|
|
43
43
|
"""
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
+
### Training Dataset Path (`dataset_path`)
|
|
47
|
+
|
|
48
|
+
You will need a CSV file with two columns: `label` and `text` to ensure better annotation, as the data is used to train the LLMs.
|
|
46
49
|
|
|
47
50
|
|
|
48
51
|
|
|
@@ -53,7 +56,7 @@ The `PCS` class allows you to customize various hyperparameters, including the c
|
|
|
53
56
|
|
|
54
57
|
### 📌 Example Usage
|
|
55
58
|
```python
|
|
56
|
-
PCS(
|
|
59
|
+
pcs = PCS(
|
|
57
60
|
prompt="Your classification prompt here",
|
|
58
61
|
dataset_path="path/to/dataset.csv",
|
|
59
62
|
annotators=["llama3-8b-8192", "mistralai/Mistral-7B-Instruct-v0.3", "google/gemma-2-9b-it"],
|
|
@@ -61,15 +64,14 @@ PCS(
|
|
|
61
64
|
GROQ_API_KEY=None,
|
|
62
65
|
OPENAI_API_KEY=None,
|
|
63
66
|
ANTHROPIC_API_KEY=None,
|
|
64
|
-
HUGGINGFACE_API_KEY=None
|
|
67
|
+
HUGGINGFACE_API_KEY=None,
|
|
68
|
+
train=True
|
|
65
69
|
)
|
|
70
|
+
|
|
71
|
+
print(pcs.annotate("America is a country"))
|
|
66
72
|
```
|
|
67
73
|
|
|
68
74
|
# Configuration
|
|
69
|
-
## 🔹 Training Dataset (`dataset_path`)
|
|
70
|
-
|
|
71
|
-
You will need a CSV file with two columns: `label` and `text` to ensure better annotation, as the data is used to train the LLMs.
|
|
72
|
-
|
|
73
75
|
|
|
74
76
|
## 🔹 Annotators (`annotators`)
|
|
75
77
|
Defines the list of LLMs used for annotation.
|
|
@@ -97,12 +99,8 @@ To access certain LLM models, you need to provide API keys. These can be passed
|
|
|
97
99
|
| `HUGGINGFACE_API_KEY` | Required for **Mistral and Google Gemma models**. |
|
|
98
100
|
|
|
99
101
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
### Annotate a New Text
|
|
106
|
-
|
|
107
|
-
```python
|
|
108
|
-
print(pcs.annotate("America is a country"))
|
|
102
|
+
## 🔹 Continue the Training (`train`)
|
|
103
|
+
Determines whether to continue optimizing weights using more data or not
|
|
104
|
+
* **Default Value**: `True`
|
|
105
|
+
* **Customization**:
|
|
106
|
+
* You can change to `False`
|
|
@@ -22,6 +22,9 @@ Respond only with the label and the reasoning.
|
|
|
22
22
|
"""
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
### Training Dataset Path (`dataset_path`)
|
|
26
|
+
|
|
27
|
+
You will need a CSV file with two columns: `label` and `text` to ensure better annotation, as the data is used to train the LLMs.
|
|
25
28
|
|
|
26
29
|
|
|
27
30
|
|
|
@@ -32,7 +35,7 @@ The `PCS` class allows you to customize various hyperparameters, including the c
|
|
|
32
35
|
|
|
33
36
|
### 📌 Example Usage
|
|
34
37
|
```python
|
|
35
|
-
PCS(
|
|
38
|
+
pcs = PCS(
|
|
36
39
|
prompt="Your classification prompt here",
|
|
37
40
|
dataset_path="path/to/dataset.csv",
|
|
38
41
|
annotators=["llama3-8b-8192", "mistralai/Mistral-7B-Instruct-v0.3", "google/gemma-2-9b-it"],
|
|
@@ -40,15 +43,14 @@ PCS(
|
|
|
40
43
|
GROQ_API_KEY=None,
|
|
41
44
|
OPENAI_API_KEY=None,
|
|
42
45
|
ANTHROPIC_API_KEY=None,
|
|
43
|
-
HUGGINGFACE_API_KEY=None
|
|
46
|
+
HUGGINGFACE_API_KEY=None,
|
|
47
|
+
train=True
|
|
44
48
|
)
|
|
49
|
+
|
|
50
|
+
print(pcs.annotate("America is a country"))
|
|
45
51
|
```
|
|
46
52
|
|
|
47
53
|
# Configuration
|
|
48
|
-
## 🔹 Training Dataset (`dataset_path`)
|
|
49
|
-
|
|
50
|
-
You will need a CSV file with two columns: `label` and `text` to ensure better annotation, as the data is used to train the LLMs.
|
|
51
|
-
|
|
52
54
|
|
|
53
55
|
## 🔹 Annotators (`annotators`)
|
|
54
56
|
Defines the list of LLMs used for annotation.
|
|
@@ -76,12 +78,8 @@ To access certain LLM models, you need to provide API keys. These can be passed
|
|
|
76
78
|
| `HUGGINGFACE_API_KEY` | Required for **Mistral and Google Gemma models**. |
|
|
77
79
|
|
|
78
80
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
### Annotate a New Text
|
|
85
|
-
|
|
86
|
-
```python
|
|
87
|
-
print(pcs.annotate("America is a country"))
|
|
81
|
+
## 🔹 Continue the Training (`train`)
|
|
82
|
+
Determines whether to continue optimizing weights using more data or not
|
|
83
|
+
* **Default Value**: `True`
|
|
84
|
+
* **Customization**:
|
|
85
|
+
* You can change to `False`
|
|
@@ -9,7 +9,7 @@ from tqdm import tqdm
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class PCS:
|
|
12
|
-
def __init__(self, prompt, dataset_path, annotators=["llama3-8b-8192", "mistralai/Mistral-7B-Instruct-v0.3", "google/gemma-2-9b-it"], textmutator="llama-3.1-8b-instant", GROQ_API_KEY=None, OPENAI_API_KEY=None, ANTHROPIC_API_KEY=None, HUGGINGFACE_API_KEY=None):
|
|
12
|
+
def __init__(self, prompt, dataset_path, annotators=["llama3-8b-8192", "mistralai/Mistral-7B-Instruct-v0.3", "google/gemma-2-9b-it"], textmutator="llama-3.1-8b-instant", GROQ_API_KEY=None, OPENAI_API_KEY=None, ANTHROPIC_API_KEY=None, HUGGINGFACE_API_KEY=None, train=True):
|
|
13
13
|
self.prompt=prompt
|
|
14
14
|
if os.path.exists(dataset_path):
|
|
15
15
|
self.dataset_path = dataset_path
|
|
@@ -50,9 +50,10 @@ class PCS:
|
|
|
50
50
|
self.optimal_mr_weights = [1] * 4
|
|
51
51
|
self.optimal_label_thresholds = [0.5] * len(self.possible_labels)
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
if train:
|
|
54
|
+
print("Labelling the dataset...")
|
|
55
|
+
self.create_annotations()
|
|
56
|
+
print("Generated the dataset annotations.")
|
|
56
57
|
|
|
57
58
|
print("Optimizing weights...")
|
|
58
59
|
self.PDE()
|
|
@@ -194,8 +195,10 @@ class PCS:
|
|
|
194
195
|
return -accuracy # We want to maximize accuracy, so we minimize negative accuracy
|
|
195
196
|
|
|
196
197
|
def PDE(self):
|
|
197
|
-
|
|
198
|
-
|
|
198
|
+
if os.path.exists(self.annotations_filename):
|
|
199
|
+
df = pd.read_csv(self.annotations_filename)
|
|
200
|
+
else:
|
|
201
|
+
return
|
|
199
202
|
# Define model column mappings
|
|
200
203
|
model_columns = []
|
|
201
204
|
for annotator in self.annotators:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|