├── examples
├── turboExample.js
├── tabularExample.js
├── nerExample.js
├── binaryClassificationExample.js
├── relationExtractionExample.js
├── qaExample.js
├── data
│ ├── relation_extraction.js
│ ├── multiclass.js
│ ├── sql.js
│ ├── binary.js
│ ├── tabular.js
│ ├── paragraph.js
│ ├── mutliLevelClassification.js
│ ├── optimized_multilabel.js
│ ├── summary.js
│ ├── qa.js
│ └── optimized_ner.js
├── sqlExample.js
├── summaryExample.js
└── multiLevelClassificationExample.js
├── .gitignore
├── models
└── openai.js
├── config
├── summarization.js
├── multiLevelClassification.js
├── binaryClassification.js
├── tabular.js
├── qa.js
├── relationExtraction.js
├── ner.js
└── sql.js
├── package.json
├── promptify
└── index.js
├── README.md
└── License
/examples/turboExample.js:
--------------------------------------------------------------------------------
1 | import { Prompter } from "../promptify/index.js";
2 |
3 | const prompt = [
4 | { role: "system", content: "you are an helpful assistat" },
5 | { role: "user", content: "hey what is your purpose?" },
6 | ];
7 |
8 | const apiKey = "api-key";
9 |
10 | const result = await Prompter(undefined, prompt, "gpt-3.5-turbo", apiKey);
11 |
12 | console.log(result);
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 | yarn.lock
10 |
11 | node_modules
12 | dist
13 | dist-extension
14 | dist-ssr
15 | *.local
16 |
17 | # Editor directories and files
18 | .vscode/*
19 | !.vscode/extensions.json
20 | .idea
21 | .DS_Store
22 | *.suo
23 | *.ntvs*
24 | *.njsproj
25 | *.sln
26 | *.sw?
27 |
--------------------------------------------------------------------------------
/models/openai.js:
--------------------------------------------------------------------------------
1 | // const { Configuration, OpenAI } = require("openai");
2 | import { Configuration, OpenAIApi } from "openai";
3 |
4 | export const OpenAI = (key) => {
5 | if (!key) throw new Error("Open AI key is required");
6 |
7 | // Logic to validate `apiKey`
8 |
9 | const config = new Configuration({
10 | apiKey: key,
11 | });
12 |
13 | const openai = new OpenAIApi(config);
14 |
15 | return openai;
16 | };
17 |
--------------------------------------------------------------------------------
/examples/tabularExample.js:
--------------------------------------------------------------------------------
1 | import { tabular } from "../config/tabular.js";
2 | import { OpenAI } from "../models/openai.js";
3 | import { Prompter } from "../promptify/index.js";
4 | import { tabularData } from "../examples/data/tabular.js";
5 |
6 | const model = OpenAI("api-key");
7 | const examples = tabularData.samples;
8 | const firstExample = examples.slice(0, 5);
9 |
10 | const prompt = tabular({
11 | text_input: examples[6],
12 | description: "Tabular Data Extraction",
13 | examples: firstExample,
14 | });
15 |
16 | const result = await Prompter(model, prompt, "text-davinci-003");
17 |
18 | console.log(result);
19 |
--------------------------------------------------------------------------------
/examples/nerExample.js:
--------------------------------------------------------------------------------
1 | import { ner } from "../config/ner.js";
2 | import { OpenAI } from "../models/openai.js";
3 | import { Prompter } from "../promptify/index.js";
4 | import { nerData } from "../examples/data/optimized_ner.js";
5 |
6 | const model = OpenAI("api-key");
7 | const examples = nerData.samples[0].data;
8 | const firstExample = examples.slice(0, 3);
9 |
10 | const prompt = ner({
11 | text_input: "I have alzheimers diease, I need medicine for it",
12 | description: "Medicine NER Expert",
13 | domain: "medicine",
14 | labels: "",
15 | examples: [firstExample],
16 | });
17 |
18 | const result = await Prompter(model, prompt, "text-davinci-003");
19 |
20 | console.log(result);
21 |
--------------------------------------------------------------------------------
/examples/binaryClassificationExample.js:
--------------------------------------------------------------------------------
1 | import { binaryClassification } from "../config/binaryClassification.js";
2 | import { OpenAI } from "../models/openai.js";
3 | import { Prompter } from "../promptify/index.js";
4 | import { binaryData } from "../examples/data/binary.js";
5 |
6 | const model = OpenAI("api-key");
7 | const examples = binaryData;
8 | const firstExample = examples.slice(0, 5);
9 |
10 | const prompt = binaryClassification({
11 | text_input: examples[6].text,
12 | description: "Binary Classification",
13 | examples: firstExample,
14 | labels: "positive, negative",
15 | });
16 |
17 | const result = await Prompter(model, prompt, "text-davinci-003");
18 |
19 | console.log(result);
20 |
--------------------------------------------------------------------------------
/config/summarization.js:
--------------------------------------------------------------------------------
1 | export const summarization = ({ description = '', examples = [], context = '' }) => {
2 | if (!context) throw new Error('context is required');
3 |
4 | const _example =
5 | examples && examples.length > 0
6 | ? `Examples: ${examples.map(
7 | (ex) => `Input ${ex.context} Output [${ex.extracted_answer}]`
8 | )}`
9 | : '';
10 | return `
11 | ${description}
12 | You are a highly intelligent and accurate passage summarizing bot. You take the above passage as input and return the summary from the Paragraph. Your output format is only {{ output_format|default("{'Summary' : Extracted Answer}") }} form, no other form.
13 | ${_example}
14 | Context: ${context}
15 | Output:
16 | `;
17 | };
18 |
--------------------------------------------------------------------------------
/examples/relationExtractionExample.js:
--------------------------------------------------------------------------------
1 | import { relationExtraction } from "../config/relationExtraction.js";
2 | import { OpenAI } from "../models/openai.js";
3 | import { Prompter } from "../promptify/index.js";
4 | import { relationExtractionData } from "../examples/data/relation_extraction.js";
5 |
6 | const model = OpenAI("api-key");
7 | const examples = relationExtractionData;
8 |
9 | const prompt = relationExtraction({
10 | text_input: "Eren is a Person. Working for XYZ company, his job title is Software Engineer. He lives in Bielefeld, Germany",
11 | description: "Relation Extraction",
12 | domain: "Personal Information",
13 | examples: examples,
14 | });
15 |
16 | const result = await Prompter(model, prompt, "text-davinci-003");
17 |
18 | console.log(result);
--------------------------------------------------------------------------------
/config/multiLevelClassification.js:
--------------------------------------------------------------------------------
1 | export const multiLevelClassification = ({ description = '', examples = [], context = '' }) => {
2 | if (!context) throw new Error('context is required');
3 |
4 | const _example =
5 | examples && examples.length > 0
6 | ? `Examples: ${examples.map(
7 | (ex) => `Input: ${ex.context} Output: [${JSON.stringify(ex.expected_answer)}]`
8 | )}`
9 | : '';
10 |
11 | return `
12 | ${description}
13 | You are a highly intelligent and can accurately classify Multi-Label Text Classification. You take the above passage as input and return the multi level text classification as output from the Paragraph. Your output format is only {{ output_format|default("{'Summary' : 'Extracted Answer'}") }} form, no other form.
14 | ${_example}
15 | Context: ${context}
16 | Output:
17 | `;
18 | };
19 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "promptifyjs",
3 | "version": "0.0.1",
4 | "description": "Prompt Engineering, Solve NLP Problems with LLM's & Easily generate different NLP Task prompts for popular generative models like GPT, PaLM, and more with Promptify",
5 | "main": "index.js",
6 | "type": "module",
7 | "directories": {
8 | "example": "examples"
9 | },
10 | "scripts": {
11 | "test": "echo \"Error: no test specified\" && exit 1"
12 | },
13 | "repository": {
14 | "type": "git",
15 | "url": "git+https://github.com/promptslab/PromptifyJs.git"
16 | },
17 | "keywords": [
18 | "promptslab"
19 | ],
20 | "author": "promptslab",
21 | "license": "ISC",
22 | "bugs": {
23 | "url": "https://github.com/promptslab/PromptifyJs/issues"
24 | },
25 | "homepage": "https://github.com/promptslab/PromptifyJs#readme",
26 | "dependencies": {
27 | "axios": "^1.3.4",
28 | "openai": "^3.1.0"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/config/binaryClassification.js:
--------------------------------------------------------------------------------
1 | export const binaryClassification = ({
2 | text_input = "",
3 | description = "",
4 | labels = "",
5 | examples = [],
6 | }) => {
7 | if (!text_input) throw new Error("input is required");
8 |
9 | const _label = `${
10 | labels ? `following predefined entity types: ${labels}` : "entity types"
11 | }`;
12 | const _example =
13 | examples && examples.length > 0
14 | ? `Examples: ${examples.map(
15 | (ex) => `Input ${ex.text} Output [${ex.labels}] \n`
16 | )}`
17 | : "";
18 | return `
19 | ${description}
20 | You are a highly intelligent and accurate Binary Classification system.
21 | You take Passage as input and classify that as either of the ${_label} only, nothing else.
22 | Your output format is only {{ output_format|default("[{'C':Category}]") }} form, no other form.
23 | ${_example}
24 | Input: ${text_input}
25 | Output:
26 | `;
27 | };
28 |
--------------------------------------------------------------------------------
/examples/qaExample.js:
--------------------------------------------------------------------------------
1 | import { qa } from "../config/qa.js";
2 | import { qaData } from "../examples/data/qa.js";
3 | import { OpenAI } from "../models/openai.js";
4 | import { Prompter } from "../promptify/index.js";
5 |
6 | const model = OpenAI("api-key");
7 | const firstExample = qaData.slice(0, 3);
8 |
9 | console.log(firstExample)
10 |
11 | const prompt = qa({
12 | domain: "nlp",
13 | examples: firstExample,
14 | context: 'Prompt engineering is a concept in artificial intelligence, particularly natural language processing (NLP). In prompt engineering, the description of the task is embedded in the input, e.g., as a question instead of it being implicitly given. Prompt engineering typically works by converting one or more tasks to a prompt-based dataset and training a language model with what has been called "prompt-based learning" or just "prompt learning".',
15 | question: "What is prompt engineering?"
16 | });
17 |
18 | const result = await Prompter(model, prompt, "text-davinci-003");
19 |
20 | console.log(result);
21 |
--------------------------------------------------------------------------------
/config/tabular.js:
--------------------------------------------------------------------------------
1 | export const tabular = ({
2 | text_input = "",
3 | description = "",
4 | examples = [],
5 | }) => {
6 | if (!text_input) throw new Error("input is required");
7 | if (!description) throw new Error("description is required");
8 | if (!examples) throw new Error("examples is required");
9 |
10 | const _example =
11 | examples && examples.length > 0
12 | ? `Examples: ${examples.map(
13 | (ex) => `Input ${ex.text} Output: [${ex.tabulardata}]`
14 | )}`
15 | : "";
16 | return `
17 | Description: ${description}
18 |
19 | You are a highly intelligent and accurate tabular data extractor from plain text input, your inputs can be text of arbitrary size, but the output should be in [{'tabular': {'entity_type': 'entity'} }] JSON format
20 |
21 | Examples Below:
22 | ${_example}
23 |
24 | Target Input Below:
25 | ${text_input.text}
26 | Output for the target input:
27 | `;
28 | };
29 |
--------------------------------------------------------------------------------
/examples/data/relation_extraction.js:
--------------------------------------------------------------------------------
1 | export const relationExtractionData = [
2 | {
3 | text: "Bob is a person. He is a friend of Alice, and he is born on the 4th July. He is interested in the Mona Lisa. The Mona Lisa was created by Leonardo da Vinci. The video 'La Joconde à Washington' is about the mona lisa.",
4 | labels: [
5 | ["Bob", "is a", "person"],
6 | ["Bob", "is a friend of", "Alice"],
7 | ["Bob", "is born on", "the 4th of July 1990"],
8 | ["Bob", "is interested in", "the Mona Lisa"],
9 | ["the Mona Lisa", "was created by", "Leonardo da Vinci"],
10 | ["the video 'La Joconde à Washington", "is about", "the Mona Lisa"],
11 | ],
12 | },
13 | {
14 | text: "Mary is a person. She is employed by XYZ corp. she has a job title Account Manager.",
15 | labels: [
16 | ["Mary", "is", "person"],
17 | ["Mary", "is employed by", "XYZ corp"],
18 | ["Mary", "has a job title", "Account Manager"],
19 | ],
20 | },
21 | ];
22 |
--------------------------------------------------------------------------------
/config/qa.js:
--------------------------------------------------------------------------------
1 | export const qa = ({
2 | description = "",
3 | domain = "",
4 | examples = [],
5 | context = "",
6 | question = ""
7 | }) => {
8 | if (!context) throw new Error("context is required");
9 | if (!question) throw new Error("question is required");
10 |
11 | const _domain = domain ? `${domain} domain` : "";
12 | const _example =
13 | examples && examples.length > 0
14 | ? `Examples: ${examples.map(
15 | (ex) => `Input: ${ex.context} Question: ${ex.question} Output: [${ex.extracted_answer}]`
16 | )}`
17 | : "";
18 | return `
19 | ${description}
20 | You are a highly intelligent and accurate ${_domain} question answering bot. You take Context and Question as input and return the answer from the Paragraph. Retain as much information as needed to answer the question at a later time.
21 | Your output format is only {{ output_format|default("[{'A' : Extracted Answer}]") }} form, no other form.
22 | ${_example}
23 | Context: ${context}
24 | Question: ${question}
25 | Output:
26 | `;
27 | };
28 |
--------------------------------------------------------------------------------
/config/relationExtraction.js:
--------------------------------------------------------------------------------
1 | export const relationExtraction = ({
2 | text_input = "",
3 | description = "",
4 | domain="",
5 | examples = [],
6 | }) => {
7 | const _example =
8 | examples && examples.length > 0
9 | ? `Examples: ${examples.map(
10 | (ex) => `Input ${ex.text} Output [${ex.labels}] \n`
11 | )}`
12 | : "";
13 |
14 | return `
15 | ${description}
16 | You are a highly intelligent and accurate ${domain} domain Resource Description Framework (RDF) data model. You take Passage as input and convert it into ${domain} domain RDF triples. A triple is a set of three entities that codifies a statement about semantic data in the form of subject–predicate–object expressions.
17 | You are a highly intelligent and accurate Resource Description Framework (RDF) data model. You take Passage as input and convert it into RDF triples. A triple is a set of three entities that codifies a statement about semantic data in the form of subject–predicate–object expressions.
18 | Your output format is only {{ output_format|default("[[ subject, predicate, object ], ...]") }} nothing else
19 | ${_example}
20 | Input: ${text_input}
21 | Output:
22 | `
23 | }
--------------------------------------------------------------------------------
/config/ner.js:
--------------------------------------------------------------------------------
1 | export const ner = ({
2 | text_input = "",
3 | description = "",
4 | domain = "",
5 | labels = "",
6 | examples = [],
7 | }) => {
8 | if (!text_input) throw new Error("input is required");
9 |
10 | const _domain = `${domain ? `${domain} domain` : ""}`;
11 | const _label = `${
12 | labels ? `following predefined entity types: ${labels}` : "entity types"
13 | }`;
14 | const _example =
15 | examples && examples.length > 0
16 | ? `Examples: ${examples.map(
17 | (ex) => `Input ${ex.sentence} Output [${ex.sentence}]`
18 | )}`
19 | : "";
20 | return `
21 | ${description}
22 | 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}.
23 | 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.
24 | ${_example}
25 | Input: ${text_input}
26 | Output:
27 | `;
28 | };
29 |
--------------------------------------------------------------------------------
/config/sql.js:
--------------------------------------------------------------------------------
1 | export const sql = ({
2 | text_input = "",
3 | description = "",
4 | example_schema = {},
5 | target_schema = {},
6 | examples = [],
7 | }) => {
8 | if (!text_input) throw new Error("input is required");
9 | if (!example_schema) throw new Error("example_schema is required");
10 | if (!examples) throw new Error("examples is required");
11 | if (!target_schema) throw new Error("target_schema is required");
12 |
13 | const _example =
14 | examples && examples.length > 0
15 | ? `Examples: ${examples.map(
16 | (ex) => `Input: ${ex.sentence} Output: [{'Q': ${ex.query}}]`
17 | )}`
18 | : "";
19 | return `
20 | ${description}
21 | You are a highly intelligent and accurate SQL query creator. You take a sentence and turn it into a SQL query.
22 | Sometimes you are also provided with a table and you have to create a query that returns the correct answer.
23 | Your output format is a dictionary with a single key 'Q' and the value is the SQL query, so {{ output_format|default("[{'Q':Query}]") }} form, no other form.
24 | The example schema for the examples below is: ${example_schema}
25 | ${_example}
26 |
27 | The target schema is: ${target_schema}
28 | Input: ${text_input}
29 | Output:
30 | `;
31 | };
32 |
--------------------------------------------------------------------------------
/examples/sqlExample.js:
--------------------------------------------------------------------------------
1 | import { sql } from "../config/sql.js";
2 | import { OpenAI } from "../models/openai.js";
3 | import { Prompter } from "../promptify/index.js";
4 | import { sqlData } from "../examples/data/sql.js";
5 |
6 | const model = OpenAI("");
7 | const examples = sqlData;
8 | const firstFiveExamples = examples.slice(0, 5);
9 | const exampleSchema = {
10 | customers: {
11 | customer_id: Number,
12 | first_name: String,
13 | last_name: String,
14 | email: String,
15 | phone: String,
16 | address: String,
17 | },
18 | orders: {
19 | order_id: Number,
20 | customer_id: Number,
21 | order_date: String,
22 | product_name: String,
23 | price: Number,
24 | quantity: Number,
25 | },
26 | };
27 |
28 | const targetSchema = {
29 | cars: {
30 | car_id: Number,
31 | car_name: String,
32 | car_price: Number,
33 | car_color: String,
34 | car_model: String,
35 | car_year: Number,
36 | },
37 | };
38 |
39 | const prompt = sql({
40 | text_input:
41 | "Write an SQL query to get car names and prices from the cars table where the car color is red and the car price is greater than 10000.",
42 | description: "SQL Writer",
43 | example_schema: exampleSchema,
44 | target_schema: targetSchema,
45 | examples: firstFiveExamples,
46 | });
47 |
48 | const result = await Prompter(model, prompt, "text-davinci-003");
49 |
50 | console.log(result);
51 |
--------------------------------------------------------------------------------
/examples/summaryExample.js:
--------------------------------------------------------------------------------
1 | import { summarization } from '../config/summarization.js';
2 | import { summaryData } from '../examples/data/summary.js';
3 | import { OpenAI } from '../models/openai.js';
4 | import { Prompter } from '../promptify/index.js';
5 |
6 | const model = OpenAI('api-key');
7 |
8 | const prompt = summarization({
9 | examples: summaryData,
10 | context: `Google Chrome is a cross-platform web browser developed by Google. It was first released in 2008 for Microsoft Windows, built with free software components from Apple WebKit and Mozilla Firefox. Versions were later released for Linux, macOS, iOS, and also for Android, where it is the default browser. The browser is also the main component of ChromeOS, where it serves as the platform for web applications. Most of Chrome's source code comes from Google's free and open-source software project Chromium, but Chrome is licensed as proprietary freeware. WebKit was the original rendering engine, but Google eventually forked it to create the Blink engine; all Chrome variants except iOS now use Blink. As of October 2022, StatCounter estimates that Chrome has a 67% worldwide browser market share (after peaking at 72.38% in November 2018) on personal computers (PC), is most used on tablets (having surpassed Safari), and is also dominant on smartphones and at 65% across all platforms combined. Because of this success, Google has expanded the "Chrome" brand name to other products: ChromeOS, Chromecast, Chromebook, Chromebit, Chromebox, and Chromebase.`,
11 | });
12 |
13 | const result = await Prompter(model, prompt, 'text-davinci-003');
14 |
15 | console.log(result);
16 |
--------------------------------------------------------------------------------
/promptify/index.js:
--------------------------------------------------------------------------------
1 | import axios from "axios";
2 |
3 | export const Prompter = async (
4 | model,
5 | prompt,
6 | modelType = "text-davinci-003",
7 | apiKey
8 | ) => {
9 | const supportedModels = [
10 | "text-davinci-003",
11 | "text-curie-001",
12 | "text-babbage-001",
13 | "text-ada-001",
14 | "gpt-3.5-turbo", //requires another implementation, can't be used like the other text completion models
15 | ];
16 |
17 | if (!supportedModels.includes(modelType))
18 | throw new Error("Model not supported");
19 | if (!modelType) throw new Error("model is required"); //logic for incorrect model
20 |
21 | if (!prompt) throw new Error("incorrect prompt");
22 |
23 | //call API to render the prompt ?
24 | if (modelType !== "gpt-3.5-turbo") {
25 | const completion = await model.createCompletion({
26 | model: modelType,
27 | prompt: prompt,
28 | max_tokens: 2000,
29 | });
30 |
31 | return completion.data;
32 | } else {
33 | const completionURL = "https://api.openai.com/v1/chat/completions";
34 |
35 | const response = await axios.post(
36 | completionURL,
37 | {
38 | model: modelType,
39 | messages: prompt,
40 | },
41 | {
42 | headers: {
43 | "Content-Type": "application/json",
44 | Authorization: `Bearer ${apiKey}`,
45 | },
46 | }
47 | );
48 |
49 | const completion = response.data;
50 |
51 | return completion.choices[0].message;
52 | }
53 | };
54 |
--------------------------------------------------------------------------------
/examples/multiLevelClassificationExample.js:
--------------------------------------------------------------------------------
1 | import { multiLevelClassification } from '../config/multiLevelClassification.js';
2 | import { multilabelClassificationData } from '../examples/data/mutliLevelClassification.js';
3 | import { OpenAI } from '../models/openai.js';
4 | import { Prompter } from '../promptify/index.js';
5 |
6 | const model = OpenAI('api-key');
7 |
8 | const prompt = multiLevelClassification({
9 | examples: multilabelClassificationData.samples,
10 | context: `The first web browser, called WorldWideWeb, was created in 1990 by Sir Tim Berners-Lee. He then recruited Nicola Pellow to write the Line Mode Browser, which displayed web pages on dumb terminals. The Mosaic web browser was released in April 1993, and was later credited as the first web browser to find mainstream popularity. Its innovative graphical user interface made the World Wide Web easy to navigate and thus more accessible to the average person. This, in turn, sparked the Internet boom of the 1990s, when the Web grew at a very rapid rate. Marc Andreessen, the leader of the Mosaic team, started his own company, Netscape, which released the Mosaic-influenced Netscape Navigator in 1994. Navigator quickly became the most popular browser.
11 |
12 | Microsoft debuted Internet Explorer in 1995, leading to a browser war with Netscape. Within a few years, Microsoft gained a dominant position in the browser market for two reasons: it bundled Internet Explorer with Microsoft Windows, their popular operating system and did so as freeware with no restrictions on usage. The market share of Internet Explorer peaked at over 95% in the early 2000s. In 1998, Netscape launched what would become the Mozilla Foundation to create a new browser using the open-source software model. This work evolved into the Firefox browser, first released by Mozilla in 2004. Firefox's market share peaked at 32% in 2010. Apple released its Safari browser in 2003. Safari remains the dominant browser on Apple devices, though it did not become popular elsewhere.`,
13 | });
14 |
15 | const result = await Prompter(model, prompt, 'text-davinci-003');
16 |
17 | console.log(result);
18 |
--------------------------------------------------------------------------------
/examples/data/multiclass.js:
--------------------------------------------------------------------------------
1 | export const multiclassData = [
2 | {
3 | text: "I ate Something I don't know what it is... Why do I keep Telling things about food",
4 | category: "worry",
5 | confidence_score: "",
6 | complexity: "",
7 | },
8 | {
9 | text: "Here's to the start of a great adventure. Niners today, Alaska tomorrow.",
10 | category: "joy",
11 | confidence_score: "",
12 | complexity: "",
13 | },
14 | {
15 | text: "It is so annoying when she starts typing on her computer in the middle of the night!",
16 | category: "hate",
17 | confidence_score: "",
18 | complexity: "",
19 | },
20 | {
21 | text: "Chocolate milk is so much better through a straw. I lack said straw",
22 | category: "neutral",
23 | confidence_score: "",
24 | complexity: "",
25 | },
26 | {
27 | text: "I want to buy this great album but unfortunately i dont hav enuff funds its "long time noisy"",
28 | category: "sadness",
29 | confidence_score: "",
30 | complexity: "",
31 | },
32 | {
33 | text: "dont wanna work 11-830 tomorrow but i get paid",
34 | category: "sadness",
35 | confidence_score: "",
36 | complexity: "",
37 | },
38 | {
39 | text: "Oh no one minute too late! Oh well",
40 | category: "worry",
41 | confidence_score: "",
42 | complexity: "",
43 | },
44 | {
45 | text: "2 days of this month left, and I only have 400MB left on my onpeak downloads.",
46 | category: "surprise",
47 | confidence_score: "",
48 | complexity: "",
49 | },
50 | {
51 | text: "my last tweet didn't send bad phone",
52 | category: "neutral",
53 | confidence_score: "",
54 | complexity: "",
55 | },
56 | {
57 | text: "I had a dream about a pretty pretty beach and there was no beach when I woke up",
58 | category: "surprise",
59 | confidence_score: "",
60 | complexity: "",
61 | },
62 | ];
63 |
--------------------------------------------------------------------------------
/examples/data/sql.js:
--------------------------------------------------------------------------------
1 | export const sqlData = [
2 | {
3 | sentence: "Retrieve the details of all customers.",
4 | query: "SELECT * FROM customers;",
5 | },
6 |
7 | {
8 | sentence: "Show the total number of orders placed by each customer.",
9 | query: "SELECT customer_id, COUNT(*) as num_orders FROM orders GROUP BY customer_id;",
10 | },
11 |
12 | {
13 | sentence:
14 | "Display the total revenue generated by each product category.",
15 | query: "SELECT product_name, SUM(price * quantity) as revenue FROM orders GROUP BY product_name;",
16 | },
17 |
18 | {
19 | sentence:
20 | "Retrieve the list of all orders placed by a specific customer.",
21 | query: "SELECT * FROM orders WHERE customer_id = 123;",
22 | },
23 |
24 | {
25 | sentence:
26 | 'Get the details of all customers whose last name starts with "S".',
27 | query: "SELECT * FROM customers WHERE last_name LIKE 'S%';",
28 | },
29 |
30 | {
31 | sentence: "Show the top 10 products with the highest revenue.",
32 | query: "SELECT product_name, SUM(price * quantity) as revenue FROM orders GROUP BY product_name ORDER BY revenue DESC LIMIT 10;",
33 | },
34 |
35 | {
36 | sentence: "List all orders that were placed in the last month.",
37 | query: "SELECT * FROM orders WHERE order_date >= DATEADD(month, -1, GETDATE());",
38 | },
39 |
40 | {
41 | sentence: "Display the average order value for each customer.",
42 | query: "SELECT customer_id, AVG(price * quantity) as avg_order_value FROM orders GROUP BY customer_id;",
43 | },
44 |
45 | {
46 | sentence:
47 | "Retrieve the list of all customers who have placed orders more than once.",
48 | query: "SELECT customer_id, COUNT(*) as num_orders FROM orders GROUP BY customer_id HAVING COUNT(*) > 1;",
49 | },
50 |
51 | {
52 | sentence: "Show the total revenue generated by each customer.",
53 | query: "SELECT customer_id, SUM(price * quantity) as revenue FROM orders GROUP BY customer_id;",
54 | },
55 | ];
56 |
--------------------------------------------------------------------------------
/examples/data/binary.js:
--------------------------------------------------------------------------------
1 | export const binaryData = [
2 | {
3 | text: "Eight years the republicans denied obama’s picks. Breitbarters outrage is as phony as their fake president.",
4 | labels: "negative",
5 | score: "",
6 | complexity: "",
7 | },
8 | {
9 | text: "Except he’s the most successful president in our lifetimes. He’s undone most of the damage Obummer did and set America on the right path again.",
10 | labels: "positive",
11 | score: "",
12 | complexity: "",
13 | },
14 | {
15 | text: "So disappointed in wwe summerslam! I want to see john cena wins his 16th title",
16 | labels: "negative",
17 | score: "",
18 | complexity: "",
19 | },
20 | {
21 | text: "Looking forward to going to Carrow Rd tonight. Last time we were there\\u002c Bale scored 2 and we were 3rd. Do not want extra time though",
22 | labels: "positive",
23 | score: "",
24 | complexity: "",
25 | },
26 | {
27 | text: "It's a good day at work when you get to shake Jim Lehrer's hand. Thanks, @user Still kicking myself for being to shy to hug",
28 | labels: "positive",
29 | score: "",
30 | complexity: "",
31 | },
32 | {
33 | text: "Trumpism likewise rests on a bed of racial resentment that was made knowingly and intentionally, long before Trump got into politics.",
34 | labels: "negative",
35 | score: "",
36 | complexity: "",
37 | },
38 | {
39 | text: "i have been with petronas for years i feel that petronas has performed well and made a huge profit",
40 | labels: "positive",
41 | score: "",
42 | complexity: "",
43 | },
44 | {
45 | text: "I've read many post on here saying Israel gives training to US law enforcement .",
46 | labels: "positive",
47 | score: "",
48 | complexity: "",
49 | },
50 | {
51 | text: "And the sad thing is the white students at those schools will act like that too .",
52 | labels: "negative",
53 | score: "",
54 | complexity: "",
55 | },
56 | ];
57 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |

3 |
PromptifyJs
4 |
5 | 
6 |
7 |
8 |
10 |
11 |
12 |
Prompt Engineering, Solve NLP Problems with LLM's & Easily generate different NLP Task prompts for popular generative models like GPT, PaLM, and more with Promptify in Javascript
13 |
14 |
15 |
16 |
33 |
34 | ## Quick tour
35 |
36 | To immediately use a LLM model for your NLP task, we provide the `Prompter` API.
37 |
38 | ```js
39 | import { ner } from "../config/ner.js";
40 | import { OpenAI } from "../models/openai.js";
41 | import { Prompter } from "../promptify/index.js";
42 | import { nerData } from "../examples/data/optimized_ner.js";
43 |
44 | const model = OpenAI("api-key");
45 | const examples = nerData.samples[0].data;
46 | const firstExample = examples.slice(0, 3);
47 |
48 | const prompt = ner({
49 | text_input: "I have alzheimers diease, I need medicine for it",
50 | description: "Medicine NER Expert",
51 | domain: "medicine",
52 | labels: "",
53 | examples: [firstExample],
54 | });
55 |
56 | const result = await Prompter(model, prompt, "text-davinci-003");
57 |
58 | console.log(result);
59 |
60 |
61 | ### Output
62 |
63 | [{'E': '93-year-old', 'T': 'Age'},
64 | {'E': 'chronic right hip pain', 'T': 'Medical Condition'},
65 | {'E': 'osteoporosis', 'T': 'Medical Condition'},
66 | {'E': 'hypertension', 'T': 'Medical Condition'},
67 | {'E': 'depression', 'T': 'Medical Condition'},
68 | {'E': 'chronic atrial fibrillation', 'T': 'Medical Condition'},
69 | {'E': 'severe nausea and vomiting', 'T': 'Symptom'},
70 | {'E': 'urinary tract infection', 'T': 'Medical Condition'},
71 | {'Branch': 'Internal Medicine', 'Group': 'Geriatrics'}]
72 |
73 | ```
74 |
--------------------------------------------------------------------------------
/examples/data/tabular.js:
--------------------------------------------------------------------------------
1 | export const tabularData = {
2 | samples: [
3 | {
4 | text: "John Doe, a 32-year-old engineer, can be reached at johndoe@email.com.",
5 | tabulardata: {
6 | name: "John Doe",
7 | age: 32,
8 | occupation: "Engineer",
9 | email: "johndoe@email.com",
10 | },
11 | },
12 | {
13 | text: "The latest iPhone, the XS Max, is priced at $999 and comes in a 128GB version with a gold finish.",
14 | tabulardata: {
15 | product: "iPhone",
16 | model: "XS Max",
17 | price: 999,
18 | storage: "128GB",
19 | color: "Gold",
20 | },
21 | },
22 | {
23 | text: "Sarah Johnson, a 28-year-old teacher, can be contacted at sarahj@email.com.",
24 | tabulardata: {
25 | name: "Sarah Johnson",
26 | age: 28,
27 | occupation: "Teacher",
28 | email: "sarahj@email.com",
29 | },
30 | },
31 | {
32 | text: "The new MacBook Pro, featuring the M1 chip, costs $1999 and comes with 16GB of memory in a silver finish.",
33 | tabulardata: {
34 | product: "MacBook Pro",
35 | model: "M1",
36 | price: 1999,
37 | storage: "16GB",
38 | color: "Silver",
39 | },
40 | },
41 |
42 | {
43 | text: "Dr. Michael Smith can be reached at michaels@email.com.",
44 | tabulardata: {
45 | name: "Michael Smith",
46 | occupation: "Doctor",
47 | email: "michaels@email.com",
48 | },
49 | },
50 |
51 | {
52 | text: "The 11-inch iPad Pro, with 128GB of storage, is available in space gray and costs $799.",
53 | tabulardata: {
54 | product: "iPad Pro",
55 | model: "11-inch",
56 | price: 799,
57 | storage: "128GB",
58 | color: "Space Gray",
59 | },
60 | },
61 |
62 | {
63 | text: "Emily Davis, a 31-year-old lawyer, can be reached at emilyd@email.com.",
64 | tabulardata: {
65 | name: "Emily Davis",
66 | age: 31,
67 | occupation: "Lawyer",
68 | email: "emilyd@email.com",
69 | },
70 | },
71 | {
72 | text: "The AirPods Max, available in silver, costs $599.",
73 | tabulardata: {
74 | product: "AirPods Max",
75 | price: 599,
76 | color: "Silver",
77 | },
78 | },
79 |
80 | {
81 | text: "David Brown, a 40-year-old manager, can be contacted at davidb@email.com.",
82 | tabulardata: {
83 | name: "David Brown",
84 | age: 40,
85 | occupation: "Manager",
86 | email: "davidb@email.com",
87 | },
88 | },
89 |
90 | {
91 | text: "The Apple Watch Series 6, with GPS, comes in a 40mm silver aluminum case and costs $399.",
92 | tabulardata: {
93 | product: "Apple Watch Series 6",
94 | type: "GPS",
95 | price: 399,
96 | size: "40mm",
97 | color: "Silver Aluminum Case",
98 | },
99 | },
100 | ],
101 | };
102 |
--------------------------------------------------------------------------------
/examples/data/paragraph.js:
--------------------------------------------------------------------------------
1 | export const paragraphData = {
2 | samples: [
3 | {
4 | id: "b384d61b-dd21-4d44-9e03-93e8a06bc939",
5 | paragraph:
6 | "Leptomeningeal metastases (LM) occur in patients with breast cancer (BC) and lung cancer (LC). The cerebrospinal fluid (CSF) tumour microenvironment (TME) of LM patients is not well defined at a single-cell level. We did an analysis based on single-cell RNA sequencing (scRNA-seq) data and four patient-derived CSF samples of idiopathic intracranial hypertension (IIH)",
7 | domain: ["clinical", "medical", "healthcare"],
8 | },
9 | {
10 | id: "b664d78b-dd21-4d15-9e03-65e8a06bc939",
11 | paragraph:
12 | "Upper boundary of abdominal cavity is diaphragm, separates it from the chest cavity; its lower boundary is the upper plane of the pelvic cavity. Enclosed by the vertebral column and the abdominal muscles. greater part of the digestive tract, the liver and pancreas, the spleen, the kidneys, and the adrenal glands located above the kidneys",
13 | domain: ["anatomy", "medical", "healthcare"],
14 | },
15 | {
16 | id: "2ee2f307-536d-458d-908f-88a6d87f83b8",
17 | paragraph:
18 | "Amyloid β42, and tau proteins are cerebrospinal biomarkers; amyloid β oligomers and synaptic markers are novel. MRI and fluorodeoxyglucose PET are for diagnosis of Alzheimer's disease",
19 | domain: ["clinical", "medical", "healthcare"],
20 | },
21 | {
22 | id: "4f1cea62-f9f0-4e2f-8a6c-35c5d3c9a9e7",
23 | paragraph:
24 | "The patient had abdominal pain and 30-pound weight loss then developed jaundice. He had epigastric pain. A thin-slice CT scan was performed, which revealed a pancreatic mass with involved lymph nodes and ring enhancing lesions with liver metastases",
25 | domain: ["clinical", "medical", "healthcare"],
26 | },
27 | {
28 | id: "926079fc-54b5-4c7c-86ba-9734d3118948",
29 | paragraph:
30 | "Aspiration pneumonia and chronic obstructive pulmonary disease (COPD) exacerbation. Acute respiratory on chronic respiratory failure secondary to chronic obstructive pulmonary disease exacerbation. Systemic inflammatory response syndrome secondary to aspiration pneumonia. No bacteria identified with blood cultures or sputum culture",
31 | domain: ["clinical", "medical", "healthcare"],
32 | },
33 | {
34 | id: "7b48cd40-917f-4613-a4c1-60cdea426ab5",
35 | paragraph:
36 | "The patient is a 93-year-old female with a medical history of chronic right hip pain, osteoporosis, hypertension, depression, and chronic atrial fibrillation admitted for evaluation and management of severe nausea and vomiting and urinary tract infection",
37 | domain: ["clinical", "medical", "healthcare"],
38 | },
39 | {
40 | id: "b9021855-22f4-4951-90fa-de9d4c83c53b",
41 | paragraph:
42 | "Entrepreneur Elon Musk has achieved global fame as the chief executive officer (CEO) of electric automobile maker Tesla Inc. (TSLA) and the private space company SpaceX. Musk co-founded PayPal (PYPL), was an early investor in several tech companies, and in October 2022 completed a deal to take Twitter Inc. private.",
43 | domain: [
44 | "entrepreneur",
45 | "technology",
46 | "finance",
47 | "automotive",
48 | "aerospace",
49 | "general",
50 | ],
51 | },
52 | {
53 | id: "a06388af-1a13-4534-9ea8-49de560c95ae",
54 | paragraph:
55 | "Welcome to the Danaos Corporation. Dr. John Coustas is chief executive officer of Danaos Corporation; and Mr. Evangelos Chatzis, chief financial officer",
56 | domain: ["business", "corporate", "general"],
57 | },
58 | ],
59 | };
60 |
--------------------------------------------------------------------------------
/examples/data/mutliLevelClassification.js:
--------------------------------------------------------------------------------
1 | export const multilabelClassificationData = {
2 | samples: [
3 | {
4 | context: `The Vietnam War (also known by other names) was a conflict in Vietnam, Laos, and Cambodia from 1 November 1955 to the fall of Saigon on 30 April 1975. It was the second of the Indochina Wars and was officially fought between North Vietnam and South Vietnam. The north was supported by the Soviet Union, China, and other communist states, while the south was supported by the United States and other anti-communist allies. The war is widely considered to be a Cold War-era proxy war. It lasted almost 20 years, with direct U.S. involvement ending in 1973. The conflict also spilled over into neighboring states, exacerbating the Laotian Civil War and the Cambodian Civil War, which ended with all three countries becoming communist states by 1975.`,
5 | expected_answer: {
6 | 'main class': 'Vietnam War',
7 | 1: {
8 | 'sub-class': 'Causes and Background',
9 | branch: 'History',
10 | group: 'Political',
11 | },
12 | 2: {
13 | 'sub-class': 'Military Tactics and Strategies',
14 | branch: 'Military Science',
15 | group: 'Warfare',
16 | },
17 | 3: {
18 | 'sub-class': 'International Relations',
19 | branch: 'Political Science',
20 | group: 'Diplomacy',
21 | },
22 | 4: {
23 | 'sub-class': 'Social and Cultural Impact',
24 | branch: 'Sociology',
25 | group: 'Culture and Society',
26 | },
27 | 5: {
28 | 'sub-class': 'Legacy and Aftermath',
29 | branch: 'History',
30 | group: 'Political',
31 | },
32 | },
33 | },
34 | {
35 | context: `MRI was originally called NMRI (nuclear magnetic resonance imaging), but "nuclear" was dropped to avoid negative associations. Certain atomic nuclei are able to absorb radio frequency energy when placed in an external magnetic field; the resultant evolving spin polarization can induce a RF signal in a radio frequency coil and thereby be detected. In clinical and research MRI, hydrogen atoms are most often used to generate a macroscopic polarization that is detected by antennas close to the subject being examined. Hydrogen atoms are naturally abundant in humans and other biological organisms, particularly in water and fat. For this reason, most MRI scans essentially map the location of water and fat in the body. Pulses of radio waves excite the nuclear spin energy transition, and magnetic field gradients localize the polarization in space. By varying the parameters of the pulse sequence, different contrasts may be generated between tissues based on the relaxation properties of the hydrogen atoms therein.`,
36 | expected_answer: {
37 | 'main class': 'MRI',
38 | 1: {
39 | 'sub-class': 'Principles',
40 | branch: 'Physics',
41 | group: 'Medical imaging',
42 | },
43 | 2: {
44 | 'sub-class': 'Applications',
45 | branch: 'Medicine',
46 | group: 'Diagnostic imaging',
47 | },
48 | 3: {
49 | 'sub-class': 'Technique',
50 | branch: 'Radiology',
51 | group: 'Imaging',
52 | },
53 | },
54 | },
55 | {
56 | context: `A quantum computer is a computer that exploits quantum mechanical phenomena. At small scales, physical matter exhibits properties of both particles and waves, and quantum computing leverages this behavior using specialized hardware. Classical physics cannot explain the operation of these quantum devices, and a scalable quantum computer could perform some calculations exponentially faster than any modern "classical" computer. In particular, a large-scale quantum computer could break widely used encryption schemes and aid physicists in performing physical simulations; however, the current state of the art is still largely experimental and impractical.
57 |
58 | The basic unit of information in quantum computing is the qubit, similar to the bit in traditional digital electronics. Unlike a classical bit, a qubit can exist in a superposition of its two "basis" states, which loosely means that it is in both states simultaneously. When measuring a qubit, the result is a probabilistic output of a classical bit. If a quantum computer manipulates the qubit in a particular way, wave interference effects can amplify the desired measurement results. The design of quantum algorithms involves creating procedures that allow a quantum computer to perform calculations efficiently.`,
59 | expected_answer: {
60 | 'main class': 'Quantum Computing',
61 | 1: {
62 | 'sub-class': 'Fundamentals',
63 | branch: 'Physics',
64 | group: 'Quantum Mechanics',
65 | },
66 | 2: {
67 | 'sub-class': 'Hardware',
68 | branch: 'Engineering',
69 | group: 'Quantum Engineering',
70 | },
71 | 3: {
72 | 'sub-class': 'Algorithms',
73 | branch: 'Computer Science',
74 | group: 'Quantum Information Theory',
75 | },
76 | 4: {
77 | 'sub-class': 'Applications',
78 | branch: 'Interdisciplinary',
79 | group: 'Quantum Computing Applications',
80 | },
81 | },
82 | },
83 | ],
84 | };
85 |
--------------------------------------------------------------------------------
/examples/data/optimized_multilabel.js:
--------------------------------------------------------------------------------
1 | export const multilabelData = {
2 | samples: [
3 | {
4 | id: "b664d78b-dd21-4d15-9e03-65e8a06bc939",
5 | data: [
6 | {
7 | "main class": "Anatomy of the body",
8 | 1: "digestive system",
9 | 2: "liver and pancreas",
10 | 3: "spleen",
11 | 4: "kidneys",
12 | 5: "adrenal glands",
13 | branch: "Anatomy",
14 | group: "Systems of the body",
15 | },
16 | ],
17 | },
18 | {
19 | id: "a06388af-1a13-4534-9ea8-49de560c95ae",
20 | data: [
21 | {
22 | "main class": "Business",
23 | 1: "Finance",
24 | 2: "Corporate conference call",
25 | 3: "Financial results",
26 | 4: "CEO",
27 | 5: "CFO",
28 | branch: "Business",
29 | group: "Corporate communication",
30 | },
31 | ],
32 | },
33 | {
34 | id: "b9021855-22f4-4951-90fa-de9d4c83c53b",
35 | domain: "business",
36 | data: [
37 | {
38 | "main class": "Business",
39 | 1: "Entrepreneurship",
40 | 2: "CEO",
41 | 3: "Technology",
42 | 4: "Automotive industry",
43 | 5: "Space exploration",
44 | branch: "Business",
45 | group: "Leadership and innovation",
46 | },
47 | ],
48 | },
49 | {
50 | id: "7b48cd40-917f-4613-a4c1-60cdea426ab5",
51 | domain: "medical",
52 | data: [
53 | {
54 | "main class": "Health",
55 | 1: "Medicine",
56 | 2: "Patient care",
57 | 3: "Discharge Summary",
58 | 4: "Geriatric medicine",
59 | 5: "Chronic pain",
60 | 6: "Osteoporosis",
61 | 7: "Hypertension",
62 | 8: "Depression",
63 | 9: "Atrial fibrillation",
64 | 10: "Nausea and vomiting",
65 | 11: "Urinary tract infection",
66 | branch: "Health",
67 | group: "Clinical medicine",
68 | },
69 | ],
70 | },
71 | {
72 | id: "926079fc-54b5-4c7c-86ba-9734d3118948",
73 | domain: "medical",
74 | data: [
75 | {
76 | "main class": "Health",
77 | 1: "Medicine",
78 | 2: "Pulmonology",
79 | 3: "Pneumonia",
80 | 4: "Chronic obstructive pulmonary disease (COPD)",
81 | 5: "Discharge Summary",
82 | 6: "Respiratory failure",
83 | 7: "Systemic inflammatory response syndrome",
84 | 8: "Bacterial infection",
85 | branch: "Health",
86 | group: "Clinical medicine",
87 | },
88 | ],
89 | },
90 | {
91 | id: "4f1cea62-f9f0-4e2f-8a6c-35c5d3c9a9e7",
92 | domain: "medical",
93 | data: [
94 | {
95 | "main class": "Health",
96 | 1: "Medicine",
97 | 2: "Gastroenterology",
98 | 3: "Pancreatic Mass",
99 | 4: "Discharge Summary",
100 | 5: "Abdominal pain",
101 | 6: "Weight loss",
102 | 7: "Jaundice",
103 | 8: "Lymph node involvement",
104 | 9: "Liver metastases",
105 | branch: "Health",
106 | group: "Clinical medicine",
107 | },
108 | ],
109 | },
110 | {
111 | id: "2ee2f307-536d-458d-908f-88a6d87f83b8",
112 | domain: "medical",
113 | data: [
114 | {
115 | "main class": "Health",
116 | 1: "Medicine",
117 | 2: "Neurology",
118 | 3: "Alzheimer's disease",
119 | 4: "Biomarkers",
120 | 5: "Proteins",
121 | 6: "MRI",
122 | 7: "PET",
123 | 8: "Diagnosis",
124 | branch: "Health",
125 | group: "Clinical medicine",
126 | },
127 | ],
128 | },
129 | {
130 | id: "b384d61b-dd21-4d44-9e03-93e8a06bc939",
131 | data: [
132 | {
133 | "main class": "Health",
134 | 1: "Medicine",
135 | 2: "Oncology",
136 | 3: "Metastasis",
137 | 4: "Breast cancer",
138 | 5: "Lung cancer",
139 | 6: "Cerebrospinal fluid",
140 | 7: "Tumor microenvironment",
141 | 8: "Single-cell RNA sequencing",
142 | 9: "Idiopathic intracranial hypertension",
143 | branch: "Health",
144 | group: "Clinical medicine",
145 | },
146 | ],
147 | },
148 | ],
149 | };
150 |
--------------------------------------------------------------------------------
/examples/data/summary.js:
--------------------------------------------------------------------------------
1 | export const summaryData = [
2 | {
3 | context: `Firefox was created in 2002 under the code name "Phoenix" by members of the Mozilla community who desired a standalone browser rather than the Mozilla Application Suite bundle. During its beta phase, it proved to be popular with its testers and was praised for its speed, security, and add-ons compared to Microsoft's then-dominant Internet Explorer 6. It was released on November 9, 2004, and challenged Internet Explorer's dominance with 60 million downloads within nine months. It is the spiritual successor of Netscape Navigator, as the Mozilla community was created by Netscape in 1998, before their acquisition by AOL.`,
4 | extracted_answer:
5 | "Firefox was created in 2002 by members of the Mozilla community who desired a standalone browser. It was originally named Phoenix and proved popular during its beta phase for its speed, security, and add-ons. It challenged Internet Explorer's dominance upon its release in 2004, with 60 million downloads within nine months. The Mozilla community was created by Netscape in 1998 before their acquisition by AOL, and Firefox is considered the spiritual successor of Netscape Navigator.",
6 | },
7 | {
8 | context: `Netflix initially both sold and rented DVDs by mail, but the sales were eliminated within a year to focus on the DVD rental business. In 2007, Netflix introduced streaming media and video on demand. The company expanded to Canada in 2010, followed by Latin America and the Caribbean. In 2013, the service began to acquire and produce original content, beginning with the political drama House of Cards. By 2022, original productions accounted for half of Netflix's library in the United States, and the company had ventured into other categories, such as video game publishing via the Netflix service. The company is ranked 115th on the Fortune 500 and 219th on the Forbes Global 2000. It is the second largest entertainment/media company by market capitalization as of February 2022. In 2021, Netflix was ranked as the eighth-most trusted brand globally by Morning Consult. During the 2010s, Netflix was the top-performing stock in the S&P 500 stock market index, with a total return of 3,693%. As of January 2023, Netflix had over 230 million subscribers worldwide, including 74.3 million in the United States and Canada; 76.7 million in Europe, the Middle East and Africa, 41.7 million in Latin America and 38 million in the Asia-Pacific region. The Netflix service is available worldwide aside from Mainland China, Syria, North Korea, and Russia. Netflix is headquartered in Los Gatos, California, in Santa Clara County, with the two CEOs, Greg Peters and Ted Sarandos, split between Los Gatos and Los Angeles, respectively. It also operates international offices in Asia, Europe and Latin America including in Canada, France, Brazil, the Netherlands, India, Italy, Japan, Poland, South Korea and the United Kingdom. The company has production hubs in Los Angeles, Albuquerque, London, Madrid, Vancouver and Toronto.`,
9 | extracted_answer:
10 | 'Netflix is an entertainment/media company headquartered in California, known for its DVD rental business and streaming media services. The company expanded to Canada, Latin America, and the Caribbean, and began producing original content in 2013. It has a large subscriber base worldwide and has been ranked as a top-performing stock in the S&P 500 index. The company is headquartered in Los Gatos, California, and has international offices and production hubs around the world.',
11 | },
12 | {
13 | context: `Reddit is an American social news aggregation, content rating, and discussion website. Registered users (commonly referred to as "Redditors") submit content to the site such as links, text posts, images, and videos, which are then voted up or down by other members. Posts are organized by subject into user-created boards called "communities" or "subreddits". Submissions with more upvotes appear towards the top of their subreddit and, if they receive enough upvotes, ultimately on the site's front page. Reddit administrators moderate the communities. Moderation is also conducted by community-specific moderators, who are not Reddit employees. As of December 2022, Reddit ranks as the 20th-most-visited website in the world and 6th most-visited website in the U.S., according to Semrush. About 42–49.3% of its user base comes from the United States, followed by the United Kingdom at 7.9–8.2% and Canada at 5.2–7.8%. Twenty-two percent of U.S. adults aged 18 to 29 years, and 14 percent of U.S. adults aged 30 to 49 years, regularly use Reddit. Reddit was founded by University of Virginia roommates Steve Huffman and Alexis Ohanian, with Aaron Swartz, in 2005. Condé Nast Publications acquired the site in October 2006. In 2011, Reddit became an independent subsidiary of Condé Nast's parent company, Advance Publications. In October 2014, Reddit raised $50 million in a funding round led by Sam Altman and including investors Marc Andreessen, Peter Thiel, Ron Conway, Snoop Dogg, and Jared Leto. Their investment valued the company at $500 million then. In July 2017, Reddit raised $200 million for a $1.8 billion valuation, with Advance Publications remaining the majority stakeholder. In February 2019, a $300 million funding round led by Tencent brought the company's valuation to $3 billion. In August 2021, a $700 million funding round led by Fidelity Investments raised that valuation to over $10 billion. The company then reportedly filed for an IPO in December 2021 with a valuation of 15 billion dollars.`,
14 | extracted_answer: `Reddit is a social news aggregation and discussion website where registered users submit content to the site which is then voted up or down by other members. Posts are organized into user-created boards called "communities" or "subreddits." As of December 2022, Reddit is the 20th-most-visited website in the world and the 6th-most-visited website in the U.S. It was founded in 2005 by Steve Huffman and Alexis Ohanian and was acquired by Condé Nast Publications in 2006. In 2011, it became an independent subsidiary of Condé Nast's parent company, Advance Publications. Reddit has raised over $1 billion in funding and filed for an IPO in December 2021 with a valuation of $15 billion.`,
15 | },
16 | ];
17 |
--------------------------------------------------------------------------------
/examples/data/qa.js:
--------------------------------------------------------------------------------
1 | export const qaData = [
2 | {
3 | context:
4 | "The university is the major seat of the Congregation of Holy Cross (albeit not its official headquarters, which are in Rome). Holy Cross House, as well as Columba Hall near the Grotto. The university through the Moreau Seminary has ties to theologian Frederick Buechner.",
5 | question:
6 | "Where is the headquarters of the Congregation of the Holy Cross?",
7 | extracted_answer: "Rome",
8 | offset: "119",
9 | },
10 | {
11 | context:
12 | "Its main seminary, Moreau Seminary, is located on the campus across St. Joseph lake from the Main Building. Old College, the oldest building on campus and located near the shore of St. Mary lake, houses undergraduate seminarians. Retired priests and brothers reside in Fatima House (a former retreat center).",
13 | question:
14 | "What is the primary seminary of the Congregation of the Holy Cross?",
15 | extracted_answer: "Moreau Seminary",
16 | offset: "19",
17 | },
18 | {
19 | context:
20 | "Science can be divided into different branches based on the subject of study. The physical sciences study the inorganic world and comprise the fields of astronomy, physics, chemistry, and the Earth sciences. The biological sciences such as biology and medicine study the organic world of life and its processes. Social sciences like anthropology and economics study the social and cultural aspects of human behaviour.",
21 | question: "What are the different branches of science?",
22 | extracted_answer:
23 | "The different branches of science include the physical sciences, the biological sciences, and the social sciences.",
24 | offset: "",
25 | },
26 | {
27 | context:
28 | "Science can be divided into different branches based on the subject of study. The physical sciences study the inorganic world and comprise the fields of astronomy, physics, chemistry, and the Earth sciences. The biological sciences such as biology and medicine study the organic world of life and its processes. Social sciences like anthropology and economics study the social and cultural aspects of human behaviour.",
29 | question: "What do the physical sciences study",
30 | extracted_answer:
31 | "The physical sciences study the inorganic world and comprise the fields of astronomy, physics, chemistry, and the Earth sciences.",
32 | offset: "78",
33 | },
34 | {
35 | context:
36 | "when the hold of Scholasticism did begin to wane, two fresh influences, equally powerful, came on the scene to prevent anything comparable to the pragmatic and empirical foundations of the physical sciences from forming in the study of humanity and society. The first was the immense appeal of the Greek classics during the Renaissance, especially those of the philosophers Plato and Aristotle.",
37 | question: "What is Scholasticism?",
38 | extracted_answer: "What is Scholasticism?",
39 | offset: "",
40 | },
41 | {
42 | context:
43 | "when the hold of Scholasticism did begin to wane, two fresh influences, equally powerful, came on the scene to prevent anything comparable to the pragmatic and empirical foundations of the physical sciences from forming in the study of humanity and society. The first was the immense appeal of the Greek classics during the Renaissance, especially those of the philosophers Plato and Aristotle.",
44 | question: "What was the first influence?",
45 | extracted_answer:
46 | "The first influence was the appeal of the Greek classics during the Renaissance, particularly the works of Plato and Aristotle.",
47 | offset: "",
48 | },
49 | {
50 | context:
51 | "The second major breakthrough of the 1930s, the theory of income determination, stemmed primarily from the work of John Maynard Keynes, who asked questions that in some sense had never been posed before. Keynes was interested in the level of national income and the volume of employment rather than in the equilibrium of the firm or the allocation of resources.",
52 | question: "What was the second major breakthrough of the 1930s?",
53 | extracted_answer:
54 | "The second major breakthrough of the 1930s was the theory of income determination.",
55 | offset: "",
56 | },
57 | {
58 | context:
59 | "The second major breakthrough of the 1930s, the theory of income determination, stemmed primarily from the work of John Maynard Keynes, who asked questions that in some sense had never been posed before. Keynes was interested in the level of national income and the volume of employment rather than in the equilibrium of the firm or the allocation of resources. ",
60 | question: "Who was primarily responsible for this breakthrough?",
61 | extracted_answer:
62 | "John Maynard Keynes was primarily responsible for this breakthrough.",
63 | offset: "",
64 | },
65 | {
66 | context:
67 | "In the systems design phase, such specifications are converted to a hierarchy of charts that define the data required and the processes to be carried out on the data so they can be expressed as instructions of a computer program. Many information systems are implemented with generic software, rather than with such custom-built programs.",
68 | question: "What is an example of generic software?",
69 | extracted_answer:
70 | "Examples of generic software include off-the-shelf programs such as word processors, spreadsheet software, and database management systems.",
71 | offset: "",
72 | },
73 | {
74 | context:
75 | "In the systems design phase, such specifications are converted to a hierarchy of charts that define the data required and the processes to be carried out on the data so they can be expressed as instructions of a computer program. Many information systems are implemented with generic software, rather than with such custom-built programs.",
76 | question: "What is an example of custom-built software?",
77 | extracted_answer:
78 | "An example of custom-built software would be a program that is specifically designed and developed for a particular organization or purpose.",
79 | offset: "",
80 | },
81 | ];
82 |
--------------------------------------------------------------------------------
/examples/data/optimized_ner.js:
--------------------------------------------------------------------------------
1 | export const nerData = {
2 | samples: [
3 | {
4 | data: [
5 | {
6 | E: "DISEASE",
7 | T: "Alzheimer's disease",
8 | },
9 | {
10 | E: "BIOMARKER",
11 | T: "Amyloid β42",
12 | },
13 | {
14 | E: "BIOMARKER",
15 | T: "tau proteins",
16 | },
17 | {
18 | E: "BIOMARKER",
19 | T: "cerebrospinal biomarkers",
20 | },
21 | {
22 | E: "BIOMARKER",
23 | T: "amyloid β oligomers",
24 | },
25 | {
26 | E: "BIOMARKER",
27 | T: "synaptic markers",
28 | },
29 | {
30 | E: "TEST",
31 | T: "MRI",
32 | },
33 | {
34 | E: "TEST",
35 | T: "fluorodeoxyglucose PET",
36 | },
37 | ],
38 | id: "2ee2f307-536d-458d-908f-88a6d87f83b8",
39 | },
40 | {
41 | data: [
42 | {
43 | E: "BODY_PART",
44 | T: "abdominal cavity",
45 | },
46 | {
47 | E: "BODY_PART",
48 | T: "diaphragm",
49 | },
50 | {
51 | E: "BODY_PART",
52 | T: "chest cavity",
53 | },
54 | {
55 | E: "BODY_PART",
56 | T: "upper plane of the pelvic cavity",
57 | },
58 | {
59 | E: "BODY_PART",
60 | T: "vertebral column",
61 | },
62 | {
63 | E: "BODY_PART",
64 | T: "abdominal muscles",
65 | },
66 | {
67 | E: "ORGAN",
68 | T: "digestive tract",
69 | },
70 | {
71 | E: "ORGAN",
72 | T: "liver",
73 | },
74 | {
75 | E: "ORGAN",
76 | T: "pancreas",
77 | },
78 | {
79 | E: "ORGAN",
80 | T: "spleen",
81 | },
82 | {
83 | E: "ORGAN",
84 | T: "kidneys",
85 | },
86 | {
87 | E: "ORGAN",
88 | T: "adrenal glands",
89 | },
90 | ],
91 | id: "b664d78b-dd21-4d15-9e03-65e8a06bc939",
92 | },
93 | {
94 | data: [
95 | {
96 | E: "DISEASE",
97 | T: "Leptomeningeal metastases",
98 | },
99 | {
100 | E: "DISEASE",
101 | T: "breast cancer",
102 | },
103 | {
104 | E: "DISEASE",
105 | T: "lung cancer",
106 | },
107 | {
108 | E: "BIOMARKER",
109 | T: "cerebrospinal fluid",
110 | },
111 | {
112 | E: "DISEASE",
113 | T: "tumour microenvironment",
114 | },
115 | {
116 | E: "TEST",
117 | T: "single-cell RNA sequencing",
118 | },
119 | {
120 | E: "DISEASE",
121 | T: "idiopathic intracranial hypertension",
122 | },
123 | ],
124 | id: "b384d61b-dd21-4d44-9e03-93e8a06bc939",
125 | },
126 | {
127 | data: [
128 | {
129 | E: "SYMPTOM",
130 | T: "abdominal pain",
131 | },
132 | {
133 | E: "QUANTITY",
134 | T: "30-pound",
135 | },
136 | {
137 | E: "SYMPTOM",
138 | T: "jaundice",
139 | },
140 | {
141 | E: "SYMPTOM",
142 | T: "epigastric pain",
143 | },
144 | {
145 | E: "TEST",
146 | T: "thin-slice CT scan",
147 | },
148 | {
149 | E: "ANATOMY",
150 | T: "pancreatic mass",
151 | },
152 | {
153 | E: "ANATOMY",
154 | T: "ring enhancing lesions",
155 | },
156 | {
157 | E: "ANATOMY",
158 | T: "liver",
159 | },
160 | {
161 | E: "DISEASE",
162 | T: "metastases",
163 | },
164 | ],
165 | id: "4f1cea62-f9f0-4e2f-8a6c-35c5d3c9a9e7",
166 | },
167 | {
168 | data: [
169 | {
170 | E: "DISEASE",
171 | T: "Aspiration pneumonia",
172 | },
173 | {
174 | E: "DISEASE",
175 | T: "chronic obstructive pulmonary disease",
176 | },
177 | {
178 | E: "DISEASE",
179 | T: "exacerbation",
180 | },
181 | {
182 | E: "DISEASE",
183 | T: "Acute respiratory",
184 | },
185 | {
186 | E: "DISEASE",
187 | T: "chronic respiratory failure",
188 | },
189 | {
190 | E: "DISEASE",
191 | T: "chronic obstructive pulmonary disease",
192 | },
193 | {
194 | E: "DISEASE",
195 | T: "Systemic inflammatory response syndrome",
196 | },
197 | {
198 | E: "TEST",
199 | T: "blood cultures",
200 | },
201 | {
202 | E: "TEST",
203 | T: "sputum culture",
204 | },
205 | ],
206 | id: "926079fc-54b5-4c7c-86ba-9734d3118948",
207 | },
208 | {
209 | data: [
210 | {
211 | E: "DATE",
212 | T: "93-year-old",
213 | },
214 | {
215 | E: "DISEASE",
216 | T: "chronic right hip pain",
217 | },
218 | {
219 | E: "DISEASE",
220 | T: "osteoporosis",
221 | },
222 | {
223 | E: "DISEASE",
224 | T: "hypertension",
225 | },
226 | {
227 | E: "DISEASE",
228 | T: "depression",
229 | },
230 | {
231 | E: "DISEASE",
232 | T: "chronic atrial fibrillation",
233 | },
234 | {
235 | E: "SYMPTOM",
236 | T: "severe nausea and vomiting",
237 | },
238 | {
239 | E: "DISEASE",
240 | T: "urinary tract infection",
241 | },
242 | ],
243 | id: "7b48cd40-917f-4613-a4c1-60cdea426ab5",
244 | },
245 | {
246 | data: [
247 | {
248 | E: "PER",
249 | T: "Elon Musk",
250 | },
251 | {
252 | E: "ORG",
253 | T: "Tesla Inc",
254 | },
255 | {
256 | E: "ORG",
257 | T: "TSLA",
258 | },
259 | {
260 | E: "ORG",
261 | T: "SpaceX",
262 | },
263 | {
264 | E: "ORG",
265 | T: "PayPal",
266 | },
267 | {
268 | E: "ORG",
269 | T: "PYPL",
270 | },
271 | {
272 | E: "ORG",
273 | T: "Twitter Inc",
274 | },
275 | ],
276 | id: "b9021855-22f4-4951-90fa-de9d4c83c53b",
277 | },
278 | {
279 | data: [
280 | {
281 | E: "ORG",
282 | T: "Danaos Corporation",
283 | },
284 | {
285 | E: "PER",
286 | T: "John Coustas",
287 | },
288 | {
289 | E: "ORG",
290 | T: "Danaos Corporation",
291 | },
292 | {
293 | E: "PER",
294 | T: "Evangelos Chatzis",
295 | },
296 | {
297 | E: "ORG",
298 | T: "Danaos Corporation",
299 | },
300 | ],
301 | id: "a06388af-1a13-4534-9ea8-49de560c95ae",
302 | },
303 | ],
304 | };
305 |
--------------------------------------------------------------------------------
/License:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------