File size: 4,068 Bytes
fc32f7d 22e3be1 fc32f7d 22e3be1 fc32f7d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | ---
language: en
license: apache-2.0
base_model: distilroberta-base
pipeline_tag: text-classification
tags:
- distilroberta
- intent-classification
- tool-calling
- screenshots
---
# Screenshot Intent Classifier
This repository contains a DistilRoBERTa-based classifier fine-tuned to decide
**whether a conversational agent should trigger a screenshot tool** for the
latest user message.
## Base Model
This model is fine-tuned from [`distilroberta-base`](https://huggingface.co/distilroberta-base),
and inherits the base encoder's maximum context length and tokenizer.
**distilroberta-base** is a distilled RoBERTa-family encoder intended for faster, cheaper inference than RoBERTa-base, while keeping the standard 512-token context window.
## Classifier
- `0` / `no_screenshot`: do not call the screenshot tool.
- `1` / `take_screenshot`: call the screenshot tool.
The input is a text block representing the recent conversation history,
formatted as one utterance per line (raw user messages separated by newlines),
e.g.:
```text
I'm wondering if blue goes well with yellow.
What's your take on this?
```
At inference time, the host application typically feeds the last few
conversation turns (most importantly the latest user message) in this format
and thresholds the classifier's `take_screenshot` probability to decide
whether to trigger the tool.
## Training Data
The classifier was trained on a curated, hand-labelled private dataset. It
contains hundreds of single-turn and multi-turn examples specifying whether
each user message **should** or **should not** trigger a screenshot, including:
- Clear positive triggers ("look at this", "check this out", "rate this pic").
- Clear negatives (off-topic chit-chat, abstract statements, idioms like
"I'll look into it").
- Edge cases involving deictic pronouns, quantities ("take 2 screenshots"),
negation ("don't look"), multi-turn context, and more.
No external user logs or third-party datasets were used; the training data is
purely synthetic / curated for this intent task.
## Training Setup
- Epochs: 4
- Batch size: 32 (per device)
- Learning rate: 5e-05
- Weight decay: 0.01
- Max sequence length: 512
The script builds examples by concatenating conversation history up to and
including the current user message, one utterance per line. Multi-turn
conversations therefore become multiple training examples with growing context.
## Usage
Basic usage with the Transformers library:
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
MODEL_ID = "yapwithai/yap-distilroberta-screenshot-intent"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForSequenceClassification.from_pretrained(MODEL_ID)
model.eval()
text = "look at this amazing sunset"
inputs = tokenizer(
text,
return_tensors="pt",
truncation=True,
padding="max_length",
max_length=512,
)
with torch.no_grad():
outputs = model(**inputs)
probs = outputs.logits.softmax(dim=-1)[0]
p_no, p_yes = probs.tolist()
print("P(no_screenshot)=", p_no)
print("P(take_screenshot)=", p_yes)
```
In production, you would:
- Construct a conversation history string similar to the training format
(recent user turns, each on its own line).
- Run the classifier once per latest user message.
- Threshold `p_yes` to decide whether to trigger the screenshot tool.
## DistilRoBERTa / RoBERTa Citation
If you use DistilRoBERTa in your work, please cite:
```bibtex
@inproceedings{sanh2019distilbert,
title={DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter},
author={Victor Sanh and Lysandre Debut and Julien Chaumond and Thomas Wolf},
booktitle={NeurIPS EMC^2 Workshop},
year={2019}
}
@article{liu2019roberta,
title={RoBERTa: A Robustly Optimized BERT Pretraining Approach},
author={Yinhan Liu and Myle Ott and Naman Goyal and Jingfei Du and Mandar Joshi and Danqi Chen and Omer Levy and Mike Lewis and Luke Zettlemoyer and Veselin Stoyanov},
journal={arXiv:1907.11692},
year={2019}
}
```
|