This guide will help you monitor your retrieval accuracy with only one line of code.

If you just want to improve your pipeline accuracy by 35% too, check out the filter quick start guide

1. Create an Account

Go to https://www.pongo.ai/ to create an account- be sure to save the API key generated during onboarding or get one from the API keys page

2. Install the Pongo Client

pip install --upgrade pongo-python

3. Observe with Pongo

Run your pipeline and pass the top ~200 results to Pongo along with your query, then we’ll analyze the relevance of the top 5 results in the background.

import pongo

#Replace the key with your actual API key
pongo_client = pongo.PongoClient("YOUR_PONGO_KEY")

#
queries = ["What color are apples?", "Who made the first mobile phone?", "How many hearts do squids have?"]

#pass in the top ~100-200 results from your existing pipeline, passing more results will catch more edge cases
lists_of_results = [
    # Apples results
    [
        'Oranges are normally orange, unlike apples',
        'Grapes can be purple or green',
        'Apples can be green or red.',
        "If an apple is brown, it's best not to eat it."
    ],
    # Mobile phone results
    [
        'Apple released the first iPhone on June 29, 2007',
        'The telephone was invented by Alexander Graham Bell in 1876.',
        'The first long-distance telephone call was made in August 1876, between Brantford and Paris, Ontario',
        'The newest iPhone models are the iPhone 15, it was released on September 22, 2023',
        'The first handheld mobile phone was the Motorola DynaTAC 8000X',
        'Martin Cooper, an engineer at Motorola, is credited with inventing the first handheld cellular mobile phone and making the first mobile phone call'
    ],
    # Squids results
    [
        'Octopuses have three hearts.',
        "A squid's systemic (main) heart has three chambers.",
        'The creature with the most hearts is the earthworm, with 10.',
        'Squids have three hearts- one systemic (main) heart and two branchial hearts'
    ]
]

for i in range(len(queries)):
    #You'll get an email report once the queries are finished processing and they'll be available for view and download through the analytics dashboard.
    #You'll be able to query observability results by the log_metadata field
    observe_result = pongo_client.observe(docs=lists_of_results[i], query=queries[i], log_metadata={'source': 'Pongo Tutorial'})    
    print(observe_result.json())

4. Check your observability results

Check out How we calculate accuracy to learn how our algorithm works

After a couple minutes, you’ll be able to view your results on the analytics dashboard. You’ll also get your first weekly email report!

5. Set up alerts

For high-performance applications, you can use the alerts page to get notifications when queries with certain log metadata return with no relevant context. (learn more)