Chi Honolulu commited on
Commit
6c938c8
·
1 Parent(s): 2736ad6

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +64 -0
README.md ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ # For reference on model card metadata, see the spec: https://github.com/huggingface/hub-docs/blob/main/modelcard.md?plain=1
3
+ # Doc / guide: https://huggingface.co/docs/hub/model-cards
4
+ license: mit
5
+ language:
6
+ - multilingual
7
+ ---
8
+ # Model Card for mt5-base-binary-en-iiia-02c
9
+
10
+ <!-- Provide a quick summary of what the model is/does. -->
11
+
12
+ This model is fine-tuned for binary text classification of Supportive Interactions in Instant Messenger dialogs of Adolescents.
13
+
14
+ ## Model Description
15
+
16
+ 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.
17
+
18
+ - **Developed by:** Anonymous
19
+ - **Language(s):** multilingual
20
+ - **Finetuned from:** mt5-base
21
+
22
+ ## Model Sources
23
+
24
+ <!-- Provide the basic links for the model. -->
25
+
26
+ - **Repository:** https://github.com/chi2024submission
27
+ - **Paper:** Stay tuned!
28
+
29
+ ## Usage
30
+ Here is how to use this model to classify a context-window of a dialogue:
31
+
32
+ ```python
33
+ from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
34
+ import torch
35
+
36
+ # Target utterance
37
+ test_texts = ['Utterance2']
38
+ # Bi-directional context of the target utterance
39
+ test_text_pairs = ['Utterance1;Utterance2;Utterance3']
40
+
41
+ # Load the model and tokenizer
42
+ checkpoint_path = "chi2024/mt5-base-binary-en-iiia-02c"
43
+ model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint_path)\
44
+ .to("cuda" if torch.cuda.is_available() else "cpu")
45
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint_path)
46
+
47
+ # Define helper functions
48
+ def verbalize_input(text: str, text_pair: str) -> str:
49
+ return "Utterance: %s\nContext: %s" % (text, text_pair)
50
+
51
+ def predict_one(text, pair):
52
+ input_pair = verbalize_input(text, pair)
53
+ inputs = tokenizer(input_pair, return_tensors="pt", padding=True,
54
+ truncation=True, max_length=256).to(model.device)
55
+ outputs = model.generate(**inputs)
56
+ decoded = [text.strip() for text in
57
+ tokenizer.batch_decode(outputs, skip_special_tokens=True)]
58
+ return decoded
59
+
60
+ # Run the prediction
61
+ preds_txt = [predict_one(t,p) for t,p in zip(test_texts, test_text_pairs)]
62
+ preds_lbl = [1 if x == 'positive' else 0 for x in preds_txt]
63
+ print(preds_lbl)
64
+ ```