used native setfit head
Browse files- README.md +124 -87
- model_head.pkl +1 -1
README.md
CHANGED
|
@@ -1,130 +1,167 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
---
|
| 14 |
|
| 15 |
-
#
|
| 16 |
|
| 17 |
-
|
| 18 |
|
| 19 |
-
The
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
## Model Details
|
| 25 |
|
| 26 |
### Model Description
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
- **
|
| 31 |
-
- **
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
| 35 |
|
| 36 |
### Model Sources
|
| 37 |
|
| 38 |
-
- **Repository:**
|
| 39 |
-
- **Paper:**
|
| 40 |
-
- **
|
| 41 |
|
| 42 |
## Uses
|
| 43 |
|
| 44 |
-
###
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
```python
|
|
|
|
| 55 |
from setfit import SetFitModel
|
| 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 |
-
### Recommendations
|
| 83 |
|
| 84 |
-
|
| 85 |
-
-->
|
| 86 |
|
| 87 |
-
|
| 88 |
|
| 89 |
-
|
| 90 |
-
- Python: 3.11.11
|
| 91 |
-
- SetFit: 1.1.2
|
| 92 |
-
- Sentence Transformers: 5.1.0
|
| 93 |
-
- Transformers: 4.57.1
|
| 94 |
-
- PyTorch: 2.6.0+cu124
|
| 95 |
-
- Datasets: 3.5.0
|
| 96 |
-
- Tokenizers: 0.22.1
|
| 97 |
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
year = {2022},
|
| 110 |
-
copyright = {Creative Commons Attribution 4.0 International}
|
| 111 |
-
}
|
| 112 |
-
```
|
| 113 |
|
| 114 |
-
|
| 115 |
-
## Glossary
|
| 116 |
|
| 117 |
-
|
| 118 |
-
-->
|
| 119 |
|
| 120 |
-
|
| 121 |
-
## Model Card Authors
|
| 122 |
|
| 123 |
-
|
| 124 |
-
-->
|
| 125 |
|
| 126 |
-
<!--
|
| 127 |
## Model Card Contact
|
| 128 |
|
| 129 |
-
|
| 130 |
-
-->
|
|
|
|
| 1 |
---
|
| 2 |
+
base_model: sentence-transformers/all-mpnet-base-v2
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
license: apache-2.0
|
| 6 |
+
tags:
|
| 7 |
+
- economic-attributes
|
| 8 |
+
- mention-classification
|
| 9 |
+
- mpnet-base-v2
|
| 10 |
+
- setfit
|
| 11 |
+
- multi-label-classification
|
| 12 |
+
model-index:
|
| 13 |
+
- name: all-mpnet-base-v2_economic-attributes-classifier
|
| 14 |
+
results:
|
| 15 |
+
- task:
|
| 16 |
+
type: multi-label-classification
|
| 17 |
+
name: Multi-label classification
|
| 18 |
+
metrics:
|
| 19 |
+
- type: _tba_
|
| 20 |
+
value: -1.0
|
| 21 |
+
dataset:
|
| 22 |
+
type: custom
|
| 23 |
+
name: custom human-labeled multi-label annotation dataset
|
| 24 |
---
|
| 25 |
|
| 26 |
+
# Group mention economic attributes classifier
|
| 27 |
|
| 28 |
+
A multi-label classifier for detecting **economic attribute** categories referred to in a social group mention, trained with `setfit` based on the light-weight [`sentence-transformers/all-mpnet-base-v2`](https://huggingface.co/sentence-transformers/all-mpnet-base-v2) sentence embedding model.
|
| 29 |
|
| 30 |
+
The economic attributes classified are:
|
| 31 |
|
| 32 |
+
| attribute | definition |
|
| 33 |
+
|:------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
| 34 |
+
| class membership | People described with their membership in or belonging to a social class such as the upper class, the middle class, lower class, or the working class. |
|
| 35 |
+
| employment status | People described or categorized by their employment status such as employers, employees, self-employed, or unemployed people. |
|
| 36 |
+
| education level | People described with or categorized by their education level such as students, apprentices, higher education, tertiary education, vocational training or graduates. |
|
| 37 |
+
| income/wealth/economic status | People defined or categorized by their income, wealth, or economic status such as high/medium/low income groups, rich/poor people, homeowners/tenants/homeless. |
|
| 38 |
+
| occupation/profession | People referred to with or categorized according to their occupation or profession such as teachers, farmers, public servants, police officers |
|
| 39 |
+
| ecology of group | People categorized by their relation to the ecology of society such as carbon emitters, coal miners, green employers, green workers, sustainable farmers, those working in the fossil sector |
|
| 40 |
|
| 41 |
## Model Details
|
| 42 |
|
| 43 |
### Model Description
|
| 44 |
+
|
| 45 |
+
Group mention economic attributes classifier
|
| 46 |
+
|
| 47 |
+
- **Developed by:** Hauke Licht
|
| 48 |
+
- **Model type:** mpnet
|
| 49 |
+
- **Language(s) (NLP):** ['en']
|
| 50 |
+
- **License:** apache-2.0
|
| 51 |
+
- **Finetuned from model:** sentence-transformers/all-mpnet-base-v2
|
| 52 |
+
- **Funded by:** The *Deutsche Forschungsgemeinschaft* (DFG, German Research Foundation) under Germany's Excellence Strategy – EXC 2126/1 – 390838866
|
| 53 |
|
| 54 |
### Model Sources
|
| 55 |
|
| 56 |
+
- **Repository:** _tba_
|
| 57 |
+
- **Paper:** _tba_
|
| 58 |
+
- **Demo:** [More Information Needed]
|
| 59 |
|
| 60 |
## Uses
|
| 61 |
|
| 62 |
+
### Bias, Risks, and Limitations
|
| 63 |
|
| 64 |
+
- Evaluation of the classifier in held-out data shows that it makes mistakes.
|
| 65 |
+
- The model has been finetuned only on human-annotated labeled social group mentions recorded in sentences sampled from party manifestos of European parties (mostly far-right and Green parties). Applying the classifier in other domains can lead to higher error rates.
|
| 66 |
+
- The data used to finetune the model come from human annotators. Human annotators can be biased and factors like gender and social background can impact their annotations judgments. This may lead to bias in the detection of specific social groups.
|
| 67 |
|
| 68 |
+
#### Recommendations
|
| 69 |
+
|
| 70 |
+
- Users who want to apply the model outside its training data domain should evaluate its performance in the target data.
|
| 71 |
+
- Users who want to apply the model outside its training data domain should contuninue to finetune this model on labeled data.
|
| 72 |
+
|
| 73 |
+
### How to Get Started with the Model
|
| 74 |
|
| 75 |
+
Use the code below to get started with the model.
|
| 76 |
+
|
| 77 |
+
## Usage
|
| 78 |
+
|
| 79 |
+
You can use the model with the [`setfit` python library](https://github.com/huggingface/setfit) (>=1.1.0):
|
| 80 |
+
|
| 81 |
+
*Note:* It is recommended to use transformers version >=4.5.5,<=5.0.0 and sentence-transformers version >=4.0.1,<=5.1.0 for compatibility.
|
| 82 |
+
|
| 83 |
+
### Classification
|
| 84 |
|
| 85 |
```python
|
| 86 |
+
import torch
|
| 87 |
from setfit import SetFitModel
|
| 88 |
|
| 89 |
+
model_name = "haukelicht/all-mpnet-base-v2_economic-attributes-classifier"
|
| 90 |
+
device = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
|
| 91 |
+
classifier = SetFitModel.from_pretrained(model_name)
|
| 92 |
+
classifier.to(device);
|
| 93 |
+
|
| 94 |
+
# Example mentions
|
| 95 |
+
mentions = ["working class people", "highly-educated professionals", "people without a stable job"]
|
| 96 |
+
|
| 97 |
+
# Get predictions
|
| 98 |
+
predictions = classifier.predict(mentions)
|
| 99 |
+
print(predictions)
|
| 100 |
+
|
| 101 |
+
# Map predictions to labels
|
| 102 |
+
[
|
| 103 |
+
[
|
| 104 |
+
classifier.id2label[l]
|
| 105 |
+
for l, p in enumerate(pred) if p==1
|
| 106 |
+
]
|
| 107 |
+
for pred in predictions
|
| 108 |
+
]
|
| 109 |
```
|
| 110 |
|
| 111 |
+
### Mention embedding
|
| 112 |
+
|
| 113 |
+
```python
|
| 114 |
+
import torch
|
| 115 |
+
from sentence_transformers import SentenceTransformer
|
| 116 |
|
| 117 |
+
model_name = "haukelicht/all-mpnet-base-v2_economic-attributes-classifier"
|
| 118 |
+
device = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
|
| 119 |
|
| 120 |
+
# Load the sentence transformer component of the pre-trained classifier
|
| 121 |
+
model = SentenceTransformer(model_name, device=device)
|
| 122 |
|
| 123 |
+
# Example mentions
|
| 124 |
+
mentions = ["working class people", "highly-educated professionals", "people without a stable job"]
|
| 125 |
|
| 126 |
+
# Compute mention embeddings
|
| 127 |
+
embeddings = model.encode(mentions)
|
| 128 |
+
````
|
| 129 |
|
| 130 |
+
## Training Details
|
|
|
|
| 131 |
|
| 132 |
+
### Training Data
|
|
|
|
| 133 |
|
| 134 |
+
The train, dev, and test splits used for model finetuning and evaluation will be made available on Github upon publication of the associated research paper.
|
|
|
|
| 135 |
|
| 136 |
+
### Training Procedure
|
| 137 |
|
| 138 |
+
#### Training Hyperparameters
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
+
- num epochs: (1, 4)
|
| 141 |
+
- train batch sizes: (16, 4)
|
| 142 |
+
- body train max teps: 100
|
| 143 |
+
- head learning rate: 0.030
|
| 144 |
+
- L2 weight: 0.015
|
| 145 |
+
- warmup proportion: 0.10
|
| 146 |
|
| 147 |
+
## Evaluation
|
| 148 |
+
|
| 149 |
+
### Testing Data, Factors & Metrics
|
| 150 |
+
|
| 151 |
+
#### Testing Data
|
| 152 |
+
|
| 153 |
+
The train, dev, and test splits used for model finetuning and evaluation will be made available on Github upon publication of the associated research paper.
|
| 154 |
+
|
| 155 |
+
## Citation
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
+
**BibTeX:**
|
|
|
|
| 158 |
|
| 159 |
+
[More Information Needed]
|
|
|
|
| 160 |
|
| 161 |
+
**APA:**
|
|
|
|
| 162 |
|
| 163 |
+
[More Information Needed]
|
|
|
|
| 164 |
|
|
|
|
| 165 |
## Model Card Contact
|
| 166 |
|
| 167 |
+
hauke.licht@uibk.ac.at
|
|
|
model_head.pkl
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 19966
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9109b9e144d648da1fbf0bc4024c61799e143a852eed3d19a1f51e45878803fc
|
| 3 |
size 19966
|