Miscellaneous
Consistent values of arbitrary properties
Zero-Shot Prompting
Few-Shot Prompting
Thought Generation
Miscellaneous
- Arbitrary properties
- Consistent values of arbitrary properties
- Chain of Summaries
- Chain of Thought
- Single label classification
- Multiclass classification
- Entity relationship extraction
- Handling errors
- Limiting the length of lists
- Reflection Prompting
- Restating instructions
- Ask LLM to rewrite instructions
- Expanding search queries
- Summary with Keywords
- Reusing components
- Using CoT to improve interpretation of component data
Miscellaneous
Consistent values of arbitrary properties
Overview
For multiple records containing arbitrary properties, instruct LLM to get more consistent key names when extracting properties.
Example
<?php
$loader = require 'vendor/autoload.php';
$loader->add('Cognesy\\Instructor\\', __DIR__.'../../src/');
use Cognesy\Instructor\Instructor;
class UserDetail
{
public int $id;
public string $key;
public string $value;
}
class UserDetails
{
/**
* @var UserDetail[] Extract information for multiple users.
* Use consistent key names for properties across users.
*/
public array $users;
}
$text = "Jason is 25 years old. He is a Python programmer.\
Amanda is UX designer.\
John is 40yo and he's CEO.";
$list = (new Instructor)->respond(
messages: [['role' => 'user', 'content' => $text]],
responseModel: UserDetails::class,
);
dump($list);
assert(!empty($list->users));
?>