Skip to content

Example Select Words Order#

To learn about the basics of creating an order, please refer to the quickstart guide.

A big part of image generation is following the prompt accurately. Rapidata makes it easy to get feedback on what parts of the prompt the model is struggling with. In this example, we will create an order where annotators are asked to select the words that are not correctly depicted in the image.

from rapidata import RapidataClient

IMAGE_URLS = ['https://assets.rapidata.ai/dalle-3_244_0.jpg',
        'https://assets.rapidata.ai/dalle-3_30_1.jpg',
        'https://assets.rapidata.ai/dalle-3_268_2.jpg',
        'https://assets.rapidata.ai/dalle-3_26_2.jpg']

PROMPTS = ['The black camera was next to the white tripod.',
        'Four cars on the street.',
        'Car is bigger than the airplane.',
        'One cat and two dogs sitting on the grass.']

PROMPTS_WITH_NO_MISTAKES = [prompt + " [No_mistakes]" for prompt in PROMPTS] # selection is split based on spaces

if __name__ == "__main__":
    rapi = RapidataClient()
    order = rapi.order.create_select_words_order(
        name="Detect Mistakes in Image-Text Alignment",
        instruction="The image is based on the text below. Select mistakes, i.e., words that are not aligned with the image.",
        datapoints=IMAGE_URLS,
        responses_per_datapoint=15,
        sentences=PROMPTS_WITH_NO_MISTAKES,
        filters=[
            rapi.order.filters.language(["en"]),
        ],
        validation_set_id="6761a86eef7af86285630ea8" # in this example, the validation set has already been created
    ).run()
    order.display_progress_bar()
    result = order.get_results()
    print(result)

To preview the order and see what the annotators see, you can run the following code:

order.preview()

To open the order in the browser, you can run the following code:

order.view()