{"record":{"id":"33996f90f7bef06e","repo":"tensorflow/models","slug":"at-most-one-of-hub-module-url-and-init-checkpoi","errorCode":null,"errorMessage":"At most one of `hub_module_url` and `init_checkpoint` can be specified.","messagePattern":"At most one of `hub_module_url` and `init_checkpoint` can be specified\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/tasks/dual_encoder.py","lineNumber":77,"sourceCode":"  # be specified.\n  init_checkpoint: str = ''\n  hub_module_url: str = ''\n  # Defines the concrete model config at instantiation time.\n  model: ModelConfig = dataclasses.field(default_factory=ModelConfig)\n  train_data: cfg.DataConfig = dataclasses.field(default_factory=cfg.DataConfig)\n  validation_data: cfg.DataConfig = dataclasses.field(\n      default_factory=cfg.DataConfig\n  )\n\n\n@task_factory.register_task_cls(DualEncoderConfig)\nclass DualEncoderTask(base_task.Task):\n  \"\"\"Task object for dual encoder.\"\"\"\n\n  def build_model(self):\n    \"\"\"Interface to build model. Refer to base_task.Task.build_model.\"\"\"\n    if self.task_config.hub_module_url and self.task_config.init_checkpoint:\n      raise ValueError('At most one of `hub_module_url` and '\n                       '`init_checkpoint` can be specified.')\n    if self.task_config.hub_module_url:\n      encoder_network = utils.get_encoder_from_hub(\n          self.task_config.hub_module_url)\n    else:\n      encoder_network = encoders.build_encoder(self.task_config.model.encoder)\n\n    # Currently, we only supports bert-style dual encoder.\n    return models.DualEncoder(\n        network=encoder_network,\n        max_seq_length=self.task_config.model.max_sequence_length,\n        normalize=self.task_config.model.normalize,\n        logit_scale=self.task_config.model.logit_scale,\n        logit_margin=self.task_config.model.logit_margin,\n        output='logits')\n\n  def build_losses(self, labels, model_outputs, aux_losses=None) -> tf.Tensor:\n    \"\"\"Interface to compute losses. Refer to base_task.Task.build_losses.\"\"\"","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/tasks/dual_encoder.py#L59-L95","documentation":"Error \"At most one of `hub_module_url` and `init_checkpoint` can be specified.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/tasks/dual_encoder.py:77 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}