aynaval2003 commited on
Commit
002dbcf
·
verified ·
1 Parent(s): 3eb4652

Model card

Browse files
Files changed (1) hide show
  1. README.md +69 -0
README.md ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language: [en]
4
+ library_name: transformers
5
+ pipeline_tag: sentence-similarity
6
+ tags: [sentence-transformers, sentence-similarity, feature-extraction, sbert]
7
+ ---
8
+
9
+ # echo-sbert-domain
10
+
11
+ A sentence embedding model for **short, messy, real-world app-store reviews**.
12
+
13
+ Built for [Echo](https://github.com/ayn-aval/Echo), which turns 100,000 Swiggy
14
+ Google Play reviews into tracked themes. Trained in two stages:
15
+
16
+ 1. **Sentence-BERT reproduction.** `distilroberta-base` on 300,000 SNLI +
17
+ MultiNLI pairs, siamese, mean pooling, classifier on `(u, v, |u-v|)` — written
18
+ by hand in raw PyTorch, reproducing
19
+ [Reimers & Gurevych (2019)](https://arxiv.org/abs/1908.10084).
20
+ 2. **Domain adaptation.** Continued with `MultipleNegativesRankingLoss` on 53,061
21
+ pairs mined from the reviews themselves, where TF-IDF and the stage-1 encoder
22
+ independently agree, plus SimCSE dropout self-pairs.
23
+
24
+ ## Results
25
+
26
+ | benchmark | score |
27
+ |---|---|
28
+ | STS average (7 datasets) after stage 1 | 72.17 |
29
+ | STS average after stage 2 | **74.54** |
30
+ | Review retrieval, Precision@10 | 61.15 |
31
+ | Review retrieval, + cross-encoder rerank | **75.77** |
32
+ | Theme assignment, blind hand-audit | 82.4% |
33
+
34
+ Stage 2 improved generic STS by +2.37 while adapting to the domain, which was
35
+ predicted to degrade and did not. Note that 74.54 is **not** "beating the paper's
36
+ 74.21": that number comes from NLI training alone, this adds a second stage.
37
+
38
+ ## Limitations, stated plainly
39
+
40
+ - **It does not bridge Hinglish.** "khana thanda tha" against "the food was cold"
41
+ scores 0.066, versus 0.049 for a genuinely unrelated pair. Romanised Hindi
42
+ reviews cluster by *language* rather than by subject.
43
+ - **On its own it loses to TF-IDF** for review retrieval (61.15 vs 65.00). It only
44
+ wins in front of a cross-encoder reranker.
45
+ - **Part of the retrieval gain may be circular** — mined pairs required TF-IDF to
46
+ agree, so the model may have partly learned to imitate it.
47
+ - Retrieval numbers rest on **26 hand-judged queries**, one judge.
48
+
49
+ ## Use
50
+
51
+ ```python
52
+ from transformers import AutoModel, AutoTokenizer
53
+ import torch
54
+
55
+ tok = AutoTokenizer.from_pretrained("aynaval2003/echo-sbert-domain")
56
+ model = AutoModel.from_pretrained("aynaval2003/echo-sbert-domain").eval()
57
+
58
+ def embed(sentences):
59
+ x = tok(sentences, padding=True, truncation=True, max_length=128,
60
+ return_tensors="pt")
61
+ with torch.no_grad():
62
+ h = model(**x).last_hidden_state
63
+ mask = x["attention_mask"].unsqueeze(-1).float() # mean pooling,
64
+ v = (h * mask).sum(1) / mask.sum(1).clamp(min=1e-9) # ignoring padding
65
+ return torch.nn.functional.normalize(v, dim=1)
66
+ ```
67
+
68
+ **Mean pooling, and it matters** — this model was trained with it. CLS pooling
69
+ scores 5.1 points lower in the ablation.