Module Contents


TFKNRM_Class(extractor, config, **kwargs)
TFKNRM(config=None, provide=None, share_dependency_objects=False, build=True) Base class for profane modules.
class capreolus.reranker.TFKNRM.TFKNRM_Class(extractor, config, **kwargs)[source]

Bases: tensorflow.keras.Model

get_score(self, doc_tok, query_tok, query_idf)[source]
call(self, x, **kwargs)[source]

During training, both posdoc and negdoc are passed During eval, both posdoc and negdoc are passed but negdoc would be a zero tensor Whether negdoc is a legit doc tensor or a dummy zero tensor is determined by which sampler is used (eg: sampler.TrainDataset) as well as the extractor (eg: EmbedText)

Unlike the pytorch KNRM model, KNRMTF accepts both the positive and negative document in its forward pass. It scores them separately and returns the score difference (i.e posdoc_score - negdoc_score).

class capreolus.reranker.TFKNRM.TFKNRM(config=None, provide=None, share_dependency_objects=False, build=True)[source]

Bases: capreolus.reranker.Reranker

Base class for profane modules. Module construction proceeds as follows: 1) Any config options not present in config are filled in with their default values. Config options and their defaults are specified in the config_spec class attribute. 2) Any dependencies declared in the dependencies class attribute are recursively instantiated. If the dependency object is present in provide, this object will be used instead of instantiating a new object for the dependency. 3) The module object’s config variable is updated to reflect the configs of its dependencies and then frozen.

After construction is complete, the module’s dependencies are available as instance variables: self.`dependency key`.

  • config – dictionary containing a config to apply to this module and its dependencies
  • provide – dictionary mapping dependency keys to module objects
  • share_dependency_objects – if true, dependencies will be cached in the registry based on their configs and reused. See the share_objects argument of ModuleBase.create.
module_name = TFKNRM[source]