Skip to content

Commit

Permalink
Fmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
Narsil committed Dec 5, 2023
1 parent cb8a168 commit 5aa3a01
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions router/src/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,23 +525,22 @@ fn send_responses(
// Create last Token
let tokens_ = generation.tokens.expect("Non empty tokens in generation");
let n = tokens_.ids.len();
metrics::histogram!(
"tgi_request_skipped_tokens",
(n - 1) as f64
);
metrics::histogram!("tgi_request_skipped_tokens", (n - 1) as f64);
for (i, (((id, logprob), text), special)) in tokens_
.ids
.into_iter()
.zip(tokens_.logprobs.into_iter())
.zip(tokens_.texts.into_iter())
.zip(tokens_.is_special.into_iter()).enumerate() {
let token = Token {
id,
text,
logprob,
special,
};
let top_tokens = if let Some(top_tokens_) = generation.top_tokens.get(i){
.ids
.into_iter()
.zip(tokens_.logprobs.into_iter())
.zip(tokens_.texts.into_iter())
.zip(tokens_.is_special.into_iter())
.enumerate()
{
let token = Token {
id,
text,
logprob,
special,
};
let top_tokens = if let Some(top_tokens_) = generation.top_tokens.get(i) {
top_tokens_
.ids
.iter()
Expand All @@ -553,12 +552,12 @@ fn send_responses(
text: text.to_string(),
logprob,
special,
}).collect()
}else{
})
.collect()
} else {
vec![]

};
match (&generation.generated_text, i){
match (&generation.generated_text, i) {
(Some(generated_text), i) if i == n - 1 => {
// Generation has ended
stopped = true;
Expand Down

0 comments on commit 5aa3a01

Please sign in to comment.