From 5723d665b3a226ae1500c26de512ddc695b147a4 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Wed, 17 Jul 2024 13:16:18 -0400 Subject: [PATCH] Introduce v3 schema Closes #38 v3 includes some backwards incompatible changes to the knowledge schema format. Here is a diff against v2. The changes are: - Q&A pairs now have an associated context blob from the knowledge document. - There is new "document_outline" field. ```diff --- src/instructlab/schema/v2/knowledge.json 2024-07-17 12:56:37 +++ src/instructlab/schema/v3/knowledge.json 2024-07-17 13:14:56 @@ -8,7 +8,8 @@ "domain", "task_description", "seed_examples", - "document" + "document", + "document_outline" ], "unevaluatedProperties": false, "properties": { @@ -44,20 +45,37 @@ "items": { "type": "object", "required": [ - "question", - "answer" + "context", + "questions_and_answers" ], "unevaluatedProperties": false, "properties": { - "question": { - "description": "A question used for synthetic data generation.", + "context": { + "description": "A context used for synthetic data generation.", "type": "string", "minLength": 1 }, - "answer": { - "description": "The desired response for the question.", - "type": "string", - "minLength": 1 + "questions_and_answers": { + "type": "array", + "minItems": 3, + "uniqueItems": true, + "items": { + "type": "object", + "required": [ + "question", + "answer" + ], + "properties": { + "question": { + "description": "A question used for synthetic data generation.", + "type": "string", + "minLength": 1 + }, + "answer": { + "description": "The desired response for the question.", + "type": "string", + "minLength": 1 + } + } + } } } } @@ -104,6 +122,11 @@ } } } + }, + "document_outline": { + "description": "An outline of the document.", + "type": "string", + "minLength": 1 } } } ``` Signed-off-by: Russell Bryant --- src/instructlab/schema/v3/__init__.py | 0 .../schema/v3/compositional_skills.json | 60 ++++++++ src/instructlab/schema/v3/knowledge.json | 134 ++++++++++++++++++ src/instructlab/schema/v3/version.json | 15 ++ 4 files changed, 209 insertions(+) create mode 100644 src/instructlab/schema/v3/__init__.py create mode 100644 src/instructlab/schema/v3/compositional_skills.json create mode 100644 src/instructlab/schema/v3/knowledge.json create mode 100644 src/instructlab/schema/v3/version.json diff --git a/src/instructlab/schema/v3/__init__.py b/src/instructlab/schema/v3/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/instructlab/schema/v3/compositional_skills.json b/src/instructlab/schema/v3/compositional_skills.json new file mode 100644 index 0000000..2df9f61 --- /dev/null +++ b/src/instructlab/schema/v3/compositional_skills.json @@ -0,0 +1,60 @@ +{ + "title": "Compositional Skill", + "description": "A compositional skill.", + "type": "object", + "$ref": "./version.json", + "required": [ + "created_by", + "task_description", + "seed_examples" + ], + "unevaluatedProperties": false, + "properties": { + "created_by": { + "description": "The GitHub username of the contributor.", + "type": "string", + "minLength": 1 + }, + "task_description": { + "description": "A description of the task which is used in prompts to the teacher model during synthetic data generation. The description should be detailed and prescriptive to improve the teacher model's responses.", + "type": "string", + "minLength": 1, + "examples": [ + "Extracting content from a financial report and providing it in bulleted format", + "Providing engaging explanations for common questions across diverse topics at a primary school level", + "Assume the roles of historical figures and provide engaging explanations for common questions across diverse topics" + ] + }, + "seed_examples": { + "description": "An array of seed examples for synthetic data generation.", + "type": "array", + "minItems": 5, + "uniqueItems": true, + "items": { + "type": "object", + "required": [ + "question", + "answer" + ], + "unevaluatedProperties": false, + "properties": { + "context": { + "description": "Information that the teacher model is expected to take into account during processing. This is different from knowledge, where the model is expected to gain facts and background knowledge from the tuning process.", + "type": "string", + "minLength": 1 + }, + "question": { + "description": "A question used for synthetic data generation.", + "type": "string", + "minLength": 1 + }, + "answer": { + "description": "The desired response for the question.", + "type": "string", + "minLength": 1 + } + } + } + } + } +} diff --git a/src/instructlab/schema/v3/knowledge.json b/src/instructlab/schema/v3/knowledge.json new file mode 100644 index 0000000..3114eec --- /dev/null +++ b/src/instructlab/schema/v3/knowledge.json @@ -0,0 +1,134 @@ +{ + "title": "Knowledge", + "description": "A knowledge skill.", + "type": "object", + "$ref": "./version.json", + "required": [ + "created_by", + "domain", + "task_description", + "seed_examples", + "document", + "document_outline" + ], + "unevaluatedProperties": false, + "properties": { + "created_by": { + "description": "The GitHub username of the contributor.", + "type": "string", + "minLength": 1 + }, + "domain": { + "description": "The knowledge domain which is used in prompts to the teacher model during synthetic data generation. The domain should be brief such as the title to a textbook chapter or section.", + "type": "string", + "minLength": 1, + "examples": [ + "Chemistry", + "History", + "Pop culture" + ] + }, + "task_description": { + "description": "A description of the task which is used in prompts to the teacher model during synthetic data generation. The description should be detailed and prescriptive to improve the teacher model's responses.", + "type": "string", + "minLength": 1, + "examples": [ + "To teach a language model about softball history", + "To teach a language model about tabby cats" + ] + }, + "seed_examples": { + "description": "An array of seed examples for synthetic data generation.", + "type": "array", + "minItems": 5, + "uniqueItems": true, + "items": { + "type": "object", + "required": [ + "context", + "questions_and_answers" + ], + "unevaluatedProperties": false, + "properties": { + "context": { + "description": "Context from the document associated with this set of sample q&a pairs.", + "type": "string", + "minLength": 1 + }, + "questions_and_answers": { + "type": "array", + "minItems": 3, + "uniqueItems": true, + "items": { + "type": "object", + "required": [ + "question", + "answer" + ], + "properties": { + "question": { + "description": "A question used for synthetic data generation.", + "type": "string", + "minLength": 1 + }, + "answer": { + "description": "The desired response for the question.", + "type": "string", + "minLength": 1 + } + } + } + } + } + } + }, + "document": { + "description": "The knowledge documents.", + "type": "object", + "required": [ + "repo", + "commit", + "patterns" + ], + "unevaluatedProperties": false, + "properties": { + "repo": { + "description": "The URL to a Git repository holding the knowledge documents.", + "type": "string", + "minLength": 1, + "examples": [ + "https://github.com/instructlab/instructlab.git" + ] + }, + "commit": { + "description": "The commit in the Git repository containing the knowledge documents.", + "type": "string", + "minLength": 1, + "examples": [ + "951999afdc59c46d325493568193b40bd5439c9e" + ] + }, + "patterns": { + "description": "An array of glob patterns of the knowledge documents in the Git repository.", + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "type": "string", + "minLength": 1, + "examples": [ + "*.md", + "folder/*.md", + "folder/knowledge_doc.md" + ] + } + } + } + }, + "document_outline": { + "description": "An outline of the document.", + "type": "string", + "minLength": 1 + } + } +} diff --git a/src/instructlab/schema/v3/version.json b/src/instructlab/schema/v3/version.json new file mode 100644 index 0000000..8c0dd3e --- /dev/null +++ b/src/instructlab/schema/v3/version.json @@ -0,0 +1,15 @@ +{ + "title": "Taxonomy Document Schema Version", + "type": "object", + "required": [ + "version" + ], + "properties": { + "version": { + "description": "The schema version of the taxonomy document.", + "type": "integer", + "$comment": "This value must match the number in the containing folder.", + "const": 3 + } + } +}