I am unable to obtain the desired response from the model I have trained.
i have this datasets for example
{'prompt':'what are you','completions':'I am a ABC Company Support AI'}
{'prompt':'who are you','completions':'I am a ABC Company Support AI'}
and train a model "davinci"
then i use this PHP Code for my testing
// Load the OpenAI API key from a file
$api_key = 'sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
// Set the model ID and fine-tuned model ID
$model_id = 'davinci';
$ft_model_id = 'davinci:ft-abc-company:dtr-ft1-2023-03-01-00-28-38';
// Define the prompt to send to the model
$prompt = 'what are you';
// Define the maximum number of tokens to generate
$max_tokens =200;
// Define the temperature of the response
$temperature = 0.5;
// Define the number of completions to generate
$n = 1;
// Define the stop sequence to use
$stop_sequence = null;
// Define the API endpoint
$endpoint = 'https://api.openai.com/v1/engines/'.$ft_model_id.'/completions';
// Define the API request headers
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $api_key
];
// Define the API request body
$body = [
'prompt' => $prompt,
'max_tokens' => $max_tokens,
'temperature' => $temperature,
'n' => $n,
'stop' => $stop_sequence
];
// Convert the body to JSON
$body_json = json_encode($body);
// Send the API request
$ch = curl_init($endpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body_json);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
exit();
}
// Decode the API response
$response_data = json_decode($response, true);
// Get the first completion
$completion = @$response_data['choices'][0]['text'];
print_r(@$response_data); echo '
';
//Check if the response is in the training data
$is_in_training_data = false;
if(@$response_data['choices'][0]['answers']){
foreach (@$response_data['choices'][0]['answers'] as $answer) {
if (strpos($completion, $answer['text']) !== false) {
$is_in_training_data = true;
break;
}
}
}
// Print the completion or 'I do not know your question.'
if ($is_in_training_data) {
echo $completion;
} else {
echo 'I do not know your question.';
}
// Close the cURL handle
curl_close($ch);
However, the answers are not being returned in the response array, only in the text array, and the answers are not related to the questions.