transformers pytorch mt5 text2text-generation multilingual license:mit autotrain_compatible endpoints_compatible region:us
---
language:
- multilingual
license: mit
---
# Model Card for mt5-base-binary-en-iiia-02c

<!-- Provide a quick summary of what the model is/does. -->

This model is fine-tuned for binary text classification of Supportive Interactions in Instant Messenger dialogs of Adolescents. 

## Model Description

The model was fine-tuned on a dataset of English Instant Messenger dialogs of Adolescents. The classification is binary and the model outputs 'positive' or 'negative': Supportive Interactions present or not. The inputs are a target utterance and its bi-directional context; it's target label that of the target utterance.

- **Developed by:** Anonymous
- **Language(s):** multilingual
- **Finetuned from:** mt5-base

## Model Sources

<!-- Provide the basic links for the model. -->

- **Repository:** https://github.com/chi2024submission
- **Paper:** Stay tuned!

## Usage
Here is how to use this model to classify a context-window of a dialogue:

```python
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
import torch

# Target utterance
test_texts = ['Utterance2']
# Bi-directional context of the target utterance
test_text_pairs = ['Utterance1;Utterance2;Utterance3']

# Load the model and tokenizer
checkpoint_path = "chi2024/mt5-base-binary-en-iiia-02c"
model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint_path)\
    .to("cuda" if torch.cuda.is_available() else "cpu")
tokenizer = AutoTokenizer.from_pretrained(checkpoint_path)

# Define helper functions
def verbalize_input(text: str, text_pair: str) -> str:
    return "Utterance: %s\nContext: %s" % (text, text_pair)

def predict_one(text, pair):
    input_pair = verbalize_input(text, pair)
    inputs = tokenizer(input_pair, return_tensors="pt", padding=True,
                       truncation=True, max_length=256).to(model.device)
    outputs = model.generate(**inputs)
    decoded = [text.strip() for text in
               tokenizer.batch_decode(outputs, skip_special_tokens=True)]
    return decoded

# Run the prediction
preds_txt = [predict_one(t,p) for t,p in zip(test_texts, test_text_pairs)]
preds_lbl = [1 if x == 'positive' else 0 for x in preds_txt]
print(preds_lbl)
```