palimpzest 0.7.21__py3-none-any.whl → 0.8.1__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 (89) hide show
  1. palimpzest/__init__.py +37 -6
  2. palimpzest/agents/__init__.py +0 -0
  3. palimpzest/agents/compute_agents.py +0 -0
  4. palimpzest/agents/search_agents.py +637 -0
  5. palimpzest/constants.py +343 -209
  6. palimpzest/core/data/context.py +393 -0
  7. palimpzest/core/data/context_manager.py +163 -0
  8. palimpzest/core/data/dataset.py +639 -0
  9. palimpzest/core/data/{datareaders.py → iter_dataset.py} +202 -126
  10. palimpzest/core/elements/groupbysig.py +16 -13
  11. palimpzest/core/elements/records.py +166 -75
  12. palimpzest/core/lib/schemas.py +152 -390
  13. palimpzest/core/{data/dataclasses.py → models.py} +306 -170
  14. palimpzest/policy.py +2 -27
  15. palimpzest/prompts/__init__.py +35 -5
  16. palimpzest/prompts/agent_prompts.py +357 -0
  17. palimpzest/prompts/context_search.py +9 -0
  18. palimpzest/prompts/convert_prompts.py +62 -6
  19. palimpzest/prompts/filter_prompts.py +51 -6
  20. palimpzest/prompts/join_prompts.py +163 -0
  21. palimpzest/prompts/moa_proposer_convert_prompts.py +6 -6
  22. palimpzest/prompts/prompt_factory.py +375 -47
  23. palimpzest/prompts/split_proposer_prompts.py +1 -1
  24. palimpzest/prompts/util_phrases.py +5 -0
  25. palimpzest/prompts/validator.py +239 -0
  26. palimpzest/query/execution/all_sample_execution_strategy.py +134 -76
  27. palimpzest/query/execution/execution_strategy.py +210 -317
  28. palimpzest/query/execution/execution_strategy_type.py +5 -7
  29. palimpzest/query/execution/mab_execution_strategy.py +249 -136
  30. palimpzest/query/execution/parallel_execution_strategy.py +153 -244
  31. palimpzest/query/execution/single_threaded_execution_strategy.py +107 -64
  32. palimpzest/query/generators/generators.py +160 -331
  33. palimpzest/query/operators/__init__.py +15 -5
  34. palimpzest/query/operators/aggregate.py +50 -33
  35. palimpzest/query/operators/compute.py +201 -0
  36. palimpzest/query/operators/convert.py +33 -19
  37. palimpzest/query/operators/critique_and_refine_convert.py +7 -5
  38. palimpzest/query/operators/distinct.py +62 -0
  39. palimpzest/query/operators/filter.py +26 -16
  40. palimpzest/query/operators/join.py +403 -0
  41. palimpzest/query/operators/limit.py +3 -3
  42. palimpzest/query/operators/logical.py +205 -77
  43. palimpzest/query/operators/mixture_of_agents_convert.py +10 -8
  44. palimpzest/query/operators/physical.py +27 -21
  45. palimpzest/query/operators/project.py +3 -3
  46. palimpzest/query/operators/rag_convert.py +7 -7
  47. palimpzest/query/operators/retrieve.py +9 -9
  48. palimpzest/query/operators/scan.py +81 -42
  49. palimpzest/query/operators/search.py +524 -0
  50. palimpzest/query/operators/split_convert.py +10 -8
  51. palimpzest/query/optimizer/__init__.py +7 -9
  52. palimpzest/query/optimizer/cost_model.py +108 -441
  53. palimpzest/query/optimizer/optimizer.py +123 -181
  54. palimpzest/query/optimizer/optimizer_strategy.py +66 -61
  55. palimpzest/query/optimizer/plan.py +352 -67
  56. palimpzest/query/optimizer/primitives.py +43 -19
  57. palimpzest/query/optimizer/rules.py +484 -646
  58. palimpzest/query/optimizer/tasks.py +127 -58
  59. palimpzest/query/processor/config.py +42 -76
  60. palimpzest/query/processor/query_processor.py +73 -18
  61. palimpzest/query/processor/query_processor_factory.py +46 -38
  62. palimpzest/schemabuilder/schema_builder.py +15 -28
  63. palimpzest/utils/model_helpers.py +32 -77
  64. palimpzest/utils/progress.py +114 -102
  65. palimpzest/validator/__init__.py +0 -0
  66. palimpzest/validator/validator.py +306 -0
  67. {palimpzest-0.7.21.dist-info → palimpzest-0.8.1.dist-info}/METADATA +6 -1
  68. palimpzest-0.8.1.dist-info/RECORD +95 -0
  69. palimpzest/core/lib/fields.py +0 -141
  70. palimpzest/prompts/code_synthesis_prompts.py +0 -28
  71. palimpzest/query/execution/random_sampling_execution_strategy.py +0 -240
  72. palimpzest/query/generators/api_client_factory.py +0 -30
  73. palimpzest/query/operators/code_synthesis_convert.py +0 -488
  74. palimpzest/query/operators/map.py +0 -130
  75. palimpzest/query/processor/nosentinel_processor.py +0 -33
  76. palimpzest/query/processor/processing_strategy_type.py +0 -28
  77. palimpzest/query/processor/sentinel_processor.py +0 -88
  78. palimpzest/query/processor/streaming_processor.py +0 -149
  79. palimpzest/sets.py +0 -405
  80. palimpzest/utils/datareader_helpers.py +0 -61
  81. palimpzest/utils/demo_helpers.py +0 -75
  82. palimpzest/utils/field_helpers.py +0 -69
  83. palimpzest/utils/generation_helpers.py +0 -69
  84. palimpzest/utils/sandbox.py +0 -183
  85. palimpzest-0.7.21.dist-info/RECORD +0 -95
  86. /palimpzest/core/{elements/index.py → data/index_dataset.py} +0 -0
  87. {palimpzest-0.7.21.dist-info → palimpzest-0.8.1.dist-info}/WHEEL +0 -0
  88. {palimpzest-0.7.21.dist-info → palimpzest-0.8.1.dist-info}/licenses/LICENSE +0 -0
  89. {palimpzest-0.7.21.dist-info → palimpzest-0.8.1.dist-info}/top_level.txt +0 -0
@@ -12,8 +12,8 @@ INPUT FIELDS:
12
12
  {example_input_fields}
13
13
 
14
14
  CONTEXT:
15
- {example_context}
16
- {image_disclaimer}
15
+ {example_context}{image_disclaimer}{audio_disclaimer}
16
+
17
17
  FILTER CONDITION: {example_filter_condition}
18
18
 
19
19
  Let's think step-by-step in order to answer the question.
@@ -24,31 +24,67 @@ ANSWER: TRUE
24
24
  ---
25
25
  """
26
26
 
27
- COT_BOOL_BASE_USER_PROMPT = """You are a helpful assistant whose job is to {job_instruction}.
27
+ COT_BOOL_NO_REASONING_BASE_SYSTEM_PROMPT = """You are a helpful assistant whose job is to {job_instruction}.
28
28
  You will be presented with a context and a filter condition. Output TRUE if the context satisfies the filter condition, and FALSE otherwise.
29
29
 
30
+ Remember, your answer must be TRUE or FALSE. Finish your response with a newline character followed by ---
31
+
32
+ An example is shown below:
33
+ ---
34
+ INPUT FIELDS:
35
+ {example_input_fields}
36
+
37
+ CONTEXT:
38
+ {example_context}{image_disclaimer}{audio_disclaimer}
39
+
40
+ FILTER CONDITION: {example_filter_condition}
41
+
42
+ ANSWER: TRUE
43
+ ---
44
+ """
45
+
46
+ COT_BOOL_BASE_USER_PROMPT = """You are a helpful assistant whose job is to {job_instruction}.
47
+ You will be presented with a context and a filter condition. Output TRUE if the context satisfies the filter condition, and FALSE otherwise.
48
+ {desc_section}
30
49
  Remember, your answer must be TRUE or FALSE. Finish your response with a newline character followed by ---
31
50
  ---
32
51
  INPUT FIELDS:
33
52
  {input_fields_desc}
34
53
 
35
54
  CONTEXT:
36
- {context}
37
- <<image-placeholder>>
55
+ {context}<<image-placeholder>><<audio-placeholder>>
56
+
38
57
  FILTER CONDITION: {filter_condition}
39
58
 
40
59
  Let's think step-by-step in order to answer the question.
41
60
 
42
61
  REASONING: """
43
62
 
63
+ COT_BOOL_NO_REASONING_BASE_USER_PROMPT = """You are a helpful assistant whose job is to {job_instruction}.
64
+ You will be presented with a context and a filter condition. Output TRUE if the context satisfies the filter condition, and FALSE otherwise.
65
+ {desc_section}
66
+ Remember, your answer must be TRUE or FALSE. Finish your response with a newline character followed by ---
67
+ ---
68
+ INPUT FIELDS:
69
+ {input_fields_desc}
70
+
71
+ CONTEXT:
72
+ {context}<<image-placeholder>><<audio-placeholder>>
73
+
74
+ FILTER CONDITION: {filter_condition}
75
+
76
+ ANSWER: """
44
77
 
45
78
  ### TEMPLATE INPUTS ###
46
79
  COT_BOOL_JOB_INSTRUCTION = """answer a TRUE / FALSE question"""
47
80
  COT_BOOL_IMAGE_JOB_INSTRUCTION = """analyze input image(s) and/or text in order to answer a TRUE / FALSE question"""
81
+ COT_BOOL_AUDIO_JOB_INSTRUCTION = """analyze input audio and/or text in order to answer a TRUE / FALSE question"""
48
82
 
49
83
  COT_BOOL_EXAMPLE_INPUT_FIELDS = """- text: a short passage of text"""
50
84
  COT_BOOL_IMAGE_EXAMPLE_INPUT_FIELDS = """- image: an image of a scene
51
85
  - photographer: the photographer of the image"""
86
+ COT_BOOL_AUDIO_EXAMPLE_INPUT_FIELDS = """- recording: an audio recording of a newscast
87
+ - speaker: the name of the speaker in the recording"""
52
88
 
53
89
  COT_BOOL_EXAMPLE_CONTEXT = """{{
54
90
  "text": "The quick brown fox jumps over the lazy dog."
@@ -57,13 +93,22 @@ COT_BOOL_IMAGE_EXAMPLE_CONTEXT = """{{
57
93
  "image": <bytes>,
58
94
  "photographer": "CameraEnthusiast1"
59
95
  }}"""
96
+ COT_BOOL_AUDIO_EXAMPLE_CONTEXT = """{{
97
+ "recording": <bytes>,
98
+ "speaker": "Walter Cronkite"
99
+ }}"""
60
100
 
61
101
  COT_BOOL_EXAMPLE_FILTER_CONDITION = "the text mentions an animal"
62
102
  COT_BOOL_IMAGE_EXAMPLE_FILTER_CONDITION = "there's an animal in this image"
103
+ COT_BOOL_AUDIO_EXAMPLE_FILTER_CONDITION = "the newscast discusses a flashpoint in the Cold War"
63
104
 
64
105
  COT_BOOL_IMAGE_DISCLAIMER = """
65
- <image content provided here; assume in this example the image shows a dog and a cat playing>
106
+ \n<image content provided here; assume in this example the image shows a dog and a cat playing>
107
+ """
108
+ COT_BOOL_AUDIO_DISCLAIMER = """
109
+ \n<audio content provided here; assume in this example the recording is about the Cuban Missile Crisis>
66
110
  """
67
111
 
68
112
  COT_BOOL_EXAMPLE_REASONING = """the text mentions the words "fox" and "dog" which are animals, therefore the answer is TRUE."""
69
113
  COT_BOOL_IMAGE_EXAMPLE_REASONING = """the image shows a dog and a cat playing, both of which are animals, therefore the answer is TRUE."""
114
+ COT_BOOL_AUDIO_EXAMPLE_REASONING = """the newscast discusses the Cuban Missile Crisis, which was a flashpoint in the Cold War, therefore the answer is TRUE."""
@@ -0,0 +1,163 @@
1
+ """This file contains prompts for join operations."""
2
+
3
+ ### BASE PROMPTS ###
4
+ COT_JOIN_BASE_SYSTEM_PROMPT = """You are a helpful assistant whose job is to {job_instruction}.
5
+ You will be presented with two data records and a join condition. Output TRUE if the two data records satisfy the join condition, and FALSE otherwise.
6
+
7
+ Remember, your answer must be TRUE or FALSE. Finish your response with a newline character followed by ---
8
+
9
+ An example is shown below:
10
+ ---
11
+ LEFT INPUT FIELDS:
12
+ {example_input_fields}
13
+
14
+ LEFT CONTEXT:
15
+ {example_context}{image_disclaimer}{audio_disclaimer}
16
+
17
+ RIGHT INPUT FIELDS:
18
+ {right_example_input_fields}
19
+
20
+ RIGHT CONTEXT:
21
+ {right_example_context}{right_image_disclaimer}{right_audio_disclaimer}
22
+
23
+ JOIN CONDITION: {example_join_condition}
24
+
25
+ Let's think step-by-step in order to evaluate the join condition.
26
+
27
+ REASONING: {example_reasoning}
28
+
29
+ ANSWER: TRUE
30
+ ---
31
+ """
32
+
33
+ COT_JOIN_NO_REASONING_BASE_SYSTEM_PROMPT = """You are a helpful assistant whose job is to {job_instruction}.
34
+ You will be presented with two data records and a join condition. Output TRUE if the two data records satisfy the join condition, and FALSE otherwise.
35
+
36
+ Remember, your answer must be TRUE or FALSE. Finish your response with a newline character followed by ---
37
+
38
+ An example is shown below:
39
+ ---
40
+ LEFT INPUT FIELDS:
41
+ {example_input_fields}
42
+
43
+ LEFT CONTEXT:
44
+ {example_context}{image_disclaimer}{audio_disclaimer}
45
+
46
+ RIGHT INPUT FIELDS:
47
+ {right_example_input_fields}
48
+
49
+ RIGHT CONTEXT:
50
+ {right_example_context}{right_image_disclaimer}{right_audio_disclaimer}
51
+
52
+ JOIN CONDITION: {example_join_condition}
53
+
54
+ ANSWER: TRUE
55
+ ---
56
+ """
57
+
58
+ COT_JOIN_BASE_USER_PROMPT = """You are a helpful assistant whose job is to {job_instruction}.
59
+ You will be presented with two data records and a join condition. Output TRUE if the two data records satisfy the join condition, and FALSE otherwise.
60
+ {desc_section}
61
+ Remember, your answer must be TRUE or FALSE. Finish your response with a newline character followed by ---
62
+ ---
63
+ LEFT INPUT FIELDS:
64
+ {input_fields_desc}
65
+
66
+ LEFT CONTEXT:
67
+ {context}<<image-placeholder>><<audio-placeholder>>
68
+
69
+ RIGHT INPUT FIELDS:
70
+ {right_input_fields_desc}
71
+
72
+ RIGHT CONTEXT:
73
+ {right_context}<<image-placeholder>><<audio-placeholder>>
74
+
75
+ JOIN CONDITION: {join_condition}
76
+
77
+ Let's think step-by-step in order to evaluate the join condition.
78
+
79
+ REASONING: """
80
+
81
+ COT_JOIN_NO_REASONING_BASE_USER_PROMPT = """You are a helpful assistant whose job is to {job_instruction}.
82
+ You will be presented with two data records and a join condition. Output TRUE if the two data records satisfy the join condition, and FALSE otherwise.
83
+ {desc_section}
84
+ Remember, your answer must be TRUE or FALSE. Finish your response with a newline character followed by ---
85
+ ---
86
+ LEFT INPUT FIELDS:
87
+ {input_fields_desc}
88
+
89
+ LEFT CONTEXT:
90
+ {context}<<image-placeholder>><<audio-placeholder>>
91
+
92
+ RIGHT INPUT FIELDS:
93
+ {right_input_fields_desc}
94
+
95
+ RIGHT CONTEXT:
96
+ {right_context}<<image-placeholder>><<audio-placeholder>>
97
+
98
+ JOIN CONDITION: {join_condition}
99
+
100
+ ANSWER: """
101
+
102
+
103
+ ### TEMPLATE INPUTS ###
104
+ COT_JOIN_JOB_INSTRUCTION = """determine whether two data records satisfy a join condition"""
105
+ COT_JOIN_IMAGE_JOB_INSTRUCTION = """analyze input image(s) and/or text in order to determine whether two data records satisfy a join condition"""
106
+ COT_JOIN_AUDIO_JOB_INSTRUCTION = """analyze input audio and/or text in order to determine whether two data records satisfy a join condition"""
107
+
108
+ COT_JOIN_EXAMPLE_INPUT_FIELDS = """- text: a short passage of text"""
109
+ COT_JOIN_IMAGE_EXAMPLE_INPUT_FIELDS = """- image: an image of a scene
110
+ - photographer: the photographer of the image"""
111
+ COT_JOIN_AUDIO_EXAMPLE_INPUT_FIELDS = """- recording: an audio recording of a newscast
112
+ - speaker: the name of the speaker in the recording"""
113
+
114
+ COT_JOIN_RIGHT_EXAMPLE_INPUT_FIELDS = """- contents: the contents of a text file"""
115
+ COT_JOIN_IMAGE_RIGHT_EXAMPLE_INPUT_FIELDS = """- image: an image of a scene
116
+ - photographer: the photographer of the image"""
117
+ COT_JOIN_AUDIO_RIGHT_EXAMPLE_INPUT_FIELDS = """- recording: an audio recording of a newscast
118
+ - speaker: the name of the speaker in the recording"""
119
+
120
+ COT_JOIN_EXAMPLE_CONTEXT = """{{
121
+ "text": "The quick brown fox jumps over the lazy dog."
122
+ }}"""
123
+ COT_JOIN_IMAGE_EXAMPLE_CONTEXT = """{{
124
+ "image": <bytes>,
125
+ "photographer": "CameraEnthusiast1"
126
+ }}"""
127
+ COT_JOIN_AUDIO_EXAMPLE_CONTEXT = """{{
128
+ "recording": <bytes>,
129
+ "speaker": "Walter Cronkite"
130
+ }}"""
131
+
132
+ COT_JOIN_RIGHT_EXAMPLE_CONTEXT = """{{
133
+ "contents": "Foxes are wild animals which primarily hunt small mammals like rabbits and rodents."
134
+ }}"""
135
+ COT_JOIN_IMAGE_RIGHT_EXAMPLE_CONTEXT = """{{
136
+ "image": <bytes>,
137
+ "filename": "img123.png"
138
+ }}"""
139
+ COT_JOIN_AUDIO_RIGHT_EXAMPLE_CONTEXT = """{{
140
+ "recording": <bytes>,
141
+ "speaker": "Barbara Walters"
142
+ }}"""
143
+
144
+ COT_JOIN_EXAMPLE_JOIN_CONDITION = "each record mentions the same animal"
145
+ COT_JOIN_IMAGE_EXAMPLE_JOIN_CONDITION = "the images are of the same subject"
146
+ COT_JOIN_AUDIO_EXAMPLE_JOIN_CONDITION = "the recordings are about the same subject"
147
+
148
+ COT_JOIN_IMAGE_DISCLAIMER = """
149
+ \n<image content provided here; assume in this example the image shows a horse in a field>
150
+ """
151
+ COT_JOIN_AUDIO_DISCLAIMER = """
152
+ \n<audio content provided here; assume in this example the recording is about the Cuban Missile Crisis>
153
+ """
154
+ COT_JOIN_RIGHT_IMAGE_DISCLAIMER = """
155
+ \n<image content provided here; assume in this example the image shows a horse in its stable>
156
+ """
157
+ COT_JOIN_RIGHT_AUDIO_DISCLAIMER = """
158
+ \n<audio content provided here; assume in this example the recording is from a telecast about the Cuban Missile Crisis's historical significance>
159
+ """
160
+
161
+ COT_JOIN_EXAMPLE_REASONING = """both passages mention a fox, which is the same animal, therefore the answer is TRUE."""
162
+ COT_JOIN_IMAGE_EXAMPLE_REASONING = """both images show a horse, which appears to be the main subject of each image, therefore the answer is TRUE."""
163
+ COT_JOIN_AUDIO_EXAMPLE_REASONING = """both recordings discuss the Cuban Missile Crisis, which is the same subject, therefore the answer is TRUE."""
@@ -16,8 +16,8 @@ OUTPUT FIELDS:
16
16
  {example_output_fields}
17
17
 
18
18
  CONTEXT:
19
- {example_context}
20
- {image_disclaimer}
19
+ {example_context}{image_disclaimer}
20
+
21
21
  Let's think step-by-step in order to answer the question.
22
22
 
23
23
  ANSWER: {example_answer}
@@ -27,7 +27,7 @@ ANSWER: {example_answer}
27
27
  COT_MOA_PROPOSER_BASE_USER_PROMPT = """You are a helpful assistant whose job is to {job_instruction}.
28
28
  You will be presented with a context and a set of output fields to generate. Your task is to generate a paragraph or two which describes what you believe is the correct value for each output field.
29
29
  Be sure to cite information from the context as evidence of why your answers are correct. Do not hallucinate evidence.
30
-
30
+ {desc_section}
31
31
  You will be provided with a description of each input field and each output field.
32
32
  ---
33
33
  INPUT FIELDS:
@@ -37,8 +37,8 @@ OUTPUT FIELDS:
37
37
  {output_fields_desc}
38
38
 
39
39
  CONTEXT:
40
- {context}
41
- <<image-placeholder>>
40
+ {context}<<image-placeholder>>
41
+
42
42
  Let's think step-by-step in order to answer the question.
43
43
 
44
44
  ANSWER: """
@@ -68,7 +68,7 @@ COT_MOA_PROPOSER_IMAGE_EXAMPLE_CONTEXT = """{{
68
68
  }}"""
69
69
 
70
70
  COT_MOA_PROPOSER_IMAGE_DISCLAIMER = """
71
- <image content provided here; assume in this example the image shows a dog and a cat playing>
71
+ \n<image content provided here; assume in this example the image shows a dog and a cat playing>
72
72
  """
73
73
 
74
74
  COT_MOA_PROPOSER_EXAMPLE_ANSWER = """the text passage mentions the scientist's name as "Augusta Ada King, Countess of Lovelace, also known as Ada Lovelace" and the scientist's birthday as "December 10, 1815". Therefore, the name of the scientist is "Augusta Ada King" and the birth year is 1815."""