Skip to content

Commit 138bb51

Browse files
author
twitter-team
committed
[cr-mixer/home-mixer] Remove getLinearRankingParams in EarlybirdTensorflowBasedSimilarityEngine
Remove unused ranking params which are specified by services when making an Earlybird relevance search. For cr-mixer: since we always set useTensorflowRanking = true in EarlybirdSimilarityEngineRouter, we will only ever use the TensorFlowBasedScoringFunction for ranking search results. That function doesn't rely on any of the linear params specified in getLinearRankingParams, nor the boosts because we set applyBoosts = false in the request. These parameters are therefore strictly redundant. The parameters in home-mixer can be removed for essentially the same reason—the parameters are redundant given that we use the Tensorflow scoring function and don't apply boosts.
1 parent 3496189 commit 138bb51

File tree

2 files changed

+5
-60
lines changed

2 files changed

+5
-60
lines changed

cr-mixer/server/src/main/scala/com/twitter/cr_mixer/similarity_engine/EarlybirdTensorflowBasedSimilarityEngine.scala

+5-38
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import com.twitter.search.earlybird.thriftscala.EarlybirdService
66
import com.twitter.search.earlybird.thriftscala.ThriftSearchQuery
77
import com.twitter.util.Time
88
import com.twitter.search.common.query.thriftjava.thriftscala.CollectorParams
9-
import com.twitter.search.common.ranking.thriftscala.ThriftAgeDecayRankingParams
10-
import com.twitter.search.common.ranking.thriftscala.ThriftLinearFeatureRankingParams
119
import com.twitter.search.common.ranking.thriftscala.ThriftRankingParams
1210
import com.twitter.search.common.ranking.thriftscala.ThriftScoringFunctionType
1311
import com.twitter.search.earlybird.thriftscala.ThriftSearchRelevanceOptions
@@ -97,7 +95,7 @@ object EarlybirdTensorflowBasedSimilarityEngine {
9795
// Whether to collect conversation IDs. Remove it for now.
9896
// collectConversationId = Gate.True(), // true for Home
9997
rankingMode = ThriftSearchRankingMode.Relevance,
100-
relevanceOptions = Some(getRelevanceOptions(query.useTensorflowRanking)),
98+
relevanceOptions = Some(getRelevanceOptions),
10199
collectorParams = Some(
102100
CollectorParams(
103101
// numResultsToReturn defines how many results each EB shard will return to search root
@@ -116,13 +114,11 @@ object EarlybirdTensorflowBasedSimilarityEngine {
116114
// The specific values of recap relevance/reranking options correspond to
117115
// experiment: enable_recap_reranking_2988,timeline_internal_disable_recap_filter
118116
// bucket : enable_rerank,disable_filter
119-
private def getRelevanceOptions(useTensorflowRanking: Boolean): ThriftSearchRelevanceOptions = {
117+
private def getRelevanceOptions: ThriftSearchRelevanceOptions = {
120118
ThriftSearchRelevanceOptions(
121119
proximityScoring = true,
122120
maxConsecutiveSameUser = Some(2),
123-
rankingParams =
124-
if (useTensorflowRanking) Some(getTensorflowBasedRankingParams)
125-
else Some(getLinearRankingParams),
121+
rankingParams = Some(getTensorflowBasedRankingParams),
126122
maxHitsToProcess = Some(500),
127123
maxUserBlendCount = Some(3),
128124
proximityPhraseWeight = 9.0,
@@ -131,41 +127,12 @@ object EarlybirdTensorflowBasedSimilarityEngine {
131127
}
132128

133129
private def getTensorflowBasedRankingParams: ThriftRankingParams = {
134-
getLinearRankingParams.copy(
130+
ThriftRankingParams(
135131
`type` = Some(ThriftScoringFunctionType.TensorflowBased),
136132
selectedTensorflowModel = Some("timelines_rectweet_replica"),
133+
minScore = -1.0e100,
137134
applyBoosts = false,
138135
authorSpecificScoreAdjustments = None
139136
)
140137
}
141-
142-
private def getLinearRankingParams: ThriftRankingParams = {
143-
ThriftRankingParams(
144-
`type` = Some(ThriftScoringFunctionType.Linear),
145-
minScore = -1.0e100,
146-
retweetCountParams = Some(ThriftLinearFeatureRankingParams(weight = 20.0)),
147-
replyCountParams = Some(ThriftLinearFeatureRankingParams(weight = 1.0)),
148-
reputationParams = Some(ThriftLinearFeatureRankingParams(weight = 0.2)),
149-
luceneScoreParams = Some(ThriftLinearFeatureRankingParams(weight = 2.0)),
150-
textScoreParams = Some(ThriftLinearFeatureRankingParams(weight = 0.18)),
151-
urlParams = Some(ThriftLinearFeatureRankingParams(weight = 2.0)),
152-
isReplyParams = Some(ThriftLinearFeatureRankingParams(weight = 1.0)),
153-
favCountParams = Some(ThriftLinearFeatureRankingParams(weight = 30.0)),
154-
langEnglishUIBoost = 0.5,
155-
langEnglishTweetBoost = 0.2,
156-
langDefaultBoost = 0.02,
157-
unknownLanguageBoost = 0.05,
158-
offensiveBoost = 0.1,
159-
inTrustedCircleBoost = 3.0,
160-
multipleHashtagsOrTrendsBoost = 0.6,
161-
inDirectFollowBoost = 4.0,
162-
tweetHasTrendBoost = 1.1,
163-
selfTweetBoost = 2.0,
164-
tweetHasImageUrlBoost = 2.0,
165-
tweetHasVideoUrlBoost = 2.0,
166-
useUserLanguageInfo = true,
167-
ageDecayParams = Some(ThriftAgeDecayRankingParams(slope = 0.005, base = 1.0))
168-
)
169-
}
170-
171138
}

home-mixer/server/src/main/scala/com/twitter/home_mixer/util/earlybird/RelevanceSearchUtil.scala

-22
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,6 @@ object RelevanceSearchUtil {
1515
`type` = Some(scr.ThriftScoringFunctionType.TensorflowBased),
1616
selectedTensorflowModel = Some("timelines_rectweet_replica"),
1717
minScore = -1.0e100,
18-
retweetCountParams = Some(scr.ThriftLinearFeatureRankingParams(weight = 20.0)),
19-
replyCountParams = Some(scr.ThriftLinearFeatureRankingParams(weight = 1.0)),
20-
reputationParams = Some(scr.ThriftLinearFeatureRankingParams(weight = 0.2)),
21-
luceneScoreParams = Some(scr.ThriftLinearFeatureRankingParams(weight = 2.0)),
22-
textScoreParams = Some(scr.ThriftLinearFeatureRankingParams(weight = 0.18)),
23-
urlParams = Some(scr.ThriftLinearFeatureRankingParams(weight = 2.0)),
24-
isReplyParams = Some(scr.ThriftLinearFeatureRankingParams(weight = 1.0)),
25-
favCountParams = Some(scr.ThriftLinearFeatureRankingParams(weight = 30.0)),
26-
langEnglishUIBoost = 0.5,
27-
langEnglishTweetBoost = 0.2,
28-
langDefaultBoost = 0.02,
29-
unknownLanguageBoost = 0.05,
30-
offensiveBoost = 0.1,
31-
inTrustedCircleBoost = 3.0,
32-
multipleHashtagsOrTrendsBoost = 0.6,
33-
inDirectFollowBoost = 4.0,
34-
tweetHasTrendBoost = 1.1,
35-
selfTweetBoost = 2.0,
36-
tweetHasImageUrlBoost = 2.0,
37-
tweetHasVideoUrlBoost = 2.0,
38-
useUserLanguageInfo = true,
39-
ageDecayParams = Some(scr.ThriftAgeDecayRankingParams(slope = 0.005, base = 1.0)),
4018
selectedModels = Some(Map("home_mixer_unified_engagement_prod" -> 1.0)),
4119
applyBoosts = false,
4220
)

0 commit comments

Comments
 (0)