def retrieve_associative(
      self,
      query: str,
      k: int = 1,
  ) -> Sequence[str]:
    """Retrieve memories associatively.

    Args:
      query: a string to use for retrieval
      k: how many memories to retrieve

    Returns:
      List of strings corresponding to memories, sorted by cosine similarity
    """
    if not self._embedder:
      raise ValueError('Embedder must be set before calling the '
                       '`retrieve_associative` method.')

    if k <= 0:
      raise ValueError('Limit must be positive.')

    query_embedding = self._embedder(query)

    data = self._get_top_k_cosine(query_embedding, k)

    return self._pd_to_text(data)
Retrieve memories associatively.

    Args:
      query: a string to use for retrieval
      k: how many memories to retrieve

    Returns:
      List of strings corresponding to memories, sorted by cosine similarity
    
concordia/associative_memory/basic_associative_memory.py