Skip to content

Commit 7fe95dd

Browse files
authored
Merge pull request #70 from beclab/feat/similarity-experiment
fix: not print highest score when there is no valid algorithm item
2 parents 6b6a3c2 + 89d6bf2 commit 7fe95dd

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

train-rank/src/knowledgebase_api.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,7 @@ namespace knowledgebase
11251125
http_request req(methods::GET);
11261126
req.set_request_uri(U(builder.to_string()));
11271127
std::string blf_user_env_value = getEnvString(BFL_USER_ENV_NAME, "");
1128+
LOG(DEBUG) << "blf_user_env_value " << blf_user_env_value << std::endl;
11281129
req.headers()
11291130
.add(U(X_BFL_USER_HEADER), U(blf_user_env_value));
11301131

@@ -1148,9 +1149,12 @@ namespace knowledgebase
11481149
}
11491150
LOG(DEBUG) << "code " << code << " message " << message << std::endl;
11501151
if (v.has_string_field("data")) {
1151-
std::string last_rankt_time_data = v.at("data").as_string();
1152-
convertStringTimestampToInt64(last_rankt_time_data,
1152+
std::string last_extractor_time_data = v.at("data").as_string();
1153+
LOG(DEBUG) << "last_extractor_time_data_str " << last_extractor_time_data
1154+
<< std::endl;
1155+
convertStringTimestampToInt64(last_extractor_time_data,
11531156
&last_extractor_time);
1157+
LOG(DEBUG) << "compelete last_extractor_time " << last_extractor_time << std::endl;
11541158
}
11551159
} catch (http_exception const &e) {
11561160
LOG(ERROR) << "Error exception " << e.what() << std::endl;

train-rank/src/rssrank.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,7 @@ namespace rssrank
10381038
int embedding_dimension = getCurrentEmbeddingDimension();
10391039
std::vector<double> recall_user_embedding = knowledgebase::init_user_embedding(embedding_dimension);
10401040
knowledgebase::updateRecallUserEmbedding(current_srouce_name, recall_user_embedding, current_rank_time);
1041+
10411042
for (const auto &current_item : not_impressioned_algorithm_to_entry)
10421043
{
10431044
std::optional<Entry> temp_entry =
@@ -1080,15 +1081,24 @@ namespace rssrank
10801081

10811082
std::sort(algorithm_integer_id_to_score.begin(), algorithm_integer_id_to_score.end(), [](const std::pair<int, double> &a, const std::pair<int, double> &b)
10821083
{ return a.second > b.second; });
1084+
1085+
if (id_to_score_with_meta.size() == 0)
1086+
{
1087+
LOG(ERROR) << "rankByTimeForColdStart no algorithm to rank" << std::endl;
1088+
}
10831089
if (FLAGS_verbose)
10841090
{
10851091
std::vector<std::pair<std::string, float>> sorted_algorithm_to_score = knowledgebase::rankScoreMetadata(id_to_score_with_meta);
10861092
for (const auto &pr : sorted_algorithm_to_score)
10871093
{
10881094
LOG(INFO) << "Algorithm [" << pr.first << "] score [" << pr.second << "]" << std::endl;
10891095
}
1090-
std::cout << "max " << sorted_algorithm_to_score[0].second << " min " << sorted_algorithm_to_score[sorted_algorithm_to_score.size() - 1].second << std::endl;
1091-
}
1096+
if (sorted_algorithm_to_score.size() > 0)
1097+
{
1098+
std::cout << "Algorithm [" << sorted_algorithm_to_score[0].first << "] max score [" << sorted_algorithm_to_score[0].second << "]" << std::endl;
1099+
}
1100+
}
1101+
10921102
if (FLAGS_upload_score)
10931103
{
10941104
LOG(INFO) << "score with metadata update to knowledge " << std::endl;

train-rank/test/knowledge_api_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ TEST(KnowledgeApiTest, TestGetLastExtractTime)
189189
// --gtest_filter=KnowledgeApiTest.TestGetLastExtractTime
190190
initDevelop();
191191
init_log();
192-
int64_t last_extractor_time = knowledgebase::getLastExtractorTime("_r4business");
192+
int64_t last_extractor_time = knowledgebase::getLastExtractorTime("r4business");
193193
std::cout << "last_extractor_time " << last_extractor_time << std::endl;
194194
}
195195

0 commit comments

Comments
 (0)