bootleg.tasks package

Submodules

bootleg.tasks.entity_gen_task module

Entity gen task definitions.

class bootleg.tasks.entity_gen_task.EntityGenOutput(normalize)[source]

Bases: object

Entity gen for output.

entity_output_func(intermediate_output_dict)[source]

Entity output func.

bootleg.tasks.entity_gen_task.create_task(args, len_context_tok)[source]

Return an EmmentalTask for entity encoder only.

Parameters
  • args – args

  • len_context_tok – number of tokens in the tokenizer

Returns: EmmentalTask for entity embedding extraction

bootleg.tasks.ned_task module

NED task definitions.

class bootleg.tasks.ned_task.DisambigLoss(normalize, temperature, entity_encoder_key)[source]

Bases: object

Disambiguation loss.

batch_cands_disambig_loss(intermediate_output_dict, Y)[source]

Return the entity disambiguation loss on prediction heads.

Parameters
  • intermediate_output_dict – output dict from the Emmental task flor

  • Y – gold labels

Returns: loss

batch_cands_disambig_output(intermediate_output_dict)[source]

Return the probs for a task in Emmental.

Parameters

intermediate_output_dict – output dict from Emmental task flow

Returns: NED probabilities for candidates (B x M x K)

disambig_loss(intermediate_output_dict, Y)[source]

Return the entity disambiguation loss on prediction heads.

Parameters
  • intermediate_output_dict – output dict from the Emmental task flor

  • Y – gold labels

Returns: loss

disambig_output(intermediate_output_dict)[source]

Return the probs for a task in Emmental.

Parameters

intermediate_output_dict – output dict from Emmental task flow

Returns: NED probabilities for candidates (B x M x K)

bootleg.tasks.ned_task.create_task(args, use_batch_cands, len_context_tok, slice_datasets=None, entity_emb_file=None)[source]

Return an EmmentalTask for named entity disambiguation (NED).

Parameters
  • args – args

  • use_batch_cands – use batch candidates for training

  • len_context_tok – length of the context tokenizer

  • slice_datasets – slice datasets used in scorer (default None)

  • entity_emb_file – file for pretrained entity embeddings - used for EVAL only

Returns: EmmentalTask for NED

Module contents

Task init.