def load_latest_retriever(docs, featurizer):
  """Returns the latest Retriever and a model timestamp."""
  latest_embedder_path = export_utils.tfhub_export_path(
      model_dir=experiment_utils.FLAGS.model_dir,
      hub_prefix='encoded',
      module_prefix='embedder')
  if FLAGS.share_embedders:
    latest_query_embedder_path = latest_embedder_path
  else:
    latest_query_embedder_path = export_utils.tfhub_export_path(
        model_dir=experiment_utils.FLAGS.model_dir,
        hub_prefix='encoded',
        module_prefix='query_embedder')

  if latest_embedder_path is None:
    # The initial embedder module comes from the ICT codebase
    latest_embedder_path = FLAGS.initial_embedder_module
    latest_query_embedder_path = FLAGS.initial_embedder_module
    model_timestamp = 0
  else:
    model_timestamp_match = re.match('.+/export/.+/([0-9]+)/.+',
                                     latest_embedder_path)
    assert model_timestamp_match
    model_timestamp = int(model_timestamp_match.group(1))

  doc_embeds_path = os.path.join(latest_embedder_path, 'encoded/encoded.ckpt')

  retriever = load_retriever(
      query_embedder_path=latest_query_embedder_path,
      docs=docs,
      doc_embeds_path=doc_embeds_path,
      featurizer=featurizer)

  return (retriever, model_timestamp)
Returns the latest Retriever and a model timestamp.
language/realm/example_generator.py