forked from MaartenGr/KeyBERT
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
337 lines (319 loc) · 11.9 KB
/
index.html
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AdaptKeyBERT</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #1a1a1a;
color: #ffffff;
line-height: 1.6;
margin: 0;
padding: 0;
}
.container {
width: 80%;
margin: auto;
overflow: hidden;
padding: 20px;
}
header {
background: #8b0000;
color: #ffffff;
padding: 20px 0;
min-height: 70px;
border-bottom: 3px solid #ff4500;
border-radius: 0 0 20px 20px;
position: relative;
}
header a {
color: #ffffff;
text-decoration: none;
font-size: 16px;
}
.logo {
position: absolute;
top: 10px;
right: 20px;
max-width: 150px;
max-height: 150px;
}
.logo img {
width: 100%;
height: auto;
}
.button {
background: #ff4500;
padding: 10px 15px;
color: #ffffff;
border: none;
border-radius: 20px;
cursor: pointer;
margin-right: 10px;
transition: background-color 0.3s ease;
}
.button:hover {
background: #ff6347;
}
h1, h2, h3 {
margin-top: 30px;
margin-bottom: 20px;
}
img {
max-width: 100%;
height: auto;
border-radius: 10px;
}
.content {
background: #2b2b2b;
margin-top: 20px;
padding: 20px;
border-radius: 20px;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th, td {
text-align: left;
padding: 12px;
border-bottom: 1px solid #444;
}
th {
background-color: #8b0000;
color: white;
}
tr:hover {
background-color: #333;
}
pre {
background-color: #1a1a1a;
border: 1px solid #444;
border-radius: 5px;
padding: 15px;
overflow-x: auto;
font-size: 14px;
position: relative;
}
code {
font-family: 'Courier New', Courier, monospace;
}
.copy-button {
position: absolute;
top: 5px;
right: 5px;
background-color: #ff4500;
color: white;
border: none;
border-radius: 5px;
padding: 5px 10px;
cursor: pointer;
}
.copy-button:hover {
background-color: #ff6347;
}
#table-of-contents {
background-color: #2b2b2b;
padding: 20px;
border-radius: 10px;
margin-bottom: 20px;
}
#table-of-contents summary {
cursor: pointer;
font-weight: bold;
color: #ff4500;
}
#table-of-contents ul {
list-style-type: none;
padding-left: 20px;
}
#table-of-contents li {
margin-bottom: 10px;
}
#table-of-contents a {
color: #ff4500;
text-decoration: none;
}
#table-of-contents a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<header>
<div class="container">
<h1>AdaptKeyBERT</h1>
<nav>
<a href="https://amanpriyanshu.github.io/" class="button">My Website</a>
<a href="https://amanpriyanshu.github.io/blogs" class="button">My Blog</a>
<a href="https://github.com/AmanPriyanshu/AdaptKeyBERT" class="button">GitHub</a>
<a href="https://pypi.org/project/adaptkeybert/" class="button">PyPI</a>
<a href="https://amanpriyanshu.github.io/blogs/posts/2024/adaptkeybert/" class="button">Blog on AdaptKeyBERT</a>
</nav>
<div class="logo">
<img src="https://amanpriyanshu.github.io/AdaptKeyBERT/images/keybert_logo.png" alt="AdaptKeyBERT Logo">
</div>
</div>
</header>
<div class="container">
<div id="table-of-contents">
<details>
<summary>Table of Contents</summary>
<ul>
<li><a href="#tldr">TLDR</a></li>
<li><a href="#about">About AdaptKeyBERT</a></li>
<li><a href="#aim">Our Aim</a></li>
<li><a href="#pipeline">Our Pipeline</a></li>
<li>
<a href="#results">Results</a>
<ul>
<li><a href="#fao-780">FAO-780 Dataset</a></li>
<li><a href="#cern-290">CERN-290 Dataset</a></li>
</ul>
</li>
<li><a href="#installation">Installation</a></li>
<li><a href="#usage">Usage Example</a></li>
<li><a href="#citation">Citation</a></li>
</ul>
</details>
</div>
<div class="content">
<h2 id="tldr">TLDR</h2>
<p><em>Keyword/keyphrase extraction with zero-shot and few-shot semi-supervised domain adaptation.</em></p>
<h2 id="about">About AdaptKeyBERT</h2>
<p>AdaptKeyBERT expands on KeyBERT by integrating semi-supervised attention for creating a few-shot domain adaptation technique for keyphrase extraction. It also extends the work by allowing zero-shot word seeding, enabling better performance on topic-relevant documents.</p>
<h2 id="aim">Our Aim</h2>
<ul>
<li>Reconsider downstream training keyword extractors on varied domains by integrating pre-trained LLMs with Few-Shot and Zero-Shot paradigms for domain accommodation.</li>
<li>Demonstrate two experimental settings with the objectives of achieving high performance for Few-Shot Domain Adaptation & Zero-Shot Domain Adaptation.</li>
<li>Open source a Python library (AdaptKeyBERT) for the construction of FSL/ZSL for keyword extraction models that employ LLMs directly integrated with the KeyBERT API.</li>
</ul>
<h2 id="pipeline">Our Pipeline</h2>
<img src="https://amanpriyanshu.github.io/AdaptKeyBERT/images/flowcharts.png" alt="AdaptKeyBERT Pipeline">
<h2 id="results">Results</h2>
<h3 id="fao-780">FAO-780 Dataset (p%=10%)</h3>
<table>
<tr>
<th>Model</th>
<th>Precision</th>
<th>Recall</th>
<th>F-Score</th>
</tr>
<tr>
<td>Benchmark</td>
<td>36.74</td>
<td>33.67</td>
<td>35.138</td>
</tr>
<tr>
<td>Zero-Shot</td>
<td>37.25</td>
<td>38.59</td>
<td>37.908</td>
</tr>
<tr>
<td>Few-Shot</td>
<td>40.03</td>
<td>39.1</td>
<td>39.559</td>
</tr>
<tr>
<td>Zero-Shot & Few-Shot</td>
<td>40.02</td>
<td>39.86</td>
<td>39.938</td>
</tr>
</table>
<h3 id="cern-290">CERN-290 Dataset (p%=10%)</h3>
<table>
<tr>
<th>Model</th>
<th>Precision</th>
<th>Recall</th>
<th>F-Score</th>
</tr>
<tr>
<td>Benchmark</td>
<td>24.74</td>
<td>26.58</td>
<td>25.627</td>
</tr>
<tr>
<td>Zero-Shot</td>
<td>27.35</td>
<td>25.9</td>
<td>26.605</td>
</tr>
<tr>
<td>Few-Shot</td>
<td>29.00</td>
<td>27.4</td>
<td>28.177</td>
</tr>
<tr>
<td>Zero-Shot & Few-Shot</td>
<td>29.11</td>
<td>28.67</td>
<td>28.883</td>
</tr>
</table>
<h2 id="installation">Installation</h2>
<pre><code>pip install adaptkeybert</code></pre>
<h2 id="usage">Usage Example</h2>
<pre><code>from adaptkeybert import KeyBERT
doc = """
Supervised learning is the machine learning task of learning a function that
maps an input to an output based on example input-output pairs. It infers a
function from labeled training data consisting of a set of training examples.
In supervised learning, each example is a pair consisting of an input object
(typically a vector) and a desired output value (also called the supervisory signal).
A supervised learning algorithm analyzes the training data and produces an inferred function,
which can be used for mapping new examples. An optimal scenario will allow for the
algorithm to correctly determine the class labels for unseen instances. This requires
the learning algorithm to generalize from the training data to unseen situations in a
'reasonable' way (see inductive bias). But then what about supervision and unsupervision, what happens to unsupervised learning.
"""
kw_model = KeyBERT()
keywords = kw_model.extract_keywords(doc, top_n=10) # Usage with candidates - kw_model.extract_keywords(sentence, candidates=candidates, stop_words=None, min_df=1)
print(keywords)
kw_model = KeyBERT(domain_adapt=True)
kw_model.pre_train([doc], [['supervised', 'unsupervised']], lr=1e-3)
keywords = kw_model.extract_keywords(doc, top_n=10)
print(keywords)
kw_model = KeyBERT(zero_adapt=True)
kw_model.zeroshot_pre_train(['supervised', 'unsupervised'], adaptive_thr=0.15)
keywords = kw_model.extract_keywords(doc, top_n=10)
print(keywords)
kw_model = KeyBERT(domain_adapt=True, zero_adapt=True)
kw_model.pre_train([doc], [['supervised', 'unsupervised']], lr=1e-3)
kw_model.zeroshot_pre_train(['supervised', 'unsupervised'], adaptive_thr=0.15)
keywords = kw_model.extract_keywords(doc, top_n=10)
print(keywords)</code><button class="copy-button" onclick="copyToClipboard('usage-code')">Copy</button></pre>
<h2 id="citation">Citation</h2>
<pre><code>@misc{priyanshu2022adaptkeybertattentionbasedapproachfewshot,
title={AdaptKeyBERT: An Attention-Based approach towards Few-Shot & Zero-Shot Domain Adaptation of KeyBERT},
author={Aman Priyanshu and Supriti Vijay},
year={2022},
eprint={2211.07499},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2211.07499},
}</code><button class="copy-button" onclick="copyToClipboard('citation-code')">Copy</button></pre>
</div>
</div>
<script>
function copyToClipboard(elementId) {
const el = document.getElementById(elementId);
let text = el.textContent || el.innerText;
navigator.clipboard.writeText(text).then(function() {
console.log('Copying to clipboard was successful!');
}, function(err) {
console.error('Could not copy text: ', err);
});
}
</script>
</body>
</html>