Overview

How can we identify and clarify ambiguous information in the prompt?

Let’s say we are given the query: Was Ed Sheeran born on an odd month?

There are many ways a model might interpret an odd month:

  • February is odd because of an irregular number of days.
  • A month is odd if it has an odd number of days.
  • A month is odd if its numerical order in the year is odd (i.e. January is the 1st month).
Ambiguities might not always be so obvious!

To help the model better infer human intention from ambiguous prompts, we can ask the model to rephrase and respond (RaR) in a single step - which is demonstrated in this example.

This can also be implemented as two-step RaR:

  • Ask the model to rephrase the question to clarify any ambiguities.
  • Pass the rephrased question back to the model to generate the final response.

Example

<?php



$loader = require 'vendor/autoload.php';

$loader->add('Cognesy\\Instructor\\', __DIR__ . '../../src/');



use Cognesy\Instructor\Instructor;



class Response {

    public string $rephrasedQuestion;

    public string $answer;

}



class Disambiguate {

    private $prompt = <<<PROMPT

        Rephrase and expand the question to address any potential ambiguities, then respond.

        Question: {query}

        PROMPT;



    public function __invoke(string $query) : Response {

        return (new Instructor)->respond(

            messages: str_replace('{query}', $query, $this->prompt),

            responseModel: Response::class,

        );

    }

}



$response = (new Disambiguate)(query: "What is an object");



dump($response);

?>

References

  1. Rephrase and Respond: Let Large Language Models Ask Better Questions for Themselves