hopwise.model.ranker¶
Common ranker in recommender system
Classes¶
Base class for sequence score rankers. |
|
Ranker that uses the cumulative sequence score of the final max_new_tokens predicted tokens to rank sequences. |
|
Ranker that uses the sequence score of the beam search to rank sequences. |
|
Ranker that uses the sequence score of the beam search to rank sequences. |
Module Contents¶
- class hopwise.model.ranker.BaseSequenceScoreRanker(tokenizer, used_ids, item_num, topk=10)[source]¶
Base class for sequence score rankers.
- tokenizer¶
- used_ids¶
- item_num¶
- topk = 10¶
- class hopwise.model.ranker.RankerLP(tokenizer, kg_positives, K=10, max_new_tokens=24)[source]¶
- tokenizer¶
- kg_positives¶
- topk¶
- topk_sequences¶
- max_new_tokens = 24¶
- K = 10¶
- class hopwise.model.ranker.CumulativeSequenceScoreRanker(tokenizer, used_ids, item_num, topk=10)[source]¶
Bases:
BaseSequenceScoreRanker
Ranker that uses the cumulative sequence score of the final max_new_tokens predicted tokens to rank sequences.
- class hopwise.model.ranker.SampleSearchSequenceScoreRanker(tokenizer, used_ids, item_num, topk=10)[source]¶
Bases:
BaseSequenceScoreRanker
Ranker that uses the sequence score of the beam search to rank sequences.
To use only if do_sample = True and if topk and topp are set.
- get_sequences(generation_outputs, max_new_tokens=24)[source]¶
generation_outputs is a dataclass with 3 fields: ‘sequences’, ‘scores’ and ‘past_key_values’ sequences is a tensor of shape (num_return_sequences, sequence_length) scores is a tuple of len (|generated tokens|) where each element is a tensor
that says the logits at each timestep before applying topk and topp
- class hopwise.model.ranker.BeamSearchSequenceScoreRanker(tokenizer, used_ids, item_num, topk=10)[source]¶
Bases:
BaseSequenceScoreRanker
Ranker that uses the sequence score of the beam search to rank sequences.