Skip to content

Commit

Permalink
add max topk
Browse files Browse the repository at this point in the history
  • Loading branch information
glemaitre committed Feb 4, 2024
1 parent a4aebe7 commit e7011fb
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ async def websocket_endpoint(websocket: WebSocket):
agent.set_params(
retriever__threshold=payload["cutoff"],
retriever__min_top_k=payload["min_top_k"],
retriever__max_top_k=payload["max_top_k"],
)
stream, sources = agent(
prompt,
Expand Down
22 changes: 21 additions & 1 deletion app/static/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,17 @@ hr {
display: inline-block !important;
min-width: 30px;
}
#maxTopKLabel {
display: inline;
}
#maxTopKValue {
display: inline-block !important;
min-width: 30px;
}
}

.control-slider-form {
margin-bottom: 1rem;
margin-bottom: 0.5rem;
padding-left: 1rem;
padding-right: 1rem;
}
Expand Down Expand Up @@ -116,6 +123,19 @@ hr {
display: none;
}

#maxTopKSlider {
vertical-align: middle;
width:150px
}

#maxTopKValue {
display: none;
}

#maxTopKLabel {
display: none;
}

#messages {
padding-top: 20px;
padding-left:10px;
Expand Down
15 changes: 11 additions & 4 deletions app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
/ {{
conf.CONTEXT_TOKENS }}</span>
</div>
<div class="float-start">
<button title="Send" id="send" type="submit" class="btn btn-primary" disabled>{{
res.BUTTON_WAIT }}</button>
</div>
</div>
<div class="col-md-3">
<div class="form-group control-slider-form">
Expand All @@ -51,19 +55,22 @@
<label for="cutoffSlider">Relevance cut-off:</label><br />
<small class="form-text text-muted">Value: <span id="cutoffValue">{{
conf.CROSS_ENCODER_THRESHOLD }}</span></small><br />
<input type="range" class="form-control-range" id="cutoffSlider" min="0.0" max="5.0"
<input type="range" class="form-control-range" id="cutoffSlider" min="0.0" max="15.0"
step="0.05" value="{{ conf.CROSS_ENCODER_THRESHOLD }}">
</div>
<div class="form-group control-slider-form">
<label for="minTopKSlider">Minimum Top K:</label><br />
<small class="form-text text-muted">Value: <span id="minTopKValue">{{
conf.CROSS_ENCODER_MIN_TOP_K }}</span></small><br />
<input type="range" class="form-control-range" id="minTopKSlider" min="1" max="20"
<input type="range" class="form-control-range" id="minTopKSlider" min="1" max="30"
step="1" value="{{ conf.CROSS_ENCODER_MIN_TOP_K }}">
</div>
<div class="form-group control-slider-form">
<button title="Send" id="send" type="submit" class="btn btn-primary" disabled>{{
res.BUTTON_WAIT }}</button>
<label for="maxTopKSlider">Maximum Top K:</label><br />
<small class="form-text text-muted">Value: <span id="maxTopKValue">{{
conf.CROSS_ENCODER_MAX_TOP_K }}</span></small><br />
<input type="range" class="form-control-range" id="maxTopKSlider" min="1" max="30"
step="1" value="{{ conf.CROSS_ENCODER_MAX_TOP_K }}">
</div>
</div>
</div>
Expand Down
7 changes: 7 additions & 0 deletions app/templates/inference.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function sendQuery() {
var temp = document.getElementById('tempValue').innerHTML;
var cutoff = document.getElementById('cutoffValue').innerHTML;
var min_top_k = document.getElementById('minTopKValue').innerHTML;
var max_top_k = document.getElementById('maxTopKValue').innerHTML;

if (message === "") {
return;
Expand All @@ -62,6 +63,7 @@ function sendQuery() {
temperature: parseFloat(temp),
cutoff: parseFloat(cutoff),
min_top_k: parseInt(min_top_k),
max_top_k: parseInt(max_top_k),
}
ws.send(JSON.stringify(payload));
setButton("{{ res.BUTTON_PROCESSING }}", true)
Expand Down Expand Up @@ -243,6 +245,11 @@ document.addEventListener("DOMContentLoaded", function(event) {
min_top_k_slider.addEventListener("input", () => {
min_top_k_label.innerText=min_top_k_slider.value;
});
const max_top_k_slider = document.getElementById("maxTopKSlider");
const max_top_k_label = document.getElementById("maxTopKValue");
max_top_k_slider.addEventListener("input", () => {
max_top_k_label.innerText=max_top_k_slider.value;
});

const button = document.getElementById('send');
const tokenCount = document.getElementById("tokenCount");
Expand Down

0 comments on commit e7011fb

Please sign in to comment.