Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
refactor(scorefn): move query coord into doc indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
jemmyshin committed Sep 17, 2019
1 parent 7626f0c commit d7c6572
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions gnes/score_fn/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,10 @@ class CoordDocScoreFn(CombinedScoreFn):
def __call__(self, last_score: 'gnes_pb2.Response.QueryResponse.ScoredResult.Score',
doc: 'gnes_pb2.Document',
*args, **kwargs):
d_weight = get_unary_score(value=self._cal_query_coord(last_score, doc),
total_chunks = len(doc.chunks)
recall_chunks = len(json.loads(last_score.explained)['operands'])
query_coord = 1 if total_chunks == 0 else recall_chunks / total_chunks
d_weight = get_unary_score(value=query_coord,
name='query coordination')
return super().__call__(last_score, d_weight)

@staticmethod
def _cal_query_coord(last_score: 'gnes_pb2.Response.QueryResponse.ScoredResult.Score',
doc: 'gnes_pb2.Document'):
total_chunks = len(doc.chunks)
recall_chunks = len(json.loads(last_score.explained)['operands'])
return recall_chunks / total_chunks

0 comments on commit d7c6572

Please sign in to comment.