Skip to content

Commit

Permalink
fix sort issue??
Browse files Browse the repository at this point in the history
  • Loading branch information
shifucun committed May 17, 2024
1 parent 1120c72 commit 9c8a0f7
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 37 deletions.
5 changes: 3 additions & 2 deletions nl_server/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ def _rank_vars(candidates: EmbeddingsResult,
# TODO: truncate the score based on model parameters from yaml
# Same model would produce different scores after certain decimals, so we want
# to round to 6 decimal places to make the score and rank stable.
for sv, score in sorted(sv2score.items(),
key=lambda item: (-int(item[1] * 1e6), item[0])):
sorted_score = sorted(sv2score.items(),
key=lambda item: (-round(item[1], 6), item[0]))
for sv, score in sorted_score:
result.svs.append(sv)
result.scores.append(score)

Expand Down
1 change: 0 additions & 1 deletion server/integration_tests/explore_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def run_detection(self,
d = ''
else:
d = re.sub(r'[ ?"]', '', q).lower()
print(d)
self.handle_response(q, resp, test_dir, d, failure, check_detection)

def run_detect_and_fulfill(self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"Parts": [
{
"CosineScore": [
0.925786018371582
0.9257855415344238
],
"QueryPart": "male population",
"SV": [
Expand Down Expand Up @@ -89,8 +89,8 @@
},
{
"CosineScore": [
0.8874198794364929,
0.872346818447113
0.8874201774597168,
0.8723466396331787
],
"QueryPart": "population",
"SV": [
Expand Down Expand Up @@ -123,7 +123,7 @@
},
{
"CosineScore": [
0.9170327186584473
0.917032778263092
],
"QueryPart": "population female population",
"SV": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
0.7139475345611572,
0.7126951217651367,
0.7112098932266235,
0.7085551023483276,
0.7085550427436829,
0.7085551023483276,
0.7080719470977783,
0.7078822255134583,
0.7053750157356262,
Expand Down Expand Up @@ -89,8 +89,8 @@
"dc/topic/sdg_1",
"Count_Household_FamilyHousehold_BelowPovertyLevelInThePast12Months",
"dc/4lvmzr1h1ylk1",
"dc/topic/sdg_2.1.2",
"dc/topic/FoodInsecurity",
"dc/topic/sdg_2.1.2",
"WHO/NCD_BMI_18A",
"Count_Household_WithoutFoodStampsInThePast12Months_AbovePovertyLevelInThePast12Months",
"WHO/NUTOVERWEIGHTPREV",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"Parts": [
{
"CosineScore": [
0.7976328730583191,
0.7976329326629639,
0.7576606273651123
],
"QueryPart": "factors like obesity",
Expand All @@ -96,7 +96,7 @@
},
{
"CosineScore": [
0.9999996423721313
0.9999995827674866
],
"QueryPart": "blood pressure",
"SV": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@
"Parts": [
{
"CosineScore": [
0.8084912300109863,
0.8080331683158875,
0.8044112324714661,
0.7984198331832886,
0.7966947555541992,
0.791584849357605,
0.7901858687400818,
0.7865886092185974,
0.7773175239562988,
0.8084911108016968,
0.8080331087112427,
0.8044111728668213,
0.7984197735786438,
0.7966943979263306,
0.7915846705436707,
0.790185809135437,
0.7865886688232422,
0.777317464351654,
0.776214063167572,
0.7629760503768921
],
Expand All @@ -86,8 +86,8 @@
},
{
"CosineScore": [
0.8318259119987488,
0.8029922842979431
0.8318256735801697,
0.8029924631118774
],
"QueryPart": "women phd",
"SV": [
Expand All @@ -104,7 +104,7 @@
{
"CosineScore": [
0.8433718681335449,
0.8265039920806885
0.8265039324760437
],
"QueryPart": "number poor hispanic women",
"SV": [
Expand All @@ -114,11 +114,11 @@
},
{
"CosineScore": [
0.7646969556808472,
0.7476687431335449,
0.73770672082901,
0.7362766861915588,
0.7305881977081299
0.7646968960762024,
0.7476688027381897,
0.7377066612243652,
0.7362767457962036,
0.7305883169174194
],
"QueryPart": "phd",
"SV": [
Expand Down Expand Up @@ -146,10 +146,10 @@
},
{
"CosineScore": [
0.8151504993438721,
0.7885995507240295,
0.7775553464889526,
0.7752051949501038
0.8151503801345825,
0.7885993719100952,
0.7775554060935974,
0.7752052545547485
],
"QueryPart": "hispanic women phd",
"SV": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"Parts": [
{
"CosineScore": [
0.8787485361099243
0.8787486553192139
],
"QueryPart": "show climate change",
"SV": [
Expand All @@ -50,7 +50,7 @@
},
{
"CosineScore": [
0.9999998807907104
1.0
],
"QueryPart": "drought",
"SV": [
Expand All @@ -65,10 +65,10 @@
"Parts": [
{
"CosineScore": [
0.7942370176315308,
0.794236958026886,
0.7929013967514038,
0.7586168050765991,
0.7583959102630615
0.758395791053772
],
"QueryPart": "show climate",
"SV": [
Expand All @@ -80,7 +80,7 @@
},
{
"CosineScore": [
0.8665127158164978
0.866512656211853
],
"QueryPart": "change drought",
"SV": [
Expand Down

0 comments on commit 9c8a0f7

Please sign in to comment.