Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Logit Transmission via gRPC: Relocating scores normalization … #72

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions alfred/fm/remote/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import json
import logging
import socket
import torch.nn.functional as F
from concurrent import futures
from typing import Optional, Union, Iterable, Tuple, Any, List

Expand Down Expand Up @@ -123,19 +122,11 @@ def _run_req_gen():
output = []
for response in self.stub.Run(_run_req_gen()):
if response.ranked:
logits = ast.literal_eval(response.logit)
candidates = list(logits.keys())
logit_values = torch.tensor(list(logits.values()))
probabilities = F.softmax(logit_values, dim=0)
scores = {
candidate: prob.item() for candidate, prob in zip(candidates, probabilities)
}
output.append(
RankedResponse(
**{
"prediction": response.message,
"scores": scores,
"logit": logits,
"scores": ast.literal_eval(response.logit),
"embeddings": bytes_to_tensor(response.embedding),
}
)
Expand Down Expand Up @@ -250,7 +241,7 @@ def Run(self, request_iterator, context):
yield query_pb2.RunResponse(
message=response.prediction,
ranked=True,
logit=str(response.logits),
logit=str(response.scores),
embedding=tensor_to_bytes(response.embeddings),
)
else:
Expand Down
Loading