
# binbin83/setfit-MiniLM-dialog-themes-13-nov

The model is a multi-class multi-label text classifier to distinguish the  different dialog act in semi-structured interview. The data used fot fine-tuning were in French.

This is a [SetFit model](https://github.com/huggingface/setfit) that can be used for text classification. The model has been trained using an efficient few-shot learning technique that involves:

1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
2. Training a classification head with features from the fine-tuned Sentence Transformer.

## Usage

To use this model for inference, first install the SetFit library:

```bash
python -m pip install setfit
```

You can then run inference as follows:

```python
from setfit import SetFitModel

# Download from Hub and run inference
model = SetFitModel.from_pretrained("binbin83/setfit-MiniLM-dialog-themes-13-nov")
label_dict = {'CauseConsequences': 0, 'PersonalExperience': 1, 'Connaissance': 2, 'Other': 3, 'Reconstitution': 4, 'Temps': 5, 'Reaction': 6, 'Nouvelle': 7, 'Media': 8, 'Lieux': 9}
# Run inference
preds = model(["Vous pouvez continuer", "Pouvez-vous me dire précisément quel a été l'odre chronologique des événements ?"])
labels = [[[f for f, p in zip(labels_dict, ps) if p] for ps in [pred]] for pred in preds ]

```

##  Labels and training data
Based on interview guide, the themes evocated in the interview where : 

['CauseConsequences', 'PersonalExperience', 'Connaissance', 'Other', 'Reconstitution', 'Temps', 'Reaction', 'Nouvelle', 'Media', 'Lieux']

We label a small amount of data: 
('Other', 50), ('Reaction', 46), ('PersonalExperience', 41), ('CauseConsequences', 41), ('Media', 27), ('Lieux', 13), ('Nouvelle', 10), ('Temps', 9), ('Reconstitution', 7), ('Connaissance', 3)

and finetune a set fit model on it


## Training and Performances

We finetune: "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"
using SetFit with CosineLossSimilarity and this parapeters: epochs = 10, batch_size=32, num_iterations = 20



On our test dataset, we get this results: 
{'f1': 0.639, 'f1_micro': 0.6808510638297872, 'f1_sample': 0.6666666666666666, 'accuracy': 0.6086956521739131}

## BibTeX entry and citation info


To cite the current study:
```bibtex
@article{
doi = {conference paper},
url = {https://arxiv.org/abs/2209.11055},
author = {Quillivic Robin, Charles Payet},
keywords = {NLP, JADT},
title = {Semi-Structured Interview Analysis: A French NLP Toolbox for Social Sciences},
publisher = {JADT},
year = {2024},
copyright = {Creative Commons Attribution 4.0 International}
}
```


To cite the setFit paper: 
```bibtex
@article{https://doi.org/10.48550/arxiv.2209.11055,
doi = {10.48550/ARXIV.2209.11055},
url = {https://arxiv.org/abs/2209.11055},
author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {Efficient Few-Shot Learning Without Prompts},
publisher = {arXiv},
year = {2022},
copyright = {Creative Commons Attribution 4.0 International}
}
```
{"language": ["fr"], "license": "apache-2.0", "tags": ["setfit", "sentence-transformers", "text-classification"], "metrics": ["f1"], "pipeline_tag": "text-classification"}
sentence-transformers safetensors bert setfit text-classification fr arxiv:2209.11055 license:apache-2.0 region:us