API or web interface: API
Chatgpt version: gpt-3.5-turbo-16k
I want to implement an entity classification prompt that:
- provides a context of definitions of the types I want to classify entities into
- provides a context of definitions of the lists of entities I want to classify
- asks chatgpt to classify entities in the list into one of the types in the list. If no types are suitable, it should return ‘None’
- asks chatgpt to NOT create any types that are not in the list of types I provide.
I have written my prompt as follows, but the problem is requirement #4. Chat gpt still invent types that are not one of those I give. Is there any way I can improve my prompt?
(I currently do not use ‘system message’, though I read somewhere that this may help resolve the issue but I don’t understand how)
Prompt:
In the following, the 'Entity list' shows location entities and their definitions in the format of '- entity: definition text'. The 'Type list' shows location types and their definitions in the format of '- type: definition text'.
Read the lists and definitions. Then for each entity in the 'Entity list', choose the most specific type FROM THE 'Type list' ONLY, or output 'None' if no 'type' from the 'Type list' is suitable. DO NOT use any 'type' that are not in the 'Type list'. Format your response in JSON: "{entity 1: type 1, entity 2: type 2, ...}".
Entity list
- entity 1: ...
- entity 2: ...
Type list
- type 1: ...
- type 2:...
As an example, it returns ‘project’ for the entity below but I’d rather it returns ‘None’:
In the following, the 'Entity list' shows location entities and their definitions in the format of '- entity: definition text'. The 'Type list' shows location types and their definitions in the format of '- type: definition text'.
Read the lists and definitions. Then for each entity in the 'Entity list', choose the most specific type FROM THE 'Type list' ONLY, or output 'None' if no 'type' from the 'Type list' is suitable. DO NOT use any 'type' that are not in the 'Type list'. Format your response in JSON: "{entity 1: type 1, entity 2: type 2, ...}".
Entity list
- Coastal GasLink: Coastal GasLink is a pipeline project in Canada. It is a TC Energy natural gas pipeline under construction in British Columbia, Canada.
Type list
- City: A large and permanent human settlement, typically characterized by its size, population density, economic activity, and infrastructure.
- State/province/region: An administrative division within a country, typically smaller than the country itself, with its own government and authority.
- Country: A distinct territorial body or political entity with its own government, borders, and sovereignty recognized by other nations.