sdg-hub 0.1.0a4__py3-none-any.whl → 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. sdg_hub/_version.py +2 -2
  2. sdg_hub/blocks/__init__.py +41 -5
  3. sdg_hub/blocks/block.py +58 -16
  4. sdg_hub/blocks/llmblock.py +121 -193
  5. sdg_hub/blocks/openaichatblock.py +556 -0
  6. sdg_hub/blocks/utilblocks.py +500 -43
  7. sdg_hub/checkpointer.py +139 -0
  8. sdg_hub/configs/annotations/detailed_annotations.yaml +28 -0
  9. sdg_hub/configs/annotations/simple_annotations.yaml +9 -0
  10. sdg_hub/configs/knowledge/atomic_facts.yaml +1 -0
  11. sdg_hub/configs/knowledge/detailed_summary.yaml +1 -0
  12. sdg_hub/configs/knowledge/extractive_summary.yaml +1 -0
  13. sdg_hub/configs/knowledge/generate_questions.yaml +82 -0
  14. sdg_hub/configs/knowledge/generate_responses.yaml +86 -0
  15. sdg_hub/configs/skills/contexts.yaml +18 -11
  16. sdg_hub/configs/skills/evaluate_freeform_pair.yaml +79 -12
  17. sdg_hub/configs/skills/evaluate_freeform_questions.yaml +60 -28
  18. sdg_hub/configs/skills/evaluate_grounded_pair.yaml +95 -30
  19. sdg_hub/configs/skills/freeform_questions.yaml +21 -16
  20. sdg_hub/configs/skills/freeform_responses.yaml +19 -25
  21. sdg_hub/configs/skills/router.yaml +53 -6
  22. sdg_hub/flow.py +366 -33
  23. sdg_hub/flow_runner.py +437 -0
  24. sdg_hub/flows/generation/knowledge/synth_knowledge1.5.yaml +21 -9
  25. sdg_hub/flows/generation/skills/{agentic_improve_skill.yaml → improve_responses.yaml} +26 -31
  26. sdg_hub/flows/generation/skills/synth_skills.yaml +4 -4
  27. sdg_hub/pipeline.py +67 -12
  28. sdg_hub/prompts.py +52 -0
  29. sdg_hub/sdg.py +128 -86
  30. sdg_hub/utils/__init__.py +5 -0
  31. sdg_hub/utils/config_validation.py +91 -0
  32. sdg_hub/utils/error_handling.py +94 -0
  33. sdg_hub/utils/path_resolution.py +62 -0
  34. sdg_hub/utils/validation_result.py +10 -0
  35. sdg_hub-0.1.2.dist-info/METADATA +190 -0
  36. sdg_hub-0.1.2.dist-info/RECORD +89 -0
  37. {sdg_hub-0.1.0a4.dist-info → sdg_hub-0.1.2.dist-info}/WHEEL +1 -1
  38. sdg_hub/blocks/filterblock.py +0 -76
  39. sdg_hub/blocks/iterblock.py +0 -31
  40. sdg_hub/blocks/rmblocks.py +0 -194
  41. sdg_hub/configs/annotations/simple.yaml +0 -10
  42. sdg_hub/configs/knowledge/data_recipe/default_recipe.yaml +0 -3
  43. sdg_hub/configs/skills/data_recipe/default_recipe.yaml +0 -6
  44. sdg_hub/flows/annotation/emotion/detailed_description.yaml +0 -19
  45. sdg_hub/flows/annotation/emotion/detailed_description_icl.yaml +0 -19
  46. sdg_hub/flows/annotation/emotion/simple.yaml +0 -19
  47. sdg_hub/utils/chunking.py +0 -73
  48. sdg_hub/utils/docprocessor.py +0 -357
  49. sdg_hub/utils/parse_and_convert.py +0 -392
  50. sdg_hub-0.1.0a4.dist-info/METADATA +0 -309
  51. sdg_hub-0.1.0a4.dist-info/RECORD +0 -90
  52. /sdg_hub/configs/{knowledge/data_recipe → reasoning}/__init__.py +0 -0
  53. /sdg_hub/configs/skills/{_G_.yaml → icl_examples/STEM.yaml} +0 -0
  54. /sdg_hub/configs/skills/{data_recipe → icl_examples}/__init__.py +0 -0
  55. /sdg_hub/configs/skills/{_A_.yaml → icl_examples/coding.yaml} +0 -0
  56. /sdg_hub/configs/skills/{_B_.yaml → icl_examples/extraction.yaml} +0 -0
  57. /sdg_hub/configs/skills/{_C_.yaml → icl_examples/humanities.yaml} +0 -0
  58. /sdg_hub/configs/skills/{_D_.yaml → icl_examples/math.yaml} +0 -0
  59. /sdg_hub/configs/skills/{_E_.yaml → icl_examples/reasoning.yaml} +0 -0
  60. /sdg_hub/configs/skills/{_F_.yaml → icl_examples/roleplay.yaml} +0 -0
  61. /sdg_hub/configs/skills/{_H_.yaml → icl_examples/writing.yaml} +0 -0
  62. {sdg_hub-0.1.0a4.dist-info → sdg_hub-0.1.2.dist-info}/licenses/LICENSE +0 -0
  63. {sdg_hub-0.1.0a4.dist-info → sdg_hub-0.1.2.dist-info}/top_level.txt +0 -0
@@ -1,39 +1,104 @@
1
- system: You are a very knowledgeable AI Assistant that will faithfully assist the user with their task.
1
+ system: You are a highly knowledgeable and impartial AI Assistant tasked with evaluating the quality of responses to user questions.
2
2
 
3
3
  introduction: |
4
- Please act as an impartial judge and evaluate the quality of the answer provided by an AI assistant to the questions displayed below. Evaluate whether or not the answer is a good example of how AI Assistant should respond to the user's instruction. Please assign a score using the following 3-point scale.
4
+ Please act as an objective evaluator and assess the quality of the AI Assistant's answer to the user's question. Your job is to determine whether the answer is complete, correct, relevant, safe, and well-written according to the task. Use the scoring rubric below and assign a score from 1 to 3.
5
+
5
6
  principles: |
6
- 1: It means the answer is incorrect, irrelevant, unsafe or provides incomplete and garbage information. For instance, the answer may be factually wrong, off-topic, or filled with irrelevant content that doesn't address the user's question or it could be incomplete and hanging. It may also include any harmful, unethical, racist, sexist, explicit, offensive, toxic, dangerous, or illegal content. If the answer is not supported by the context given.
7
+ Use the following 3-point scale to score the answer:
8
+
9
+ **1 — Poor Quality**
10
+ - The answer is factually incorrect, off-topic, incomplete, or nonsensical.
11
+ - It may contain hallucinations, hanging statements, or irrelevant content.
12
+ - It does not align with the task description or question intent.
7
13
 
8
- 2: It means the answer provides the correct answer, but it is brief and to the point without explanations. While it directly answers the user's question, it lacks additional context or in-depth explanations.
14
+ **2 Acceptable but Minimal**
15
+ - The answer is correct and safe, but short and lacks depth or clarity.
16
+ - It may be technically correct but overly terse or missing explanation.
17
+ - It satisfies the user's question at a surface level without context.
9
18
 
10
- 3: It means the answer is a perfect answer from an AI Assistant. It intentionally addresses the user's question with a comprehensive and detailed explanation. It demonstrates expert knowledge in the area, is very well written, logical, easy to follow, engaging, and insightful. And the answer is safe and does not include any harmful content.
19
+ **3 Excellent Answer**
20
+ - The answer is complete, correct, relevant, and insightful.
21
+ - It provides clear reasoning, well-structured writing, and deep understanding.
22
+ - It directly addresses the question with expert-level knowledge.
11
23
 
12
24
  examples: |
13
- [Start of Context]
14
- In recent years, electric vehicles (EVs) have gained popularity due to their environmental benefits and advancements in technology. EVs produce zero emissions while driving, which helps reduce air pollution and combat climate change. Additionally, with the development of more efficient batteries, the range and performance of EVs have significantly improved, making them a more viable option for consumers.
15
- [End of Context]
16
-
17
- [Start of Question]
18
- How do electric vehicles help in reducing air pollution?
19
- [End of Question]
20
-
21
- [Start of Answer]
22
- Electric vehicles (EVs) help in reducing air pollution because they produce zero emissions while driving.
23
- [End of Answer]
24
-
25
- [Start of Evaluation]
26
- This answer is correct, directly addresses the user's question, and is supported by the provided context. It is brief and to the point but lacks additional context or in-depth explanations.
27
- [End of Evaluation]
28
-
29
- [Start of Score]
30
- 2
31
- [End of Score]
25
+ Example 1 — Score: 1 (Poor Quality)
26
+
27
+ Task Description: Summarize the key point of a news paragraph in one sentence.
28
+
29
+ [Start of Context]
30
+ The mayor of Springfield unveiled a new plan to reduce urban pollution, which includes a ban on gas-powered scooters, expansion of bike lanes, and free public transit passes for residents.
31
+ [End of Context]
32
+
33
+ [Start of Question]
34
+ What is the main point of the paragraph?
35
+ [End of Question]
36
+
37
+ [Start of Answer]
38
+ Scooters are fun but kind of dangerous if you go too fast lol.
39
+ [End of Answer]
40
+
41
+ [Start of Evaluation]
42
+ The answer is irrelevant and nonsensical in context. It does not reflect the content of the paragraph and includes casual language and commentary that breaks task intent. It is an example of a hallucinated, off-topic response.
43
+ [End of Evaluation]
44
+
45
+ [Start of Score]
46
+ 1
47
+ [End of Score]
48
+
49
+ Example 2 — Score: 2 (Acceptable but Minimal)
50
+
51
+ Task Description: Summarize the key point of a news paragraph in one sentence.
52
+
53
+ [Start of Context]
54
+ The mayor of Springfield unveiled a new plan to reduce urban pollution, which includes a ban on gas-powered scooters, expansion of bike lanes, and free public transit passes for residents.
55
+ [End of Context]
56
+
57
+ [Start of Question]
58
+ What is the main point of the paragraph?
59
+ [End of Question]
60
+
61
+ [Start of Answer]
62
+ The city is taking steps to reduce pollution.
63
+ [End of Answer]
64
+
65
+ [Start of Evaluation]
66
+ The answer is factually correct and safe, but vague. It lacks depth and omits the key details about *how* the city plans to reduce pollution. It does not demonstrate full understanding of the context or question.
67
+ [End of Evaluation]
68
+
69
+ [Start of Score]
70
+ 2
71
+ [End of Score]
72
+
73
+ Example 3 — Score: 3 (Excellent Answer)
74
+
75
+ Task Description: Summarize the key point of a news paragraph in one sentence.
76
+
77
+ [Start of Context]
78
+ The mayor of Springfield unveiled a new plan to reduce urban pollution, which includes a ban on gas-powered scooters, expansion of bike lanes, and free public transit passes for residents.
79
+ [End of Context]
80
+
81
+ [Start of Question]
82
+ What is the main point of the paragraph?
83
+ [End of Question]
84
+
85
+ [Start of Answer]
86
+ The mayor of Springfield introduced a pollution-reduction plan that bans gas-powered scooters, expands bike lanes, and provides free transit passes to residents.
87
+ [End of Answer]
88
+
89
+ [Start of Evaluation]
90
+ The answer is complete, relevant, and clearly written. It captures the full intent and detail of the paragraph in a single well-structured sentence, demonstrating both factual understanding and clarity. It aligns perfectly with the task instruction.
91
+ [End of Evaluation]
92
+
93
+ [Start of Score]
94
+ 3
95
+ [End of Score]
32
96
 
33
97
  generation: |
34
- Begin your evaluation by providing a short explanation. Be as objective as possible. After providing your explanation, you must rate the answer on a scale of 1 to 3 as mentioned above.
35
- Here's the context, question and the answer you need to evaluate:
36
-
98
+ Now begin your evaluation of the following QA pair. Use the rubric above and be objective and concise in your reasoning.
99
+
100
+ Task Description: {{task_description}}
101
+
37
102
  [Start of Context]
38
103
  {{ context }}
39
104
  [End of Context]
@@ -46,9 +111,9 @@ generation: |
46
111
  {{ response }}
47
112
  [End of Answer]
48
113
 
49
- * Return the evaluation between [Start of Evaluation] and [End of Evaluation] tags.
50
- * Return the score between [Start of Score] and [End of Score] tags.
51
-
114
+ * Provide your evaluation between [Start of Evaluation] and [End of Evaluation] tags.
115
+ * Provide the score between [Start of Score] and [End of Score] tags.
116
+ * Do not include any content outside these tags.
52
117
 
53
118
  start_tags: ["[Start of Evaluation]", "[Start of Score]"]
54
119
  end_tags: ["[End of Evaluation]", "[End of Score]"]
@@ -1,29 +1,34 @@
1
- system: You are a very knowledgeable AI Assistant that will faithfully assist the user with their task.
1
+ system: You are a highly intelligent and helpful AI Assistant specializing in generating well-crafted questions tailored to specific tasks.
2
2
 
3
3
  introduction: |
4
- You are asked to come up with a set of {{ num_samples }} diverse questions - {{ task_description }}.
4
+ Your task is to generate {{num_samples}} diverse and well-structured questions for the following task:
5
+ "{{task_description}}"
5
6
 
6
7
  principles: |
7
- Please follow these guiding principles when generating responses:
8
- * Use proper grammar and punctuation.
9
- * Always generate safe and respectful content. Do not generate content that is harmful, abusive, or offensive.
10
- * Always generate content that is factually accurate and relevant to the prompt.
11
- * The questions should be clear and human-like.
12
- * The questions should be diverse and cover a wide range of topics.
13
- * The questions should not be template-based or generic, it should be very diverse.
14
- * Simply return the questions, do not return any answers or explanations.
15
- * Strictly adhere to the prompt and generate responses in the same style and format as the example.
16
- * Return each question between [Start of Question] and [End of Question] tags.
8
+ Please follow these strict guidelines when generating each question:
9
+ * Each question must be directly related to the task description.
10
+ * Use correct grammar, spelling, and punctuation.
11
+ * Questions must be clear, natural-sounding, and human-like.
12
+ * Do **not** include answers, explanations, or commentary—only the question.
13
+ * Ensure **maximum diversity** in wording and perspective—no repetitive or template-based phrasing.
14
+ * Each question must strictly follow the **exact same format and style** as shown in the example.
15
+ * Do **not deviate** from the example structure in any way.
16
+ * Wrap each question between `[Start of Question]` and `[End of Question]` tags.
17
17
 
18
18
  examples: |
19
- To better assist you with this task, here is an example:
20
-
19
+ To guide you, here is an example of a correctly formatted question:
20
+
21
21
  [Start of Question]
22
- {{ seed_question }}
22
+ {{seed_question}}
23
23
  [End of Question]
24
24
 
25
25
  generation: |
26
- Now generate {{ num_samples }} such questions, remember to follow the principles mentioned above and use the same format as the examples. Remember to use the same style and format as the example above. Return each question between [Start of Question] and [End of Question] tags.
26
+ Now generate {{num_samples}} such questions.
27
+ Ensure that each one is:
28
+ - Fully relevant to the task description.
29
+ - Consistent with the example format.
30
+ - Clearly enclosed between [Start of Question] and [End of Question] tags.
31
+ Do not include any content outside these tags.
27
32
 
28
33
  start_tags: ["[Start of Question]"]
29
34
  end_tags: ["[End of Question]"]
@@ -1,45 +1,39 @@
1
- system: You are a very knowledgeable AI Assistant that will faithfully assist the user with their task.
1
+ system: You are a highly knowledgeable and precise AI Assistant tasked with generating high-quality responses based strictly on user prompts.
2
2
 
3
- introduction: Your task is to faithfully follow the user's prompt and generate a response.
3
+ introduction: |
4
+ Your task is to carefully read and understand the user's prompt, and generate a well-structured response that directly addresses it.
4
5
 
5
6
  principles: |
6
- Please follow these guiding principles when generating responses:
7
- * Use proper grammar and punctuation.
8
- * Always generate safe and respectful content. Do not generate content that is harmful, abusive, or offensive.
9
- * Always generate content that is factually accurate and relevant to the prompt.
10
- * Strictly adhere to the prompt and generate responses in the same style and format as the example.
11
- * Return the response between [Start of Response] and [End of Response] tags.
7
+ Please follow these strict guidelines when generating your response:
8
+ * The response must be directly relevant to the given question and accurately fulfill its intent.
9
+ * The response should be clear, natural, and human-like in tone.
10
+ * You must strictly follow the **exact structure and formatting** shown in the example.
11
+ * Do **not** add any extra commentary, explanations, greetings, or metadata.
12
+ * The response must be enclosed between `[Start of Response]` and `[End of Response]` tags.
13
+ * Do **not** deviate from the formatting under any circumstance.
12
14
 
13
15
  examples: |
14
- To better assist you with this task, here is an example:
15
- {% if seed_samples is defined %}
16
- {% for sample in seed_samples %}
17
- [Start of Question]
18
- {{ sample.seed_question }}
19
- [End of Question]
16
+ Below is an example of a properly formatted question and response:
20
17
 
21
- [Start of Response]
22
- {{ sample.seed_response }}
23
- [End of Response]
24
- {% endfor %}
25
- {% else %}
26
18
  [Start of Question]
27
- {{ seed_question }}
19
+ {{seed_question}}
28
20
  [End of Question]
29
21
 
30
22
  [Start of Response]
31
- {{ seed_response }}
23
+ {{seed_response}}
32
24
  [End of Response]
33
- {% endif %}
34
25
 
35
26
  generation: |
36
- Now generate a response to the following prompt. Remember to use the same style and format as the example above.
27
+ Now generate a response to the following prompt. Make sure the response:
28
+ - Accurately addresses the question.
29
+ - Strictly follows the example format and style.
30
+ - Appears **only** between [Start of Response] and [End of Response] tags.
37
31
 
38
32
  [Start of Question]
39
- {{ question }}
33
+ {{question}}
40
34
  [End of Question]
41
35
 
42
- Return the response between [Start of Response] and [End of Response] tags.
36
+ Return only the response between the tags. Do not add anything outside.
43
37
 
44
38
  start_tags: ["[Start of Response]"]
45
39
  end_tags: ["[End of Response]"]
@@ -1,12 +1,59 @@
1
- system: ""
1
+ system: |
2
+ You are a skill classifier. Given a question or task, classify it into exactly one of the following categories:
3
+ - coding: Questions about programming, software development, algorithms, or technical implementation.
4
+ - extraction: Tasks that require identifying and pulling out specific pieces of information from text or data, without analysis or transformation. This includes extracting structured data and transforming it into a specific format.
5
+ - humanities: Questions about economics, social sciences, literature, history, philosophy, or arts that require analysis, comparison, or evaluation.
6
+ - math: Questions requiring mathematical calculations, proofs, probability, or numerical reasoning.
7
+ - reasoning: Tasks requiring logical deduction, problem-solving, or analytical thinking.
8
+ - roleplay: Scenarios requiring adopting a specific role, perspective, or character.
9
+ - stem: Questions about science, technology, engineering, or mathematics that require explaining technical or scientific concepts.
10
+ - writing: Tasks that require creating new content, compositions, or text generation.
2
11
 
3
- introduction: ""
12
+ Only output the category name, and nothing else. Please do not output anything except one of these exact words.
4
13
 
5
- principles: ""
14
+ introduction: |
15
+ Classify the given question into one of the predefined categories based on its primary focus and requirements.
6
16
 
7
- examples: ""
17
+ principles: |
18
+ 1. Each question should be classified into exactly one category.
19
+ 2. Choose the category that best represents the primary skill or domain required.
20
+ 3. If a question could fit multiple categories, choose the most specific one.
21
+ 4. Consider the main task or goal of the question, not just the subject matter.
22
+ 5. For extraction tasks, focus on questions that require pulling out specific information or data, often with specific formatting requirements, without significant analysis or creative generation.
23
+ 6. For humanities tasks, focus on questions that require analysis, comparison, or evaluation of social, cultural, or historical topics.
24
+ 7. For writing tasks, focus on questions that require creative or open-ended content generation or composition, rather than tasks with strict formatting or content extraction rules.
8
25
 
9
- generation: "{{ question }}"
26
+ examples: |
27
+ Question: Extract and categorize the health-related themes, such as 'symptoms', 'treatments', and 'prevention'
28
+ Category: extraction
29
+
30
+ Question: Summarize the story with three bullet points using only nouns and adjectives, without verbs.
31
+ Category: extraction
32
+
33
+ Question: Can you analyze the relationship between economic indicators like GDP, interest rates, and consumer behavior?
34
+ Category: humanities
35
+
36
+ Question: Calculate the area of a triangle with base 6 units and height 8 units
37
+ Category: math
38
+
39
+ Question: Suppose you are in a marathon and you just passed the person in third place. What position are you in?
40
+ Category: reasoning
41
+
42
+ Question: You are a medieval blacksmith. Describe your typical workday and the challenges you face
43
+ Category: roleplay
44
+
45
+ Question: In the realm of quantum mechanics, what is wave-particle duality, and how does it contribute to the understanding of quantum systems?
46
+ Category: STEM
47
+
48
+ Question: Write a travel blog post about exploring the ancient temples and street food scene in Bangkok, Thailand
49
+ Category: writing
50
+
51
+ generation: |
52
+ Question: {{ question }}
53
+
54
+ Based on the above question, classify it into exactly one of these categories: coding, extraction, humanities, math, reasoning, roleplay, STEM, or writing.
55
+
56
+ Category:
10
57
 
11
58
  start_tags: [""]
12
- end_tags: [""]
59
+ end_tags: [""]