CShorten commited on
Commit
1a88532
·
verified ·
1 Parent(s): 3067a6d

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +324 -0
README.md ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ pretty_name: Query Agent Gym
4
+ language:
5
+ - en
6
+ size_categories:
7
+ - 10K<n<100K
8
+ task_categories:
9
+ - question-answering
10
+ - table-question-answering
11
+ tags:
12
+ - weaviate
13
+ - query-agent
14
+ - function-calling
15
+ - text-to-query
16
+ - database
17
+ - retrieval
18
+ - agents
19
+ - synthetic
20
+ configs:
21
+ - config_name: queries
22
+ default: true
23
+ data_files:
24
+ - split: test
25
+ path:
26
+ - public-transit/queries.parquet
27
+ - tattoo-studios/queries.parquet
28
+ - nonprofits/queries.parquet
29
+ - surf-schools/queries.parquet
30
+ - childcare/queries.parquet
31
+ - config_name: environments
32
+ data_files:
33
+ - split: test
34
+ path: environments.parquet
35
+ - config_name: public-transit_TransitRoutes
36
+ data_files:
37
+ - split: test
38
+ path: public-transit/objects/TransitRoutes.parquet
39
+ - config_name: public-transit_RidershipReports
40
+ data_files:
41
+ - split: test
42
+ path: public-transit/objects/RidershipReports.parquet
43
+ - config_name: tattoo-studios_TattooArtists
44
+ data_files:
45
+ - split: test
46
+ path: tattoo-studios/objects/TattooArtists.parquet
47
+ - config_name: tattoo-studios_TattooDesigns
48
+ data_files:
49
+ - split: test
50
+ path: tattoo-studios/objects/TattooDesigns.parquet
51
+ - config_name: nonprofits_Charities
52
+ data_files:
53
+ - split: test
54
+ path: nonprofits/objects/Charities.parquet
55
+ - config_name: nonprofits_Campaigns
56
+ data_files:
57
+ - split: test
58
+ path: nonprofits/objects/Campaigns.parquet
59
+ - config_name: nonprofits_GivingPrograms
60
+ data_files:
61
+ - split: test
62
+ path: nonprofits/objects/GivingPrograms.parquet
63
+ - config_name: nonprofits_Donations
64
+ data_files:
65
+ - split: test
66
+ path: nonprofits/objects/Donations.parquet
67
+ - config_name: surf-schools_SurfBeaches
68
+ data_files:
69
+ - split: test
70
+ path: surf-schools/objects/SurfBeaches.parquet
71
+ - config_name: surf-schools_SurfInstructors
72
+ data_files:
73
+ - split: test
74
+ path: surf-schools/objects/SurfInstructors.parquet
75
+ - config_name: surf-schools_LessonPrograms
76
+ data_files:
77
+ - split: test
78
+ path: surf-schools/objects/LessonPrograms.parquet
79
+ - config_name: surf-schools_SurfEquipment
80
+ data_files:
81
+ - split: test
82
+ path: surf-schools/objects/SurfEquipment.parquet
83
+ - config_name: childcare_DaycareCenters
84
+ data_files:
85
+ - split: test
86
+ path: childcare/objects/DaycareCenters.parquet
87
+ - config_name: childcare_ChildcareStaff
88
+ data_files:
89
+ - split: test
90
+ path: childcare/objects/ChildcareStaff.parquet
91
+ - config_name: childcare_ChildEnrollments
92
+ data_files:
93
+ - split: test
94
+ path: childcare/objects/ChildEnrollments.parquet
95
+ ---
96
+
97
+ # Query Agent Gym
98
+
99
+ Query Agent Gym is a set of procedurally generated database environments and
100
+ natural-language queries with exactly known ground-truth queries, built to
101
+ evaluate data agents that answer questions by writing database queries, such
102
+ as the [Weaviate Query Agent](https://docs.weaviate.io/agents/query). How the
103
+ environments and queries are generated is described in the blog post
104
+ [Query Agent Gym: Post-Training our Query Agent](https://weaviate.io/blog/query-agent-gym).
105
+
106
+ This release holds the five **held-out test environments** of that study:
107
+ 15 collections with 1,000 objects each (15,000 objects, 18,000 searchable
108
+ documents) and 250 queries, 50 per environment. Every entity, name, and
109
+ document is synthetic.
110
+
111
+ | Environment | Collections (kind) | Objects | Queries |
112
+ |---|---|---:|---:|
113
+ | Public Transit | TransitRoutes (knowledge_base), RidershipReports (transactional) | 2,000 | 50 |
114
+ | Tattoo Studios | TattooArtists, TattooDesigns (knowledge_base) | 2,000 | 50 |
115
+ | Nonprofits | Charities, Campaigns, GivingPrograms (knowledge_base), Donations (transactional) | 4,000 | 50 |
116
+ | Surf Schools | SurfBeaches, SurfInstructors, LessonPrograms, SurfEquipment (knowledge_base) | 4,000 | 50 |
117
+ | Childcare | DaycareCenters, ChildcareStaff (knowledge_base), ChildEnrollments (transactional) | 3,000 | 50 |
118
+
119
+ ## Quick start
120
+
121
+ ```python
122
+ from datasets import load_dataset
123
+ import json
124
+
125
+ queries = load_dataset("weaviate/QueryAgentGym", "queries", split="test")
126
+ surf = queries.filter(lambda r: r["environment"] == "surf-schools")
127
+ q = queries[0]
128
+ print(q["command"]) # the natural-language request
129
+ print(q["ground_truth_sql"]) # readable ground truth, one entry per sub-query
130
+ plan = json.loads(q["ground_truth"]) # exact ground truth (query_database arguments)
131
+
132
+ routes = load_dataset("weaviate/QueryAgentGym", "public-transit_TransitRoutes", split="test")
133
+ ```
134
+
135
+ ## Layout
136
+
137
+ Each environment has its own folder.
138
+
139
+ ```
140
+ environments.parquet one row per environment
141
+ <environment>/schema.json the schema exactly as generated
142
+ <environment>/queries.parquet the environment's 50 queries
143
+ <environment>/objects/<Collection>.parquet 1,000 objects per collection
144
+ ```
145
+
146
+ | Config | Rows | Contents |
147
+ |---|---:|---|
148
+ | `queries` (default) | 250 | All five environments' queries, with an `environment` column |
149
+ | `environments` | 5 | One row per environment |
150
+ | `<environment>_<Collection>` | 1,000 each | The objects of one collection, one typed column per property |
151
+
152
+ To work with one environment, filter the `queries` config on `environment`,
153
+ or read `<environment>/queries.parquet` directly.
154
+
155
+ ### `queries`
156
+
157
+ | Field | Type | Description |
158
+ |---|---|---|
159
+ | `query_id` | string | e.g. `public-transit-013` |
160
+ | `environment` | string | Environment id, e.g. `public-transit` |
161
+ | `environment_name` | string | e.g. `Public Transit` |
162
+ | `command` | string | The natural-language request given to the agent |
163
+ | `phrasing` | string | `explicit` (names properties and values plainly) or `conversational` (a scenario, with values still verbatim) |
164
+ | `plan` | string | The operators of the plan, sub-queries separated by `;` |
165
+ | `num_sub_queries` | int | 1 to 3. Sub-queries are independent, never multi-hop |
166
+ | `operator_classes` | list of strings | Operator classes the plan features (search, each filter kind, each aggregation kind, group-by, multi-query) |
167
+ | `ground_truth` | string (JSON) | List of `query_database` argument objects, one per sub-query (format below) |
168
+ | `ground_truth_sql` | list of strings | A SQL-like rendering of each sub-query, for reading only |
169
+ | `search_grounds` | list of structs | For each sub-query with a search, its relevance-labeled result set (below) |
170
+ | `reference_results` | string (JSON) | Each sub-query's ground truth executed on the objects (below) |
171
+
172
+ ### Objects
173
+
174
+ Each `<environment>_<Collection>` config has a `uuid` column followed by one
175
+ column per property, in schema order. The `uuid` is the object's id and is
176
+ what `search_grounds` and `reference_results` refer to. Property types map to
177
+ columns and to Weaviate data types as follows.
178
+
179
+ | Property type | Column type | Weaviate data type |
180
+ |---|---|---|
181
+ | `searchable_text` | string | `text` (the prose a search should match) |
182
+ | `filterable_text` | string | `text` (identifiers, references, categories) |
183
+ | `int` / `number` | int64 / float64 | `int` / `number` |
184
+ | `boolean` | bool | `boolean` |
185
+ | `date` | string, `YYYY-MM-DD` | `date` (send as RFC 3339, e.g. `2025-11-16T00:00:00Z`) |
186
+ | `text_array`, `int_array`, `number_array`, `boolean_array`, `date_array` | list | `text[]`, `int[]`, `number[]`, `boolean[]`, `date[]` |
187
+
188
+ Each collection has exactly one identifier property (`is_identifier` in
189
+ `schema.json`): an invented, unique name in a `knowledge_base` collection, a
190
+ code in a `transactional` one. A `transactional` collection's reference
191
+ properties (`references` in `schema.json`) hold the identifier of a
192
+ `knowledge_base` record,
193
+ stored directly in the row, so no query needs a join. No value is null.
194
+
195
+ ## Ground truth format
196
+
197
+ A ground truth is a list of sub-queries, each a `query_database` function-call
198
+ argument object.
199
+
200
+ ```json
201
+ [{"collection_name": "TransitRoutes",
202
+ "search_query": "observatory and weather access",
203
+ "numeric_array_property_filters": [
204
+ {"property_name": "stopSequenceNumbers", "operator": "CONTAINS_ALL", "values": [1, 8]}]}]
205
+ ```
206
+
207
+ | Argument | Items | Operators or metrics |
208
+ |---|---|---|
209
+ | `collection_name` | | The target collection |
210
+ | `search_query` | string | A relevance search over the collection's searchable text |
211
+ | `text_property_filters` | `property_name`, `operator`, `value` | `=`, `LIKE` (pattern uses `%`, e.g. `Nerith%`) |
212
+ | `numeric_property_filters` | `property_name`, `operator`, `value` | `=`, `<`, `>`, `<=`, `>=` |
213
+ | `date_property_filters` | `property_name`, `operator`, `value` (ISO date) | `=`, `<`, `>`, `<=`, `>=` |
214
+ | `boolean_property_filters` | `property_name`, `operator`, `value` | `=`, `!=` |
215
+ | `array_property_filters` (text arrays), `numeric_array_property_filters`, `boolean_array_property_filters`, `date_array_property_filters` | `property_name`, `operator`, `values` | `CONTAINS_ANY`, `CONTAINS_ALL` |
216
+ | `numeric_property_aggregations` | `property_name`, `metric` | `COUNT`, `MIN`, `MAX`, `MEAN`, `MEDIAN`, `MODE`, `SUM` |
217
+ | `text_property_aggregations` | `property_name`, `metric`, `top_occurrences_limit` | `COUNT`, `COUNT_DISTINCT`, `TOP_OCCURRENCES` |
218
+ | `boolean_property_aggregations` | `property_name`, `metric` | `COUNT`, `TOTAL_TRUE`, `TOTAL_FALSE`, `PERCENTAGE_TRUE`, `PERCENTAGE_FALSE` |
219
+ | `date_property_aggregations` | `property_name`, `metric` | `COUNT`, `EARLIEST`, `LATEST` |
220
+ | `groupby_property` | string | Groups every aggregation of the sub-query |
221
+
222
+ All filters in a sub-query are combined with AND. A sub-query without
223
+ aggregations retrieves records, and one with aggregations returns only the
224
+ statistics.
225
+
226
+ **Searches.** The words of `search_query` are one valid phrasing and are not
227
+ the target. A search sub-query's correct result is its labeled set:
228
+ `search_grounds[i].candidate_ids` are the records the sub-query's filters
229
+ select (R), and `relevant_ids` are the records a language model labeled
230
+ relevant to the topic after reading every document in R (S). The `topic` and
231
+ `description` fields say what the search is about.
232
+
233
+ **Reference results.** `reference_results[i]` is sub-query `i` executed on the
234
+ objects, with a search resolving to its `relevant_ids`. A retrieval is a sorted
235
+ list of uuids, an aggregation is `{"METRIC(property)": value}`, and a group-by
236
+ maps each group value (as a string) to its aggregations. Percentages are on a
237
+ 0 to 100 scale, and `TOP_OCCURRENCES` is a list of `[value, count]` pairs.
238
+ Ties in `MODE` and `TOP_OCCURRENCES` are broken deterministically, which a
239
+ database may break differently.
240
+
241
+ ## Evaluation
242
+
243
+ The blog post evaluates agents with **Exact Match** over the plan. The
244
+ predicted and ground-truth plans are canonicalized and matched sub-query to
245
+ sub-query. The collection, every filter with its operator and value, every
246
+ aggregation with its metric and property, and the group-by must agree, and
247
+ extra sub-queries or statistics count as errors. A search must be present on
248
+ the right collection, but its words are not compared. A few re-expressions
249
+ that return the same answer on the data are accepted, such as a per-group
250
+ count of any populated single-valued property, or a date bound that excludes
251
+ no record. Answer-level comparison against `reference_results` is a looser
252
+ alternative.
253
+
254
+ To reproduce the setup, create one Weaviate collection per objects config with
255
+ the data types above and a text vectorizer (the study used
256
+ `text2vec_weaviate` with hybrid search), use each row's `uuid` as the object
257
+ id, and point the agent at an environment's collections. Uploading each run
258
+ under a fresh collection name avoids agents reusing statistics cached from an
259
+ earlier run.
260
+
261
+ ### Reference results
262
+
263
+ The Weaviate Query Agent, run once on the 250 queries with the same code and
264
+ filter statistics, before and after a prompt revision made from failures on
265
+ separate training environments (not released).
266
+
267
+ | Environment | Before revision | After revision |
268
+ |---|---:|---:|
269
+ | Public Transit | 40/50 | 49/50 |
270
+ | Tattoo Studios | 34/50 | 47/50 |
271
+ | Nonprofits | 34/50 | 48/50 |
272
+ | Surf Schools | 40/50 | 50/50 |
273
+ | Childcare | 36/50 | 45/50 |
274
+ | **Total** | **184/250 (73.6%)** | **239/250 (95.6%)** |
275
+
276
+ ## How the data was made
277
+
278
+ Each environment is a position in a seeded order over 200 domain briefs (seed
279
+ 380, positions 5 to 9). Its structure is sampled procedurally: the number and
280
+ kind of collections, property types, references, and each query's operator
281
+ plan. Language models write the surface: the schema design (GPT-6 Sol),
282
+ record names and documents (GPT-6 Luna), search topics and their relevance
283
+ labels, and the natural-language commands (GPT-5.6 Luna). Ground truths are
284
+ grounded in the saved objects and every command passes mechanical checks and
285
+ a faithfulness verifier, so the plan can be recovered from the words. Each set
286
+ of 50 queries is selected from a pool of 200 sampled plans so that every
287
+ operator class appears at least 3 times, which makes the sets balanced across
288
+ operators rather than distributed like natural traffic. A seeded coin chose
289
+ each command's phrasing, giving 113 explicit and 137 conversational commands.
290
+
291
+ ## Limitations
292
+
293
+ - All data is synthetic and English only. Entities are invented, so an agent
294
+ cannot answer from world knowledge, and documents are written as a real
295
+ system of record would write them.
296
+ - Values are drawn independently, so a record can combine values that would
297
+ rarely co-occur in reality (a fin set tagged for zipper care). Documents are
298
+ written to stay consistent with each record's values.
299
+ - Public Transit has no group-by queries. Its only groupable properties are
300
+ references with over 400 distinct values, which yield degenerate groups.
301
+ - Relevance labels for searches come from a language model reading each
302
+ candidate document, not from human annotation.
303
+ - Search topics can repeat a theme within an environment, and two Tattoo
304
+ Studios design searches share the phrase "melting snow".
305
+ - The query sets exclude what the Weaviate Query Agent cannot express, such as
306
+ aggregating over the results of a semantic search.
307
+
308
+ ## Citation
309
+
310
+ ```bibtex
311
+ @misc{query_agent_gym_2026,
312
+ title = {Query Agent Gym: Post-Training our Query Agent},
313
+ author = {Shorten, Connor},
314
+ year = {2026},
315
+ url = {https://weaviate.io/blog/query-agent-gym}
316
+ }
317
+
318
+ @article{shorten2025querying,
319
+ title = {Querying Databases with Function Calling},
320
+ author = {Shorten, Connor and others},
321
+ journal = {arXiv preprint arXiv:2502.00032},
322
+ year = {2025}
323
+ }
324
+ ```