KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums KDB.AI Get the cosine similarity scores along with the retrieved docs Reply To: Get the cosine similarity scores along with the retrieved docs

  • megan_mcp

    Administrator
    May 20, 2024 at 4:38 pm

    Hi @Sosycs

    As an example I’ve used snippets from our Document Search sample (screenshot below):

    Simply change the metric to: “metric” : “CS”.

    To see the distance print the results of the similarity search (the distance will be in a column in the result called “__nn_distance”:

    print(table.search(query_vector, n=3))

    Also take a look at our documentation on cosine similarity for extra help – KDB.AI Similarity Metrics – Documentation (kx.com)

    Hope this helps!

    Thanks,

    Megan