Closed LiangqunLu closed 4 years ago
Beyond your modeling question, you might want to, if you haven't yet, think about the core data structure of TF ranking. TF Ranking operates on a Query Data Structure composed of a Context feature set and Example documents feature sets. You will have to consider how you will fit your recommender data into this paradigm. For example, typical recsys data is tuples of (user, item, click)
.
Also one issue you might encounter, is that a lot of recsys algorithms depend on global negative sampling. TF Ranking cannot do that directly, it only does sampling within the Query documents.
Thanks, Alex! I thought about that issue and I came up with a simple solution. For the Wide linear combination which I wanted to add, I just used TF-Ranking MLP structure and added another 1 dense layer as a linear cross. In this case, the input data is the exactly the same and I saved the trouble to modify the input. I just am not quite sure whether it is correct?
You seem to be referencing some previous example you are modifying: "the input data is the exactly the same" same as what?
Awkward.. It is exactly the same as TF-Ranking MLP structure. I used the example script tf_ranking_libsvm.py.
# In the TF-Ranking canned estimator
# This basically defines the feature columns, feature transformation, model structures, loss and metrics.
estimator = tf.estimator.Estimator(
model_fn=tfr.model.make_groupwise_ranking_fn(
group_score_fn=make_score_fn(),
group_size=FLAGS.group_size,
transform_fn=make_transform_fn(),
ranking_head=ranking_head ),
config=tf.estimator.RunConfig(
FLAGS.output_dir, save_checkpoints_steps=1000))
def make_score_fn():
'''
MLP structure is defined, which is supposed to handle feature columns, calculate parameters and return logits.
'''
So what I said above is that I made use of the TF-Ranking input. I only added a wide structure inside the TF-Ranking make_score_fn
Ok, so you are using libsvm as your input format. I think the example that comes w/ TF Ranking is a sample of MSLR-WEB30k, which is composed of rel, qid, features
tuples. I'm just curious how you will retrofit this data format for recsys data?
Yeah, I use libsvm input format that basically consists label/rel, queries and features. In my recsys project, it is pretty much the same except my labels are binary. The queries have various sizes of documents. However, my results using AUC and NDCG@3 are not satisfactory. Indeed, AUC is ~0.51 when I used listwise-based softmax loss.
what are your features? In typical recsys Latent Factor Model, it's just a User ID and an Item ID...
Oh I maybe mixed a little bit. My project is Learning to rank more precisely. The features in the libsvm format are item embeddings and use embeddings. But I used TF Ranking for the ranking and did not need to use matrix factorization at this moment.
Hi @eggie5
I read through quite a few closed issues and learned that TF-Ranking is working finally in your platform. If so, can I ask how you set up the parameters and what metrics are mainly evaluated? For the parameters, I mean the list of group-size, list_size, loss function, dropout_rate and so on. For the metrics, do you evaluate ARP or OPA or NDCG? Did you implement L2 regularization eventually? I understand these variables may vary on different projects. I appreciate it if I can learn some ideas from the successful examples.
I've used it for a few projects now. One recommender and one LTR system. For the recommender I build a Latent Factor model, a Deep Triplet Network. For the LTR system, I used a Two Tower Network. Most of my models are trained on clickstream data with binary feedback, so that helped drive some choice of loss and metrics like the pairwise losses and OPA were very relevant and interpretable. With clickstream feedback, MRR is possibly a meaningful metric, but you must realize that a typically great MRR of 0.5
is actually the lower-bound random-classifier in this case! Also in the binary feedback setting NDCG pretty much recovers MRR and tracks it in my experience. Regarding L2, I think there's an issue I started here w/ details.
Closing this discussion for now. A lot of good of advice here, we may use it for future reference.
Hi,
It is apparent that TF-Ranking is utilizing 3-layer MLP for learning to rank. So I am considering adding other complex models demonstrating abilities for recommender systems or CTR to TFR library. The Wide & Deep learning from Google 2016 uses a wide structure for memorization and a DNN for generation. I tried to add a linear combination part to _score_fn, then use both wide and deep logits to optimize for listwise-based softmax loss. I am pasting my code here. Can someone have a look and point out if I make any mistakes? Thanks!