Skip to content

Modified NER prompt for keyword position [WIP] #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions config/ner.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const ner = ({
text_input = "",
description = "",
position,
domain = "",
labels = "",
examples = [],
Expand All @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions examples/data/optimized_ner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion examples/nerExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);