From 9c33fa48e94439ad237b314d8b28475b69c55e3e Mon Sep 17 00:00:00 2001 From: arionrefat Date: Sat, 25 Mar 2023 19:13:02 +0600 Subject: [PATCH] modified prompt --- config/ner.js | 7 +++++-- examples/data/optimized_ner.js | 4 ++++ examples/nerExample.js | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/config/ner.js b/config/ner.js index c424e68..bfa5359 100644 --- a/config/ner.js +++ b/config/ner.js @@ -1,6 +1,7 @@ export const ner = ({ text_input = "", description = "", + position, domain = "", labels = "", examples = [], @@ -14,13 +15,15 @@ export const ner = ({ const _example = examples && examples.length > 0 ? `Examples: ${examples.map( - (ex) => `Input ${ex.sentence} Output [${ex.sentence}]` + (ex) => `Input ${ex[0].E} Output [${ex[0].T}]` )}` : ""; return ` ${description} You are a highly intelligent and accurate ${_domain} Named-entity recognition(NER) system. You take Passage as input and your task is to recognize and extract specific types of ${_domain} named entities in that given passage and classify into a set of ${_label}. - Your output format is only {{ output_format|default("[{{'T': type of entity from predefined entity types, 'E': entity in the input text}},...,{{'branch' : Appropriate branch of the passage ,'group': Appropriate Group of the passage}}]") }} form, no other form. + + Your output format is ${position ? `{{ output_format|default("[{{'T': type of entity from predefined entity types, 'E': entity in the input text}},...,{{'branch' : Appropriate branch of the passage ,'group': Appropriate Group of the passage}},...,{{ 'start' : start position of the entity, 'end' : end position of the entity}}]") }}` : `{{ output_format|default("[{{'T': type of entity from predefined entity types, 'E': entity in the input text}},...,{{'branch' : Appropriate branch of the passage ,'group': Appropriate Group of the passage}}]") }}`} form, otherwise no other form. + ${_example} Input: ${text_input} Output: diff --git a/examples/data/optimized_ner.js b/examples/data/optimized_ner.js index 8d82c04..81506cd 100644 --- a/examples/data/optimized_ner.js +++ b/examples/data/optimized_ner.js @@ -5,10 +5,14 @@ export const nerData = { { E: "DISEASE", T: "Alzheimer's disease", + start: 0, + end: 10 }, { E: "BIOMARKER", T: "Amyloid β42", + start: 5, + end: 16 }, { E: "BIOMARKER", diff --git a/examples/nerExample.js b/examples/nerExample.js index e0af3da..ad1a5aa 100644 --- a/examples/nerExample.js +++ b/examples/nerExample.js @@ -3,7 +3,7 @@ import { OpenAI } from "../models/openai.js"; import { Prompter } from "../promptify/index.js"; import { nerData } from "../examples/data/optimized_ner.js"; -const model = OpenAI("api-key"); +const model = OpenAI("openai-api"); const examples = nerData.samples[0].data; const firstExample = examples.slice(0, 3); @@ -12,9 +12,12 @@ const prompt = ner({ description: "Medicine NER Expert", domain: "medicine", labels: "", + position: true, examples: [firstExample], }); +console.log(prompt) + const result = await Prompter(model, prompt, "text-davinci-003"); console.log(result);