mirror of
https://github.com/twitter/the-algorithm.git
synced 2025-01-02 23:51:53 +01:00
Merge 7380e27c93
into 72eda9a24f
This commit is contained in:
commit
4997f0f6d2
@ -40,7 +40,7 @@ import com.twitter.cr_mixer.module.similarity_engine.ProducerBasedUnifiedSimilar
|
||||
import com.twitter.cr_mixer.module.similarity_engine.SimClustersANNSimilarityEngineModule
|
||||
import com.twitter.cr_mixer.module.similarity_engine.TweetBasedUnifiedSimilarityEngineModule
|
||||
import com.twitter.cr_mixer.module.similarity_engine.TweetBasedQigSimilarityEngineModule
|
||||
import com.twitter.cr_mixer.module.similarity_engine.TweetBasedTwHINSimlarityEngineModule
|
||||
import com.twitter.cr_mixer.module.similarity_engine.TweetBasedTwHINSimilarityEngineModule
|
||||
import com.twitter.cr_mixer.module.similarity_engine.TweetBasedUserAdGraphSimilarityEngineModule
|
||||
import com.twitter.cr_mixer.module.similarity_engine.TweetBasedUserTweetGraphSimilarityEngineModule
|
||||
import com.twitter.cr_mixer.module.similarity_engine.TweetBasedUserVideoGraphSimilarityEngineModule
|
||||
@ -180,7 +180,7 @@ class CrMixerServer extends ThriftServer with Mtls with HttpServer with HttpMtls
|
||||
TripCandidateStoreModule,
|
||||
TwiceClustersMembersStoreModule,
|
||||
TweetBasedQigSimilarityEngineModule,
|
||||
TweetBasedTwHINSimlarityEngineModule,
|
||||
TweetBasedTwHINSimilarityEngineModule,
|
||||
TweetBasedUnifiedSimilarityEngineModule,
|
||||
TweetBasedUserAdGraphSimilarityEngineModule,
|
||||
TweetBasedUserTweetGraphSimilarityEngineModule,
|
||||
|
@ -21,7 +21,7 @@ import com.twitter.cr_mixer.similarity_engine.SimilarityEngine.SimilarityEngineC
|
||||
import com.twitter.cr_mixer.thriftscala.SimilarityEngineType
|
||||
import com.twitter.finagle.memcached.{Client => MemcachedClient}
|
||||
|
||||
object TweetBasedTwHINSimlarityEngineModule extends TwitterModule {
|
||||
object TweetBasedTwHINSimilarityEngineModule extends TwitterModule {
|
||||
@Provides
|
||||
@Named(ModuleNames.TweetBasedTwHINANNSimilarityEngine)
|
||||
def providesTweetBasedTwHINANNSimilarityEngine(
|
||||
|
@ -6,7 +6,7 @@ enum FeatureVal {
|
||||
FloatVector(Vec<f32>),
|
||||
}
|
||||
|
||||
// A Feture has a name and a value
|
||||
// A Feature has a name and a value
|
||||
// The name for now is 'id' of type string
|
||||
// Eventually this needs to be flexible - example to accomodate feature-id
|
||||
struct Feature {
|
||||
|
@ -149,7 +149,7 @@ public class EarlybirdFeatureSchemaMerger {
|
||||
* (This is done inside superroot)
|
||||
* @param requestContext the search request context
|
||||
* @param mergedResponse the merged result inside the superroot
|
||||
* @param realtimeResponse the realtime tier resposne
|
||||
* @param realtimeResponse the realtime tier response
|
||||
* @param protectedResponse the protected tier response
|
||||
* @param fullArchiveResponse the full archive tier response
|
||||
* @param statsPrefix
|
||||
|
@ -178,7 +178,7 @@ RawTensor TensorRecordReader::readStringTensor() {
|
||||
CHECK_THRIFT_TYPE(readByte(), TTYPE_STRING, "data_type");
|
||||
length = readInt32();
|
||||
// Store the current location of the byte stream.
|
||||
// Use this at to "deocde strings" at a later point.
|
||||
// Use this at to "decode strings" at a later point.
|
||||
data = getBuffer();
|
||||
for (int32_t i = 0; i < length; i++) {
|
||||
// Skip reading the strings
|
||||
|
@ -7,7 +7,7 @@ from tensorflow.python.ops import array_ops, math_ops
|
||||
def safe_div(numerator, denominator, name=None):
|
||||
"""
|
||||
Example usage: calculating NDCG = DCG / IDCG to handle cases when
|
||||
IDCG = 0 returns 0 instead of Infinity
|
||||
IDCG = 0 returns 0 instead of Infinity
|
||||
Do not use this dividing funciton unless it makes sense to your problem
|
||||
Divides two tensors element-wise, returns 0 if the denominator is <= 0.
|
||||
Args:
|
||||
@ -56,7 +56,7 @@ def cal_swapped_ndcg(label_scores, predicted_scores, top_k_int):
|
||||
Args:
|
||||
label_scores: a real `Tensor`.
|
||||
predicted_scores: a real `Tensor`, with dtype matching label_scores
|
||||
top_k_int: An int or an int `Tensor`.
|
||||
top_k_int: An int or an int `Tensor`.
|
||||
Returns:
|
||||
a `Tensor` that holds swapped NDCG by .
|
||||
"""
|
||||
@ -100,7 +100,7 @@ def _dcg_idcg(relevance_scores, cg_discount):
|
||||
relevance_scores: a real `Tensor`.
|
||||
cg_discount: a real `Tensor`, with dtype matching relevance_scores
|
||||
Returns:
|
||||
a `Tensor` that holds \\sum_{i=1}^k \frac{relevance_scores_k}{cg_discount}
|
||||
a `Tensor` that holds \\sum_{i=1}^k \frac{relevance_scores_k}{cg_discount}
|
||||
"""
|
||||
# cg_discount is safe
|
||||
dcg_k = relevance_scores / cg_discount
|
||||
@ -115,8 +115,8 @@ def _get_ranking_orders(label_scores, predicted_scores, top_k_int=1):
|
||||
predicted_scores: a real `Tensor`, with dtype matching label_scores
|
||||
top_k_int: an integer or an int `Tensor`.
|
||||
Returns:
|
||||
two `Tensors` that hold sorted_labels: the ground truth relevance socres
|
||||
and predicted_order: relevance socres based on sorted predicted_scores
|
||||
two `Tensors` that hold sorted_labels: the ground truth relevance scores
|
||||
and predicted_order: relevance scores based on sorted predicted_scores
|
||||
"""
|
||||
# sort predictions_scores and label_scores
|
||||
# size [batch_size/num of DataRecords, 1]
|
||||
@ -141,7 +141,7 @@ def _get_cg_discount(top_k_int=1):
|
||||
Args:
|
||||
top_k_int: An int or an int `Tensor`.
|
||||
Returns:
|
||||
a `Tensor` that holds \log_{2}(i + 1), i \in [1, k]
|
||||
a `Tensor` that holds \log_{2}(i + 1), i \in [1, k]
|
||||
"""
|
||||
log_2 = tf.log(tf.constant(2.0, dtype=tf.float32))
|
||||
# top_k_range needs to start from 1 to top_k_int
|
||||
|
Loading…
Reference in New Issue
Block a user