dr-stone commited on
Commit
06d7858
·
verified ·
1 Parent(s): 5a5a4a1

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +121 -3
README.md CHANGED
@@ -1,3 +1,121 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: apache-2.0
4
+ base_model: distilbert/distilbert-base-multilingual-cased
5
+ pipeline_tag: text-classification
6
+ tags:
7
+ - distilbert_multilingual
8
+ - intent-classification
9
+ - tool-calling
10
+ - screenshots
11
+ ---
12
+
13
+ # Screenshot Intent Classifier
14
+
15
+ This repository contains a DistilBERT Multilingual-based classifier fine-tuned to decide
16
+ **whether a conversational agent should trigger a screenshot tool** for the
17
+ latest user message.
18
+
19
+ ## Base Model
20
+
21
+ This model is fine-tuned from [`distilbert/distilbert-base-multilingual-cased`](https://huggingface.co/distilbert/distilbert-base-multilingual-cased),
22
+ and inherits the base encoder's maximum context length and tokenizer.
23
+ **distilbert-base-multilingual-cased** is a distilled version of multilingual BERT, supporting 104 languages with a compact BERT-family encoder and the standard 512-token context window.
24
+
25
+ ## Classifier
26
+
27
+ - `0` / `no_screenshot`: do not call the screenshot tool.
28
+ - `1` / `take_screenshot`: call the screenshot tool.
29
+
30
+ The input is a text block representing the recent conversation history,
31
+ formatted as one utterance per line (raw user messages separated by newlines),
32
+ e.g.:
33
+
34
+ ```text
35
+ I'm wondering if blue goes well with yellow.
36
+ What's your take on this?
37
+ ```
38
+
39
+ At inference time, the host application typically feeds the last few
40
+ conversation turns (most importantly the latest user message) in this format
41
+ and thresholds the classifier's `take_screenshot` probability to decide
42
+ whether to trigger the tool.
43
+
44
+ ## Training Data
45
+
46
+ The classifier was trained on a curated, hand-labelled private dataset. It
47
+ contains hundreds of single-turn and multi-turn examples specifying whether
48
+ each user message **should** or **should not** trigger a screenshot, including:
49
+
50
+ - Clear positive triggers ("look at this", "check this out", "rate this pic").
51
+ - Clear negatives (off-topic chit-chat, abstract statements, idioms like
52
+ "I'll look into it").
53
+ - Edge cases involving deictic pronouns, quantities ("take 2 screenshots"),
54
+ negation ("don't look"), multi-turn context, and more.
55
+
56
+ No external user logs or third-party datasets were used; the training data is
57
+ purely synthetic / curated for this intent task.
58
+
59
+ ## Training Setup
60
+
61
+ - Epochs: 5
62
+ - Batch size: 16 (per device)
63
+ - Learning rate: 1e-05
64
+ - Weight decay: 0.01
65
+ - Max sequence length: 512
66
+
67
+ The script builds examples by concatenating conversation history up to and
68
+ including the current user message, one utterance per line. Multi-turn
69
+ conversations therefore become multiple training examples with growing context.
70
+
71
+ ## Usage
72
+
73
+ Basic usage with the Transformers library:
74
+
75
+ ```python
76
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
77
+ import torch
78
+
79
+ MODEL_ID = "yapwithai/yap-distilbert-ml-screenshot-intent"
80
+
81
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
82
+ model = AutoModelForSequenceClassification.from_pretrained(MODEL_ID)
83
+ model.eval()
84
+
85
+ text = "look at this amazing sunset"
86
+ inputs = tokenizer(
87
+ text,
88
+ return_tensors="pt",
89
+ truncation=True,
90
+ padding="max_length",
91
+ max_length=512,
92
+ )
93
+
94
+ with torch.no_grad():
95
+ outputs = model(**inputs)
96
+ probs = outputs.logits.softmax(dim=-1)[0]
97
+
98
+ p_no, p_yes = probs.tolist()
99
+ print("P(no_screenshot)=", p_no)
100
+ print("P(take_screenshot)=", p_yes)
101
+ ```
102
+
103
+ In production, you would:
104
+
105
+ - Construct a conversation history string similar to the training format
106
+ (recent user turns, each on its own line).
107
+ - Run the classifier once per latest user message.
108
+ - Threshold `p_yes` to decide whether to trigger the screenshot tool.
109
+
110
+ ## DistilBERT Citation
111
+
112
+ If you use DistilBERT Multilingual in your work, please cite:
113
+
114
+ ```bibtex
115
+ @inproceedings{sanh2019distilbert,
116
+ title={DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter},
117
+ author={Victor Sanh and Lysandre Debut and Julien Chaumond and Thomas Wolf},
118
+ booktitle={NeurIPS EMC^2 Workshop},
119
+ year={2019}
120
+ }
121
+ ```