File size: 2,142 Bytes
9cfff32
fbf5042
 
 
 
f76be94
fbf5042
f76be94
 
 
 
fbf5042
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: PyTerrier SPLADE
emoji: ๐Ÿ•
colorFrom: green
colorTo: green
sdk: gradio
sdk_version: 3.7
app_file: app.py
pinned: false
---

<style>
.transformer {
  display: inline-block;
  background: #8facdb;
  position: relative;
  height: 60px;
  line-height: 60px;
  padding: 0 24px;
  margin: 0 18px;
  color: #333;
  cursor: help;
}
.transformer::before {
  content: "";
  position: absolute;
  bottom: 0;
  top: 0;
  left: -15px;
  border-top: 30px solid #8facdb;
  border-bottom: 30px solid #8facdb;
  border-left: 15px solid transparent;
}
.transformer::after {
  content: "";
  position: absolute;
  bottom: 0;
  top: 0;
  right: -15px;
  border-top: 30px solid transparent;
  border-bottom: 30px solid transparent;
  border-left: 15px solid #8facdb;
}
.transformer.boring {
  background: #ddd;
}
.transformer.boring::before {
  border-top-color: #ddd;
  border-bottom-color: #ddd;
}
.transformer.boring::after {
  border-left-color: #ddd;
}
.df {
  width: 24px;
  line-height: 24px;
  text-align: center;
  border: 3px double #888;
  background-color: #eee;
  color: #333;
  border-radius: 4px;
  display: inline-block;
  box-sizing: content-box;
  cursor: help;
  margin: 0 -25px;
  opacity: 0.5;
  z-index: 1;
  position: relative;
}
.df:hover {
  opacity: 1;
}
.pipeline {
  text-align: center;
}
</style>

This is a demonstration of [PyTerrier's SPLADE package](https://github.com/cmacdonald/pyt_splade). The SPLADE model encodes queries and documents
into sparse representations, which can then be used for indexing and retrieval.

### Query Encoding

Let's start by exploring SPLADE's query encoder. The query encoder is a `Qโ†’Q` (query rewriting, query-to-query) transformer, and can be used in pipelines accordingly.
It maps a query string into [MatchOp](https://terrier-core.readthedocs.io/en/latest/querylanguage.html#matching-op-query-language) query with terms from the
query re-weighted and weighted expansion terms added.

<div class="pipeline">
  <div class="df" title="Query Frame">Q</div>
  <div class="transformer" title="SPLADE Query Transformer">SPLADE</div>
  <div class="df" title="Query Frame">Q</div>
</div>