autoddg 0.1.0__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.
- autoddg/__init__.py +36 -0
- autoddg/autoddg.py +324 -0
- autoddg/configurations/__init__.py +0 -0
- autoddg/configurations/prompts.yaml +236 -0
- autoddg/description/__init__.py +6 -0
- autoddg/description/generator.py +130 -0
- autoddg/description/search.py +59 -0
- autoddg/evaluation/__init__.py +20 -0
- autoddg/evaluation/base.py +59 -0
- autoddg/evaluation/openai.py +34 -0
- autoddg/evaluation/pairwise.py +239 -0
- autoddg/llm/__init__.py +7 -0
- autoddg/llm/base.py +33 -0
- autoddg/llm/local.py +293 -0
- autoddg/llm/openai_compat.py +68 -0
- autoddg/profiling/__init__.py +6 -0
- autoddg/profiling/semantic.py +405 -0
- autoddg/profiling/summary.py +87 -0
- autoddg/ranking/__init__.py +18 -0
- autoddg/ranking/metrics.py +123 -0
- autoddg/ranking/qrels.py +32 -0
- autoddg/search/__init__.py +5 -0
- autoddg/search/engine.py +173 -0
- autoddg/topic/__init__.py +5 -0
- autoddg/topic/generator.py +68 -0
- autoddg/utils/__init__.py +14 -0
- autoddg/utils/descriptions.py +105 -0
- autoddg/utils/logging.py +24 -0
- autoddg/utils/prompts.py +29 -0
- autoddg/utils/sampling.py +28 -0
- autoddg-0.1.0.dist-info/METADATA +470 -0
- autoddg-0.1.0.dist-info/RECORD +35 -0
- autoddg-0.1.0.dist-info/WHEEL +4 -0
- autoddg-0.1.0.dist-info/entry_points.txt +4 -0
- autoddg-0.1.0.dist-info/licenses/LICENSE +201 -0
autoddg/__init__.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from .autoddg import AutoDDG
|
|
4
|
+
from .description import DatasetDescriptionGenerator, SearchFocusedDescription
|
|
5
|
+
from .evaluation import (
|
|
6
|
+
GPT4oMiniPairwiseEvaluator,
|
|
7
|
+
GPT4oPairwiseEvaluator,
|
|
8
|
+
GPTEvaluator,
|
|
9
|
+
LLaMAEvaluator,
|
|
10
|
+
LLaMAPairwiseEvaluator,
|
|
11
|
+
PairwiseEvaluator,
|
|
12
|
+
)
|
|
13
|
+
from .llm import LLMClient, LocalLLMClient, OpenAICompatibleClient
|
|
14
|
+
from .profiling import SemanticProfiler, profile_dataset
|
|
15
|
+
from .topic import DatasetTopicGenerator
|
|
16
|
+
|
|
17
|
+
__version__ = "0.1.0"
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"AutoDDG",
|
|
21
|
+
"DatasetDescriptionGenerator",
|
|
22
|
+
"DatasetTopicGenerator",
|
|
23
|
+
"GPTEvaluator",
|
|
24
|
+
"LLaMAEvaluator",
|
|
25
|
+
"PairwiseEvaluator",
|
|
26
|
+
"GPT4oPairwiseEvaluator",
|
|
27
|
+
"GPT4oMiniPairwiseEvaluator",
|
|
28
|
+
"LLaMAPairwiseEvaluator",
|
|
29
|
+
"LLMClient",
|
|
30
|
+
"LocalLLMClient",
|
|
31
|
+
"OpenAICompatibleClient",
|
|
32
|
+
"SearchFocusedDescription",
|
|
33
|
+
"SemanticProfiler",
|
|
34
|
+
"profile_dataset",
|
|
35
|
+
"__version__",
|
|
36
|
+
]
|
autoddg/autoddg.py
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from beartype import beartype
|
|
6
|
+
from pandas import DataFrame
|
|
7
|
+
|
|
8
|
+
from .description import DatasetDescriptionGenerator, SearchFocusedDescription
|
|
9
|
+
from .evaluation import BaseEvaluator
|
|
10
|
+
from .llm import LocalLLMClient, OpenAICompatibleClient
|
|
11
|
+
from .profiling import SemanticProfiler, profile_dataset
|
|
12
|
+
from .topic import DatasetTopicGenerator
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@beartype
|
|
16
|
+
class AutoDDG:
|
|
17
|
+
"""AutoDDG - Automated Dataset Description Generator
|
|
18
|
+
|
|
19
|
+
AutoDDG is the library's entry class, exposing:
|
|
20
|
+
* profiling,
|
|
21
|
+
* semantic analysis,
|
|
22
|
+
* topic generation,
|
|
23
|
+
* dataset description,
|
|
24
|
+
* search-focused description expansion, and
|
|
25
|
+
* optional description evaluation
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
client (Any): OpenAI-compatible client (e.g. ``openai.OpenAI(...)``) or None
|
|
29
|
+
for local LLM.
|
|
30
|
+
model_name (str): Model identifier (e.g. ``"gpt-4o"`` for API or
|
|
31
|
+
``"Qwen/Qwen2.5-7B-Instruct"`` for local).
|
|
32
|
+
use_local_llm (bool): If True, use local LLM via transformers.
|
|
33
|
+
Requires transformers and torch.
|
|
34
|
+
local_llm_device (str | None): Device for local LLM ("cuda", "cpu", or None
|
|
35
|
+
for auto).
|
|
36
|
+
local_llm_dtype (str | None): Data type for local LLM ("float16", "bfloat16",
|
|
37
|
+
"float32", or None for auto).
|
|
38
|
+
description_temperature (float): Temperature for description generation.
|
|
39
|
+
description_words (int): Target word count for generated descriptions.
|
|
40
|
+
search_model_name (str | None): Override model for search-expansion.
|
|
41
|
+
semantic_model_name (str | None): Override model for semantic profiling.
|
|
42
|
+
topic_temperature (float): Temperature for topic generation.
|
|
43
|
+
evaluator (BaseEvaluator | None): Optional evaluator for quality scoring.
|
|
44
|
+
|
|
45
|
+
Examples:
|
|
46
|
+
Basic usage with API:
|
|
47
|
+
|
|
48
|
+
>>> import openai
|
|
49
|
+
>>> from autoddg import AutoDDG
|
|
50
|
+
>>> client = openai.OpenAI(api_key="sk-...")
|
|
51
|
+
>>> pipe = AutoDDG(
|
|
52
|
+
... client=client, model_name="gpt-4o", description_words=100
|
|
53
|
+
... )
|
|
54
|
+
>>> sample_csv = (
|
|
55
|
+
... "city,country,population\\nLondon,UK,8908081\\nLeeds,UK,789194"
|
|
56
|
+
... )
|
|
57
|
+
>>> prompt, desc = pipe.describe_dataset(dataset_sample=sample_csv)
|
|
58
|
+
>>> print(desc)
|
|
59
|
+
|
|
60
|
+
Basic usage with local LLM:
|
|
61
|
+
|
|
62
|
+
>>> from autoddg import AutoDDG
|
|
63
|
+
>>> pipe = AutoDDG(
|
|
64
|
+
... client=None,
|
|
65
|
+
... model_name="Qwen/Qwen2.5-7B-Instruct",
|
|
66
|
+
... use_local_llm=True,
|
|
67
|
+
... description_words=100
|
|
68
|
+
... )
|
|
69
|
+
>>> sample_csv = (
|
|
70
|
+
... "city,country,population\\nLondon,UK,8908081\\nLeeds,UK,789194"
|
|
71
|
+
... )
|
|
72
|
+
>>> prompt, desc = pipe.describe_dataset(dataset_sample=sample_csv)
|
|
73
|
+
>>> print(desc)
|
|
74
|
+
|
|
75
|
+
Advanced usage with topic and evaluator:
|
|
76
|
+
|
|
77
|
+
>>> import pandas as pd
|
|
78
|
+
>>> from autoddg import GPTEvaluator
|
|
79
|
+
>>> df = pd.DataFrame({
|
|
80
|
+
... "city": ["London", "Leeds"],
|
|
81
|
+
... "country": ["UK", "UK"],
|
|
82
|
+
... "population": [8908081, 789194],
|
|
83
|
+
... })
|
|
84
|
+
>>> profile, semantic = pipe.profile_dataframe(df)
|
|
85
|
+
>>> topic = pipe.generate_topic("UK Cities", None, df.to_csv(index=False))
|
|
86
|
+
>>> _, desc = pipe.describe_dataset(
|
|
87
|
+
... dataset_sample=df.to_csv(index=False),
|
|
88
|
+
... dataset_profile=profile,
|
|
89
|
+
... use_profile=True,
|
|
90
|
+
... semantic_profile=semantic,
|
|
91
|
+
... use_semantic_profile=True,
|
|
92
|
+
... data_topic=topic, use_topic=True,
|
|
93
|
+
... )
|
|
94
|
+
>>> evaluator = GPTEvaluator(gpt4_api_key="sk-...")
|
|
95
|
+
>>> pipe.set_evaluator(evaluator)
|
|
96
|
+
>>> scores = pipe.evaluate_description(desc)
|
|
97
|
+
>>> print(scores)
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
def __init__(
|
|
101
|
+
self,
|
|
102
|
+
client: Any | None = None,
|
|
103
|
+
model_name: str = "gpt-4o",
|
|
104
|
+
*,
|
|
105
|
+
use_local_llm: bool = False,
|
|
106
|
+
local_llm_device: str | None = None,
|
|
107
|
+
local_llm_dtype: str | None = None,
|
|
108
|
+
description_temperature: float = 0.0,
|
|
109
|
+
description_words: int = 100,
|
|
110
|
+
search_model_name: str | None = None,
|
|
111
|
+
semantic_model_name: str | None = None,
|
|
112
|
+
topic_temperature: float = 0.0,
|
|
113
|
+
evaluator: BaseEvaluator | None = None,
|
|
114
|
+
) -> None:
|
|
115
|
+
# Initialize LLM client
|
|
116
|
+
if use_local_llm:
|
|
117
|
+
if client is not None:
|
|
118
|
+
raise ValueError(
|
|
119
|
+
"Cannot specify both client and use_local_llm=True. "
|
|
120
|
+
"For local LLM, set client=None and use_local_llm=True."
|
|
121
|
+
)
|
|
122
|
+
llm_client = LocalLLMClient(
|
|
123
|
+
model_name=model_name,
|
|
124
|
+
device=local_llm_device,
|
|
125
|
+
torch_dtype=local_llm_dtype,
|
|
126
|
+
)
|
|
127
|
+
elif client is not None:
|
|
128
|
+
llm_client = OpenAICompatibleClient(client)
|
|
129
|
+
else:
|
|
130
|
+
raise ValueError(
|
|
131
|
+
"Must provide either client (for API) or set use_local_llm=True " "(for local LLM)"
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
self.client = client # Keep for backward compatibility
|
|
135
|
+
self.model_name = model_name
|
|
136
|
+
self.description_generator = DatasetDescriptionGenerator(
|
|
137
|
+
client=llm_client,
|
|
138
|
+
model_name=model_name,
|
|
139
|
+
temperature=description_temperature,
|
|
140
|
+
description_words=description_words,
|
|
141
|
+
)
|
|
142
|
+
self.semantic_profiler = SemanticProfiler(
|
|
143
|
+
client=llm_client,
|
|
144
|
+
model_name=semantic_model_name or model_name,
|
|
145
|
+
)
|
|
146
|
+
self.topic_generator = DatasetTopicGenerator(
|
|
147
|
+
client=llm_client,
|
|
148
|
+
model_name=model_name,
|
|
149
|
+
temperature=topic_temperature,
|
|
150
|
+
)
|
|
151
|
+
self.search_description = SearchFocusedDescription(
|
|
152
|
+
client=llm_client,
|
|
153
|
+
model_name=search_model_name or model_name,
|
|
154
|
+
)
|
|
155
|
+
self.evaluator = evaluator
|
|
156
|
+
|
|
157
|
+
def describe_dataset(
|
|
158
|
+
self,
|
|
159
|
+
dataset_sample: str,
|
|
160
|
+
dataset_profile: str | None = None,
|
|
161
|
+
use_profile: bool = False,
|
|
162
|
+
semantic_profile: str | None = None,
|
|
163
|
+
use_semantic_profile: bool = False,
|
|
164
|
+
data_topic: str | None = None,
|
|
165
|
+
use_topic: bool = False,
|
|
166
|
+
) -> tuple[str, str]:
|
|
167
|
+
"""
|
|
168
|
+
Produce a short description from a CSV sample with optional context
|
|
169
|
+
|
|
170
|
+
Args:
|
|
171
|
+
dataset_sample: CSV text containing example rows
|
|
172
|
+
dataset_profile: Structural profile text
|
|
173
|
+
use_profile: Include the structural profile if True
|
|
174
|
+
semantic_profile: Natural-language column semantics
|
|
175
|
+
use_semantic_profile: Include the semantic profile if True
|
|
176
|
+
data_topic: Short topic string for the dataset
|
|
177
|
+
use_topic: Include the topic if True
|
|
178
|
+
|
|
179
|
+
Returns:
|
|
180
|
+
(prompt, description)
|
|
181
|
+
"""
|
|
182
|
+
|
|
183
|
+
return self.description_generator.generate_description(
|
|
184
|
+
dataset_sample=dataset_sample,
|
|
185
|
+
dataset_profile=dataset_profile,
|
|
186
|
+
use_profile=use_profile,
|
|
187
|
+
semantic_profile=semantic_profile,
|
|
188
|
+
use_semantic_profile=use_semantic_profile,
|
|
189
|
+
data_topic=data_topic,
|
|
190
|
+
use_topic=use_topic,
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
def profile_dataframe(self, dataframe: DataFrame) -> tuple[str, str]:
|
|
194
|
+
"""
|
|
195
|
+
Summarise structure and coverage using the datamart profiler
|
|
196
|
+
|
|
197
|
+
Ref: https://pypi.org/project/datamart-profiler/
|
|
198
|
+
|
|
199
|
+
Args:
|
|
200
|
+
dataframe: Input frame
|
|
201
|
+
|
|
202
|
+
Returns:
|
|
203
|
+
(profile_text, semantic_notes)
|
|
204
|
+
"""
|
|
205
|
+
|
|
206
|
+
return profile_dataset(dataframe)
|
|
207
|
+
|
|
208
|
+
def analyze_semantics(
|
|
209
|
+
self,
|
|
210
|
+
dataframe: DataFrame,
|
|
211
|
+
*,
|
|
212
|
+
use_group_prompting: bool = False,
|
|
213
|
+
use_multi_threading: bool = False,
|
|
214
|
+
use_batch_processing: bool = False,
|
|
215
|
+
max_workers: int | None = None,
|
|
216
|
+
group_size: int = 0,
|
|
217
|
+
batch_size: int = 4,
|
|
218
|
+
) -> str:
|
|
219
|
+
"""
|
|
220
|
+
Infer column semantics with an LLM and return a short overview
|
|
221
|
+
|
|
222
|
+
Processing modes available:
|
|
223
|
+
1. Sequential mode (default): Processes columns one by one sequentially.
|
|
224
|
+
2. Multi-threaded mode (use_multi_threading=True): Uses multi-threading to
|
|
225
|
+
process columns in parallel for faster execution. Only available for
|
|
226
|
+
OpenAI API clients.
|
|
227
|
+
3. Group mode (use_group_prompting=True): Processes columns in groups via
|
|
228
|
+
group prompting, reducing API calls.
|
|
229
|
+
- If group_size=0: Processes all columns in a single prompt (most
|
|
230
|
+
efficient).
|
|
231
|
+
- If group_size>0: Processes columns in groups of group_size.
|
|
232
|
+
4. Batch mode (use_batch_processing=True): Processes columns in batches
|
|
233
|
+
using batch inference. Only available for local LLMs. Takes precedence
|
|
234
|
+
over other modes.
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
dataframe: Input frame
|
|
238
|
+
use_group_prompting: If True, use group prompting (single API call for all
|
|
239
|
+
columns or groups). Takes precedence over use_multi_threading.
|
|
240
|
+
use_multi_threading: If True, use multi-threading for individual column
|
|
241
|
+
processing (only used if use_group_prompting=False and
|
|
242
|
+
use_batch_processing=False). Only works with OpenAI API clients.
|
|
243
|
+
use_batch_processing: If True, use batch processing for local LLMs.
|
|
244
|
+
Only works with LocalLLMClient. Takes precedence over other modes.
|
|
245
|
+
max_workers: Maximum number of concurrent workers for multi-threaded mode.
|
|
246
|
+
Default: min(32, num_columns).
|
|
247
|
+
group_size: Group size for group prompting. If 0, process all columns
|
|
248
|
+
at once. If >0, process in groups of that size.
|
|
249
|
+
batch_size: Batch size for batch processing mode. Only used with local LLMs.
|
|
250
|
+
|
|
251
|
+
Returns:
|
|
252
|
+
Summary of column semantics
|
|
253
|
+
"""
|
|
254
|
+
|
|
255
|
+
return self.semantic_profiler.analyze_dataframe(
|
|
256
|
+
dataframe,
|
|
257
|
+
use_group_prompting=use_group_prompting,
|
|
258
|
+
use_multi_threading=use_multi_threading,
|
|
259
|
+
use_batch_processing=use_batch_processing,
|
|
260
|
+
max_workers=max_workers,
|
|
261
|
+
group_size=group_size,
|
|
262
|
+
batch_size=batch_size,
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
def generate_topic(
|
|
266
|
+
self, title: str, original_description: str | None, dataset_sample: str
|
|
267
|
+
) -> str:
|
|
268
|
+
"""
|
|
269
|
+
Generate a 2–3 word topic from title description and sample
|
|
270
|
+
|
|
271
|
+
Args:
|
|
272
|
+
title: Dataset title
|
|
273
|
+
original_description: Existing description if available
|
|
274
|
+
dataset_sample: CSV text sample
|
|
275
|
+
|
|
276
|
+
Returns:
|
|
277
|
+
Short topic string
|
|
278
|
+
"""
|
|
279
|
+
|
|
280
|
+
return self.topic_generator.generate_topic(title, original_description, dataset_sample)
|
|
281
|
+
|
|
282
|
+
def expand_description_for_search(self, description: str, topic: str) -> tuple[str, str]:
|
|
283
|
+
"""
|
|
284
|
+
Expand a readable description into a search-oriented variant
|
|
285
|
+
|
|
286
|
+
Args:
|
|
287
|
+
description: Original dataset description
|
|
288
|
+
topic: Topic string
|
|
289
|
+
|
|
290
|
+
Returns:
|
|
291
|
+
(prompt, expanded_description)
|
|
292
|
+
"""
|
|
293
|
+
|
|
294
|
+
return self.search_description.expand_description(description, topic)
|
|
295
|
+
|
|
296
|
+
def evaluate_description(self, description: str) -> str:
|
|
297
|
+
"""
|
|
298
|
+
Score a description with the configured evaluator
|
|
299
|
+
|
|
300
|
+
Args:
|
|
301
|
+
description: Description text to score
|
|
302
|
+
|
|
303
|
+
Returns:
|
|
304
|
+
Evaluation response
|
|
305
|
+
|
|
306
|
+
Raises:
|
|
307
|
+
RuntimeError: If no evaluator is set
|
|
308
|
+
"""
|
|
309
|
+
|
|
310
|
+
if self.evaluator is None:
|
|
311
|
+
raise RuntimeError(
|
|
312
|
+
"No evaluator configured for AutoDDG. Provide one via set_evaluator()."
|
|
313
|
+
)
|
|
314
|
+
return self.evaluator.evaluate(description)
|
|
315
|
+
|
|
316
|
+
def set_evaluator(self, evaluator: BaseEvaluator) -> None:
|
|
317
|
+
"""
|
|
318
|
+
Attach or replace the evaluator to use for scoring
|
|
319
|
+
|
|
320
|
+
Args:
|
|
321
|
+
evaluator: Evaluator instance
|
|
322
|
+
"""
|
|
323
|
+
|
|
324
|
+
self.evaluator = evaluator
|
|
File without changes
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
dataset_description:
|
|
2
|
+
introduction: |
|
|
3
|
+
Answer the question using the following information.
|
|
4
|
+
|
|
5
|
+
First, consider the dataset sample:
|
|
6
|
+
|
|
7
|
+
{dataset_sample}
|
|
8
|
+
profile_instruction: |
|
|
9
|
+
Additionally, the dataset profile is as follows:
|
|
10
|
+
|
|
11
|
+
{dataset_profile}
|
|
12
|
+
|
|
13
|
+
Based on this profile, please add sentence(s) to enrich the dataset description.
|
|
14
|
+
semantic_instruction: |
|
|
15
|
+
Furthermore, the semantic profile of the dataset columns is as follows:
|
|
16
|
+
{semantic_profile}
|
|
17
|
+
|
|
18
|
+
Based on this information, please add sentence(s) discussing the semantic profile in the description.
|
|
19
|
+
topic_instruction: |
|
|
20
|
+
Moreover, the dataset topic is: {data_topic}. Based on this topic, please add sentence(s) describing what this dataset can be used for.
|
|
21
|
+
closing_instruction: |
|
|
22
|
+
Question: Based on the information above and the requirements, provide a dataset description in sentences. Use only natural, readable sentences without special formatting.
|
|
23
|
+
|
|
24
|
+
Answer:
|
|
25
|
+
system_message: |
|
|
26
|
+
You are an assistant for a dataset search engine. Your goal is to improve the readability of dataset descriptions for dataset search engine users.
|
|
27
|
+
|
|
28
|
+
search_expansion:
|
|
29
|
+
template: |
|
|
30
|
+
Dataset Overview:
|
|
31
|
+
- Please keep the exact initial description of the dataset as shown in beginning the prompt.
|
|
32
|
+
|
|
33
|
+
Key Themes or Topics:
|
|
34
|
+
- Central focus on a broad area of interest (e.g., urban planning, socio-economic factors, environmental analysis).
|
|
35
|
+
- Data spans multiple subtopics or related areas that contribute to a holistic understanding of the primary theme.
|
|
36
|
+
Example:
|
|
37
|
+
- theme1/topic1
|
|
38
|
+
- theme2/topic2
|
|
39
|
+
- theme3/topic3
|
|
40
|
+
|
|
41
|
+
Applications and Use Cases:
|
|
42
|
+
- Facilitates analysis for professionals, policymakers, researchers, or stakeholders.
|
|
43
|
+
- Useful for specific applications, such as planning, engineering, policy formulation, or statistical modeling.
|
|
44
|
+
- Enables insights into patterns, trends, and relationships relevant to the domain.
|
|
45
|
+
Example:
|
|
46
|
+
- application1/usecase1
|
|
47
|
+
- application2/usecase2
|
|
48
|
+
- application3/usecase3
|
|
49
|
+
|
|
50
|
+
Concepts and Synonyms:
|
|
51
|
+
- Includes related concepts, terms, and variations to ensure comprehensive coverage of the topic.
|
|
52
|
+
- Synonyms and alternative phrases improve searchability and retrieval effectiveness.
|
|
53
|
+
Example:
|
|
54
|
+
- concept1/synonym1
|
|
55
|
+
- concept2/synonym2
|
|
56
|
+
- concept3/synonym3
|
|
57
|
+
|
|
58
|
+
Keywords and Themes:
|
|
59
|
+
- Lists relevant keywords and themes for indexing, categorization, and enhancing discoverability.
|
|
60
|
+
- Keywords reflect the dataset's content, scope, and relevance to the domain.
|
|
61
|
+
Example:
|
|
62
|
+
- keyword1
|
|
63
|
+
- keyword2
|
|
64
|
+
- keyword3
|
|
65
|
+
|
|
66
|
+
Additional Context:
|
|
67
|
+
- Highlights the dataset's relevance to specific challenges or questions in the domain.
|
|
68
|
+
- May emphasize its value for interdisciplinary applications or integration with related datasets.
|
|
69
|
+
Example:
|
|
70
|
+
- context1
|
|
71
|
+
- context2
|
|
72
|
+
- context3
|
|
73
|
+
user_prompt: |
|
|
74
|
+
You are given a dataset about the topic {topic}, with the following initial description:
|
|
75
|
+
|
|
76
|
+
{initial_description}
|
|
77
|
+
|
|
78
|
+
Please expand the description by including the exact topic. Additionally, add as many related concepts, synonyms, and relevant terms as possible based on the initial description and the topic.
|
|
79
|
+
|
|
80
|
+
Unlike the initial description, which is focused on presentation and readability, the expanded description is intended to be indexed at the backend of a dataset search engine to improve searchability.
|
|
81
|
+
|
|
82
|
+
Therefore, focus less on readability and more on including all relevant terms related to the topic. Make sure to include any variations of the key terms and concepts that could help improve retrieval in search results.
|
|
83
|
+
|
|
84
|
+
Please follow the structure of the following example template:
|
|
85
|
+
{template}
|
|
86
|
+
system_message: |
|
|
87
|
+
You are an assistant for a dataset search engine. Your goal is to improve the performance of the dataset search engine for keyword queries.
|
|
88
|
+
|
|
89
|
+
semantic_profiler:
|
|
90
|
+
template: |
|
|
91
|
+
{'Temporal':
|
|
92
|
+
{
|
|
93
|
+
'isTemporal': Does this column contain temporal information? Yes or No,
|
|
94
|
+
'resolution': If Yes, specify the resolution (Year, Month, Day, Hour, etc.).
|
|
95
|
+
},
|
|
96
|
+
'Spatial': {'isSpatial': Does this column contain spatial information? Yes or No,
|
|
97
|
+
'resolution': If Yes, specify the resolution (Country, State, City, Coordinates, etc.).},
|
|
98
|
+
'Entity Type': What kind of entity does the column describe? (e.g., Person, Location, Organization, Product),
|
|
99
|
+
'Domain-Specific Types': What domain is this column from (e.g., Financial, Healthcare, E-commerce, Climate, Demographic),
|
|
100
|
+
'Function/Usage Context': How might the data be used (e.g., Aggregation Key, Ranking/Scoring, Interaction Data, Measurement).}
|
|
101
|
+
response_example: |
|
|
102
|
+
{
|
|
103
|
+
"Domain-Specific Types": "General",
|
|
104
|
+
"Entity Type": "Temporal Entity",
|
|
105
|
+
"Function/Usage Context": "Aggregation Key",
|
|
106
|
+
"Spatial": {"isSpatial": false,
|
|
107
|
+
"resolution": ""},
|
|
108
|
+
"Temporal": {"isTemporal": true,
|
|
109
|
+
"resolution": "Year"}
|
|
110
|
+
}
|
|
111
|
+
user_prompt: |
|
|
112
|
+
You are a dataset semantic analyzer. Based on the column name and sample values, classify the column into multiple semantic types.
|
|
113
|
+
Please group the semantic types under the following categories:
|
|
114
|
+
'Temporal', 'Spatial', 'Entity Type', 'Data Format', 'Domain-Specific Types', 'Function/Usage Context'.
|
|
115
|
+
Following is the template {template}
|
|
116
|
+
Please follow these rules:
|
|
117
|
+
1. The output must be a valid JSON object that can be directly loaded by json.loads. Example response is {response_example}
|
|
118
|
+
2. All keys from the template must be present in the response.
|
|
119
|
+
3. All keys and string values must be enclosed in double quotes.
|
|
120
|
+
4. There must be no trailing commas.
|
|
121
|
+
5. Use booleans (true/false) and numbers without quotes.
|
|
122
|
+
6. Do not include any additional information or context in the response.
|
|
123
|
+
7. If you are unsure about a specific category, you can leave it as an empty string.
|
|
124
|
+
|
|
125
|
+
Column name: {column_name}
|
|
126
|
+
Sample values: {sample_values}
|
|
127
|
+
system_message: |
|
|
128
|
+
You are a helpful assistant skilled in dataset semantic analysis.
|
|
129
|
+
group_response_example: |
|
|
130
|
+
{
|
|
131
|
+
"column1": {
|
|
132
|
+
"Domain-Specific Types": "General",
|
|
133
|
+
"Entity Type": "Temporal Entity",
|
|
134
|
+
"Function/Usage Context": "Aggregation Key",
|
|
135
|
+
"Spatial": {"isSpatial": false, "resolution": ""},
|
|
136
|
+
"Temporal": {"isTemporal": true, "resolution": "Year"}
|
|
137
|
+
},
|
|
138
|
+
"column2": {
|
|
139
|
+
"Domain-Specific Types": "Financial",
|
|
140
|
+
"Entity Type": "Numeric Entity",
|
|
141
|
+
"Function/Usage Context": "Measurement",
|
|
142
|
+
"Spatial": {"isSpatial": false, "resolution": ""},
|
|
143
|
+
"Temporal": {"isTemporal": false, "resolution": ""}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
group_user_prompt: |
|
|
147
|
+
You are a dataset semantic analyzer. Analyze multiple columns at once and classify each column into multiple semantic types.
|
|
148
|
+
|
|
149
|
+
For each column provided below, classify it into semantic types under the following categories:
|
|
150
|
+
'Temporal', 'Spatial', 'Entity Type', 'Data Format', 'Domain-Specific Types', 'Function/Usage Context'.
|
|
151
|
+
|
|
152
|
+
Template for each column:
|
|
153
|
+
{template}
|
|
154
|
+
|
|
155
|
+
Please follow these rules:
|
|
156
|
+
1. The output must be a valid JSON object where each key is a column name and each value is the semantic type classification for that column.
|
|
157
|
+
2. All keys from the template must be present in each column's classification.
|
|
158
|
+
3. All keys and string values must be enclosed in double quotes.
|
|
159
|
+
4. There must be no trailing commas.
|
|
160
|
+
5. Use booleans (true/false) and numbers without quotes.
|
|
161
|
+
6. Do not include any additional information or context in the response.
|
|
162
|
+
7. If you are unsure about a specific category for a column, you can leave it as an empty string.
|
|
163
|
+
|
|
164
|
+
Example response format:
|
|
165
|
+
{response_example}
|
|
166
|
+
|
|
167
|
+
Columns to analyze:
|
|
168
|
+
{columns_text}
|
|
169
|
+
|
|
170
|
+
Return a JSON object with column names as keys and their semantic classifications as values:
|
|
171
|
+
|
|
172
|
+
topic_generation:
|
|
173
|
+
system_message: |
|
|
174
|
+
You are an assistant for generating concise dataset topics.
|
|
175
|
+
user_prompt: |
|
|
176
|
+
Using the dataset information provided, generate a concise topic in 2-3 words that best describes the dataset's primary theme.
|
|
177
|
+
|
|
178
|
+
Title: {title}
|
|
179
|
+
{description_block}
|
|
180
|
+
Dataset Sample: {dataset_sample}
|
|
181
|
+
|
|
182
|
+
Topic (2-3 words):
|
|
183
|
+
|
|
184
|
+
evaluation:
|
|
185
|
+
system_message: |
|
|
186
|
+
You are a helpful and precise assistant for checking the quality of the dataset description.
|
|
187
|
+
user_prompt: |
|
|
188
|
+
You will be given one tabular dataset description. Your task is to rate the description on 3 metrics.
|
|
189
|
+
Please make sure you read and understand these instructions carefully. Please keep this document open while reviewing, and refer to it as needed.
|
|
190
|
+
|
|
191
|
+
Evaluation Criteria:
|
|
192
|
+
1. Completeness (1-10) - Evaluates how thoroughly the dataset description covers essential aspects such as the scope of data, query workloads, summary statistics, and possible tasks or applications.
|
|
193
|
+
A high score indicates that the description provides a comprehensive overview, including details on dataset size, structure, fields, and potential use cases.
|
|
194
|
+
2. Conciseness (1-10) - Measures the efficiency of the dataset description in conveying necessary information without redundancy.
|
|
195
|
+
A high score indicates that the description is succinct, avoiding unnecessary details while employing semantic types (e.g., categories, entities) to streamline communication.
|
|
196
|
+
3. Readability (1-10) - Evaluates the logical flow and readability of the dataset description.
|
|
197
|
+
A high score suggests that the description progresses logically from one section to the next, creating a coherent and integrated narrative that facilitates understanding of the dataset.
|
|
198
|
+
|
|
199
|
+
Evaluation Steps:
|
|
200
|
+
Read the dataset description carefully and identify the main topic and key points. Assign a score for each criteria on a scale of 1 to 10, where 1 is the lowest and 10 is the highest based on the Evaluation Criteria.
|
|
201
|
+
|
|
202
|
+
Example 1:
|
|
203
|
+
Description: The dataset provides information on alcohol-impaired driving deaths and occupant deaths across various states in the United States. It includes data for 51 states, detailing the number of alcohol-impaired driving deaths and occupant deaths, with values ranging from 0 to 3723 and 0 to 10406, respectively. Each entry also contains the state abbreviation and its geographical coordinates. The dataset is structured with categorical and numerical data types, focusing on traffic safety and casualty statistics. Key attributes include state names, death counts, and location coordinates, making it a valuable resource for analyzing traffic safety trends and issues related to impaired driving.
|
|
204
|
+
Evaluation Form (scores ONLY): Completeness: 7, Conciseness: 9, Readability: 9
|
|
205
|
+
|
|
206
|
+
Example 2:
|
|
207
|
+
Description: The dataset provides a comprehensive overview of traffic safety statistics across various states in the United States, specifically focusing on alcohol-impaired driving deaths and occupant deaths. It includes data from 51 unique states, represented by their two-letter postal abbreviations, such as MA (Massachusetts), SD (South Dakota), AK (Alaska), MS (Mississippi), and ME (Maine). Each entry in the dataset captures critical information regarding the number of alcohol-impaired driving deaths and the total occupant deaths resulting from traffic incidents.
|
|
208
|
+
The column "Alcohol-Impaired Driving Deaths" is represented as an integer, indicating the number of fatalities attributed to alcohol impairment while driving. The dataset reveals a range of values, with the highest recorded number being 2367 deaths in Mississippi, highlighting the severity of the issue in certain regions. In contrast, states like Alaska report significantly lower figures, with only 205 alcohol-impaired driving deaths.
|
|
209
|
+
The "Occupant Deaths" column also consists of integer values, representing the total number of deaths among vehicle occupants, regardless of the cause. This data spans from 0 to 10406, with Mississippi again showing the highest number of occupant deaths at 6100, which raises concerns about overall traffic safety in the state.
|
|
210
|
+
Additionally, the dataset includes a "Location" column that provides geographical coordinates for each state, enhancing the spatial understanding of the data. The coordinates are formatted as latitude and longitude pairs, allowing for potential mapping and geographical analysis of traffic safety trends.
|
|
211
|
+
Overall, this dataset serves as a valuable resource for researchers, policymakers, and public safety advocates aiming to understand and address the impact of alcohol on driving safety across different states. It highlights the need for targeted interventions and policies to reduce alcohol-impaired driving incidents and improve occupant safety on the roads.
|
|
212
|
+
Evaluation Form (scores ONLY): Completeness: 8, Conciseness: 7, Readability: 8
|
|
213
|
+
|
|
214
|
+
Please provide scores for the given dataset description based on the Evaluation Criteria. Do not include any additional information or comments in your response.
|
|
215
|
+
Evaluation Form (scores ONLY):
|
|
216
|
+
|
|
217
|
+
pairwise_evaluation:
|
|
218
|
+
system_message: |
|
|
219
|
+
You are a helpful and precise assistant for judging the quality of dataset descriptions.
|
|
220
|
+
user_prompt: |
|
|
221
|
+
You will be shown two descriptions of the same dataset, A and B.
|
|
222
|
+
Please select which description is better overall, based on completeness, conciseness, and readability.
|
|
223
|
+
Respond with exactly "A" or "B" (without any additional text).
|
|
224
|
+
|
|
225
|
+
Description A:
|
|
226
|
+
{desc_a}
|
|
227
|
+
|
|
228
|
+
Description B:
|
|
229
|
+
{desc_b}
|
|
230
|
+
|
|
231
|
+
Evaluation Criteria:
|
|
232
|
+
- Completeness (1-10) - Evaluates how thoroughly the dataset description covers essential aspects such as the scope of data, query workloads, summary statistics, and possible tasks or applications. A high score indicates that the description provides a comprehensive overview, including details on dataset size, structure, fields, and potential use cases.
|
|
233
|
+
- Conciseness (1-10) - Measures the efficiency of the dataset description in conveying necessary information without redundancy. A high score indicates that the description is succinct, avoiding unnecessary details while employing semantic types (e.g., categories, entities) to streamline communication.
|
|
234
|
+
- Readability (1-10) - Evaluates the logical flow and readability of the dataset description. A high score suggests that the description progresses logically from one section to the next, creating a coherent and integrated narrative that facilitates understanding of the dataset.
|
|
235
|
+
|
|
236
|
+
Which description is better?
|