Text Ranking
Transformers
Safetensors
English
ProductSearch
J-MADRAL commited on
Commit
210bc7a
·
verified ·
1 Parent(s): 4ff4d61

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +94 -1
README.md CHANGED
@@ -14,4 +14,97 @@ base_model:
14
  pipeline_tag: text-ranking
15
  tags:
16
  - ProductSearch
17
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  pipeline_tag: text-ranking
15
  tags:
16
  - ProductSearch
17
+ ---
18
+
19
+
20
+ **P-MADRAL** is a BERT-sized multi-aspects dense retriever initialized from [BERT](https://huggingface.co/google-bert/bert-base-uncased) public checkpoint,
21
+ further pre-trained on e-commerce product data, and fine-tuned on product search retrieval task on the
22
+ [Amazon ESCI](https://huggingface.co/datasets/J-MADRAL/AmazonESCI) dataset.
23
+ We use symmetric encoder architecture, with a single shared encoder for both queries and products.
24
+ The similarity function is *dot product*.
25
+
26
+
27
+ ## Paper and Repository ##
28
+
29
+ P-MADRAL has been described in the *Multi-Aspect Joint Retrieval for E-Commerce: Bridging Product Catalogs and Customer Reviews* paper.
30
+ The associated GitHub repository is available at [https://anonymous.4open.science/r/J-MADRAL-C4CC](https://anonymous.4open.science/r/J-MADRAL-C4CC).
31
+
32
+
33
+ ## Usage (HuggingFace Transformers) ##
34
+
35
+ Using the model directly in HuggingFace transformers requires additional code available in the [repository](https://anonymous.4open.science/r/J-MADRAL-C4CC).
36
+
37
+ ```python
38
+ import modeling
39
+ import torch
40
+ import transformers
41
+
42
+ # We use a training query from Amazon ESCI as an example.
43
+ queries = [
44
+ "iphone 11 pro max case"
45
+ ]
46
+ products = [
47
+ "OtterBox Symmetry Series Case for iPhone 11 Pro Max - Black [...]",
48
+ "Camera Lens Protector for iPhone 11 Pro/Pro Max, Tempered Glass 9H Hardness Anti-Scratch Camera Screen Protective [...]"
49
+ ]
50
+
51
+ # Load the tokenizer and model.
52
+ tokenizer = transformers.AutoTokenizer.from_pretrained("J-MADRAL/P-MADRAL")
53
+ model = modeling.BiEncoderModel.from_pretrained("J-MADRAL/P-MADRAL")
54
+
55
+ # Tokenize the input data.
56
+ q_input = tokenizer(queries,
57
+ add_special_tokens=True,
58
+ truncation=True,
59
+ padding=True,
60
+ max_length=128,
61
+ return_tensors="pt")
62
+ p_input = tokenizer(products,
63
+ add_special_tokens=True,
64
+ truncation=True,
65
+ padding=True,
66
+ max_length=128,
67
+ return_tensors="pt")
68
+
69
+ # Compute embeddings: take the "pooled_output".
70
+ q_emb = model(**q_input).pooled_output
71
+ p_emb = model(**p_input).pooled_output
72
+
73
+ # Compute similarity scores, using dot product similarity.
74
+ scores = torch.matmul(q_emb, p_emb.transpose(0, 1))
75
+ ```
76
+
77
+
78
+ ## Training Hyperparameters ##
79
+
80
+ Training Stage | Num. Epochs | Learning Rate | AP Scaling Factor | Max Num Tokens | Batch Size | Num Negatives
81
+ |---|---|---|---|---|---|---
82
+ Pre-training | 20 | 1e-4 | 0.10 | 128 | 64 | ---
83
+ Fine-tuning | 20 | 5e-6 | 0.05 | 128 | 64 | 7
84
+
85
+ The data used for fine-tuning is available at [https://huggingface.co/datasets/J-MADRAL/TrainingData](https://huggingface.co/datasets/J-MADRAL/TrainingData).
86
+
87
+
88
+ ## Evaluation Results ##
89
+
90
+ #### [Amazon ESCI](https://huggingface.co/datasets/J-MADRAL/AmazonESCI) ####
91
+
92
+ Model | R@100 | R@500 | MRR | nDCG@10 | nDCG@50
93
+ |---|---|---|---|---|---
94
+ BM25 | 0.4949 | 0.6603 | 0.4056 | 0.2599 | 0.3160
95
+ [DRAGON](https://huggingface.co/facebook/dragon-plus-context-encoder) | 0.5490 | 0.7155 | 0.4541 | 0.2929 | 0.3540
96
+ [P-BiBERT](https://huggingface.co/J-MADRAL/P-BiBERT) | 0.6018 | 0.7640 | 0.4939 | 0.3276 | 0.3967
97
+ **P-MADRAL** | **0.6235** | **0.7806** | **0.5060** | **0.3382** | **0.4104**
98
+ [J-BiBERT](https://huggingface.co/J-MADRAL/J-BiBERT) | 0.5889 | 0.7556 | 0.4808 | 0.3195 | 0.3858
99
+ [J-MADRAL](https://huggingface.co/J-MADRAL/J-MADRAL) | *0.6083* | *0.7729* | *0.4988* | *0.3330* | *0.4028*
100
+
101
+ #### [TREC Product Search 2023](https://huggingface.co/datasets/J-MADRAL/TREC_Product_Search_2023) ####
102
+
103
+ Model | R@100 | R@500 | MRR | nDCG@10 | nDCG@50
104
+ |---|---|---|---|---|---
105
+ BM25 | 0.7252 | 0.8650 | 0.7746 | 0.6231 | 0.5988
106
+ [DRAGON](https://huggingface.co/facebook/dragon-plus-context-encoder) | 0.7373 | 0.8692 | 0.8135 | 0.6526 | 0.6293
107
+ [P-BiBERT](https://huggingface.co/J-MADRAL/P-BiBERT) | 0.7432 | 0.8757 | 0.8256 | 0.6612 | 0.6287
108
+ **P-MADRAL** | **0.7547** | *0.8840* | **0.8337** | **0.6719** | **0.6480**
109
+ [J-BiBERT](https://huggingface.co/J-MADRAL/J-BiBERT) | 0.7432 | 0.8684 | 0.8114 | 0.6487 | 0.6213
110
+ [J-MADRAL](https://huggingface.co/J-MADRAL/J-MADRAL) | *0.7527* | **0.8888** | *0.8333* | *0.6702* | *0.6411*