bloksbgt commited on
Commit
2fdc260
·
verified ·
1 Parent(s): c80f135

Upload SQL-SFT-V1

Browse files
README.md ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - id
4
+ license: other
5
+ task_categories:
6
+ - text-generation
7
+ - question-answering
8
+ size_categories:
9
+ - n<1K
10
+ configs:
11
+ - config_name: pajak_eval
12
+ data_files:
13
+ - split: train
14
+ path: data/pajak-eval.json
15
+ - config_name: pajak_train
16
+ data_files:
17
+ - split: train
18
+ path: data/pajak-train.json
19
+ - config_name: pajak_train_4000
20
+ data_files:
21
+ - split: train
22
+ path: data/pajak-train_4000.json
23
+ - config_name: nvidia_nemotron_3_ultra_550b_a55b_pajak_train
24
+ data_files:
25
+ - split: train
26
+ path: data/nvidia-nemotron-3-ultra-550b-a55b-pajak-train.json
27
+ ---
28
+ # SQL-SFT-V1
29
+
30
+ Dataset distilasi tentang pelaporan pajak di Indonesia dalam Bahasa Indonesia, dibuat untuk belajar membangun LLM sendiri.
31
+ Formatnya mengikuti [rasbt/math_distill](https://huggingface.co/datasets/rasbt/math_distill).
32
+
33
+ ## Construction
34
+
35
+ - Soal disediakan sendiri oleh pemilik dataset (file `problems.jsonl`) beserta kunci jawaban singkat (`gtruth_answer`).
36
+ - Jawaban (thinking + jawaban akhir) dihasilkan oleh model teacher lewat router API; verifikasi otomatis terhadap kunci jawaban: VERIFY=True, ONLY_CORRECT=True, REQUIRE_THINKING=True.
37
+
38
+ Akurasi teacher sebelum filter:
39
+
40
+ | Model teacher | Sampel | Benar | Dengan thinking |
41
+ |---|---|---|---|
42
+ | `nvidia/nemotron-3-ultra-550b-a55b` | 24 | 3 (12.5%) | 24 |
43
+
44
+ ## Files
45
+
46
+ - [data/pajak-eval.json](data/pajak-eval.json):
47
+ * 1 soal evaluasi (held-out, tidak ada di file train) beserta jawaban teacher.
48
+ - [data/pajak-train.json](data/pajak-train.json):
49
+ * 2 sampel train dari seluruh teacher (tidak tumpang tindih dengan set eval).
50
+ - [data/pajak-train_4000.json](data/pajak-train_4000.json):
51
+ * Seperti pajak-train.json tetapi hanya sampel dengan panjang <= 4000 token (setelah chat template): 2 sampel.
52
+ - [data/nvidia-nemotron-3-ultra-550b-a55b-pajak-train.json](data/nvidia-nemotron-3-ultra-550b-a55b-pajak-train.json):
53
+ * Sampel train yang dijawab oleh model `nvidia/nemotron-3-ultra-550b-a55b`: 2 sampel.
54
+
55
+ ## Fields
56
+
57
+ Each example contains:
58
+
59
+ - `problem`: soal perpajakan
60
+ - `gtruth_answer`: jawaban singkat (kunci)
61
+ - `message_thinking`: thinking trace dari teacher
62
+ - `message_content`: jawaban akhir dari teacher
63
+
64
+ Keduanya dapat digabung, sama seperti math_distill:
65
+
66
+ ```python
67
+ complete_answer = f"<think>{data['message_thinking']}</think>\n\n{data['message_content']}"
68
+ ```
69
+
70
+ ## Dataset Statistics
71
+
72
+ Dihitung dengan `scripts/average_field_lengths_json.py`, misalnya:
73
+
74
+ ```bash
75
+ python scripts/average_field_lengths_json.py --json_path data/pajak-eval.json --tokenizer Qwen/Qwen3-0.6B
76
+ ```
77
+
78
+ ### `data/pajak-eval.json`
79
+
80
+ ```
81
+ Records: 1
82
+ Tokenizer: Qwen/Qwen3-0.6B
83
+ Field AvgTokens MinTokens MaxToken Count
84
+ gtruth_answer 240.00 240 240 1
85
+ message_content 231.00 231 231 1
86
+ message_thinking 624.00 624 624 1
87
+ problem 112.00 112 112 1
88
+
89
+ Verified-correct answers: 1/1 (100.0%)
90
+ ```
91
+
92
+ ### `data/pajak-train.json`
93
+
94
+ ```
95
+ Records: 2
96
+ Tokenizer: Qwen/Qwen3-0.6B
97
+ Field AvgTokens MinTokens MaxToken Count
98
+ gtruth_answer 146.00 134 158 2
99
+ message_content 78.50 72 85 2
100
+ message_thinking 556.00 155 957 2
101
+ problem 123.00 115 131 2
102
+
103
+ Verified-correct answers: 2/2 (100.0%)
104
+ ```
105
+
106
+ ### `data/pajak-train_4000.json`
107
+
108
+ ```
109
+ Records: 2
110
+ Tokenizer: Qwen/Qwen3-0.6B
111
+ Field AvgTokens MinTokens MaxToken Count
112
+ gtruth_answer 146.00 134 158 2
113
+ message_content 78.50 72 85 2
114
+ message_thinking 556.00 155 957 2
115
+ problem 123.00 115 131 2
116
+
117
+ Verified-correct answers: 2/2 (100.0%)
118
+ ```
119
+
120
+ ### `data/nvidia-nemotron-3-ultra-550b-a55b-pajak-train.json`
121
+
122
+ ```
123
+ Records: 2
124
+ Tokenizer: Qwen/Qwen3-0.6B
125
+ Field AvgTokens MinTokens MaxToken Count
126
+ gtruth_answer 146.00 134 158 2
127
+ message_content 78.50 72 85 2
128
+ message_thinking 556.00 155 957 2
129
+ problem 123.00 115 131 2
130
+
131
+ Verified-correct answers: 2/2 (100.0%)
132
+ ```
133
+
134
+ ## Intended use
135
+
136
+ Untuk pembelajaran pribadi: melatih/distilasi LLM kecil.
137
+
138
+ ## Usage
139
+
140
+ ```python
141
+ from datasets import load_dataset
142
+
143
+ repo_id = "bloksbgt/SQL-SFT-V1"
144
+
145
+ train = load_dataset(repo_id, "pajak_train", split="train")
146
+ eval_set = load_dataset(repo_id, "pajak_eval", split="train")
147
+ train_4000 = load_dataset(repo_id, "pajak_train_4000", split="train")
148
+
149
+ print(len(train), len(eval_set), len(train_4000))
150
+ print(train[0].keys())
151
+ ```
data/nvidia-nemotron-3-ultra-550b-a55b-pajak-train.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "problem": "Given the following MYSQL schema:\n\n```sql\nCREATE TABLE invoices (\n invoice_id INT AUTO_INCREMENT PRIMARY KEY,\n customer_id INT NOT NULL,\n issued_date DATE NOT NULL,\n due_date DATE NOT NULL,\n amount DECIMAL(12,2) NOT NULL,\n paid_at DATETIME\n);\n\nCREATE TABLE customers (\n customer_id INT AUTO_INCREMENT PRIMARY KEY,\n company_name VARCHAR(200),\n contact_email VARCHAR(255),\n account_manager_id INT\n);\n```\n\nWrite a MySQL query to find all overdue unpaid invoices (due date in the past, not yet paid), with customer name and days overdue.",
4
+ "gtruth_answer": "```sql\nSELECT\n i.invoice_id,\n c.company_name,\n c.contact_email,\n i.issued_date,\n i.due_date,\n i.amount,\n DATEDIFF(CURDATE(), i.due_date) AS days_overdue\nFROM invoices i\nJOIN customers c ON c.customer_id = i.customer_id\nWHERE i.paid_at IS NULL\n AND i.due_date < CURDATE()\nORDER BY days_overdue DESC;\n```\n\n**How it works:**\n\n`paid_at IS NULL` identifies unpaid invoices; `due_date < CURDATE()` identifies overdue ones. `DATEDIFF(CURDATE(), i.due_date)` gives positive days-overdue values. Sorting by `days_overdue DESC` surfaces the most critical invoices first.",
5
+ "message_thinking": "The user wants a MySQL query to find overdue unpaid invoices with customer name and days overdue. Let me write this query.\n\nOverdue unpaid invoices: due_date < current date, and paid_at IS NULL.\nNeed customer company_name from customers table.\nDays overdue: DATEDIFF(current_date, due_date).\n\nI'll use CURDATE() for current date in MySQL.\n\nQuery:\nSELECT i.invoice_id, c.company_name, i.due_date, i.amount, DATEDIFF(CURDATE(), i.due_date) AS days_overdue\nFROM invoices i\nJOIN customers c ON i.customer_id = c.customer_id\nWHERE i.due_date < CURDATE()\n AND i.paid_at IS NULL;\n\nThat's it. I'll output in the required format.",
6
+ "message_content": "```sql\nSELECT\n i.invoice_id,\n c.company_name,\n i.due_date,\n i.amount,\n DATEDIFF(CURDATE(), i.due_date) AS days_overdue\nFROM invoices i\nJOIN customers c ON i.customer_id = c.customer_id\nWHERE i.due_date < CURDATE()\n AND i.paid_at IS NULL;\n```\n\n\\boxed{Query above}"
7
+ },
8
+ {
9
+ "problem": "Given the following BIGQUERY schema:\n\n```sql\n-- BigQuery table: `events.raw_events`\n-- Fields:\n-- event_id STRING\n-- user_id STRING\n-- event_name STRING\n-- event_time TIMESTAMP\n-- properties JSON STRING (e.g. '{\"tags\": [\"premium\", \"trial\"], \"plan\": \"pro\"}')\n-- tags ARRAY<STRING>\n```\n\nWrite a BigQuery SQL query to count the number of events per tag for the last 30 days, where tags is a repeated STRING field (ARRAY<STRING>).",
10
+ "gtruth_answer": "```sql\nSELECT\n tag,\n COUNT(*) AS event_count\nFROM `events.raw_events`,\nUNNEST(tags) AS tag\nWHERE event_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)\nGROUP BY tag\nORDER BY event_count DESC;\n```\n\n**How it works:**\n\nBigQuery's `UNNEST(array_column) AS alias` in the `FROM` clause (cross join unnest) expands each array into individual rows. Every event with N tags produces N rows in the unnested result — making it straightforward to aggregate by tag. The comma before `UNNEST` is BigQuery's implicit cross join syntax.",
11
+ "message_thinking": "The user wants a BigQuery SQL query to count events per tag for the last 30 days. The tags field is ARRAY<STRING>. Need to unnest the array and count.\n\nKey points:\n- Table: `events.raw_events`\n- Fields: event_id, user_id, event_name, event_time, properties (JSON STRING), tags (ARRAY<STRING>)\n- Need last 30 days relative to max event_time or current date? Usually use max(event_time) for reproducibility.\n- Count events per tag: each event can have multiple tags, so unnest tags, then group by tag, count distinct event_id? Or count rows after unnest (each tag occurrence). The prompt says \"count the number of events per tag\". Could be count of events that have that tag. If an event has multiple tags, it counts for each tag. So unnest tags, then count(*) per tag.\n\nWe'll write query:\n\nWITH filtered AS (\n SELECT event_id, tags\n FROM `events.raw_events`\n WHERE event_time >= TIMESTAMP_SUB((SELECT MAX(event_time) FROM `events.raw_events`), INTERVAL 30 DAY)\n)\nSELECT tag, COUNT(*) AS event_count\nFROM filtered, UNNEST(tags) AS tag\nGROUP BY tag\nORDER BY event_count DESC;\n\nThat's it.\n\nNeed to output in boxed format? The instruction: \"Akhiri dengan jawaban akhir yang singkat dalam format \\boxed{...}; untuk angka rupiah tulis angka penuh, contoh \\boxed{Rp12.345.000}.\" But this is a SQL query, not a number. The user asked for a query. The instruction about boxed answer is from the system prompt for tax consultant? Actually the system prompt says: \"Kamu konsultan pajak Indonesia berpengalaman... Akhiri dengan jawaban akhir yang singkat dalam format \\boxed{...}\". But the user is asking for BigQuery SQL. The system prompt might be generic. However, the instruction says \"Respond like terse caveman.\" and \"All technical substance stay exact\". The boxed format might be for final answer. But the answer is a SQL query, not a number. Should I put the SQL query in a box? The example shows \\boxed{Rp12.345.000}. Probably they want the final answer in a box. I'll put the SQL query inside \\boxed{...}. But the query is multi-line. Might need to escape newlines? Usually they want the answer in a box. I'll provide the query as code block and then boxed? The instruction: \"Akhiri dengan jawaban akhir yang singkat dalam format \\boxed{...}\". So final answer should be boxed. I'll put the query in a single line? Or maybe just the query as string. I'll output the query in a code block and then boxed? The caveman style says no filler, just answer. I'll output the query in a code block and then a boxed version? Might be overkill. I'll just output the query in a code block and then a boxed summary? The user asked \"Write a BigQuery SQL query...\". So the answer is the query. I'll provide the query in a code block and then put the query in a box? The boxed format is for short answer. Maybe they want the query as the final answer. I'll put the query inside \\boxed{} but with newlines? Might break. I'll output the query as a single line with semicolons. But better to provide as code block and then boxed with \"Query: ...\". However, the system prompt says \"Akhiri dengan jawaban akhir yang singkat dalam format \\boxed{...}\". I'll comply by putting the query in a box. I'll write the query as a single line string.\n\nLet's produce:\n\n\\boxed{WITH filtered AS (SELECT event_id, tags FROM `events.raw_events` WHERE event_time >= TIMESTAMP_SUB((SELECT MAX(event_time) FROM `events.raw_events`), INTERVAL 30 DAY)) SELECT tag, COUNT(*) AS event_count FROM filtered, UNNEST(tags) AS tag GROUP BY tag ORDER BY event_count DESC;}\n\nBut that's messy. I'll output the query in a code block and then a boxed note \"See query above\". But the instruction says \"Akhiri dengan jawaban akhir yang singkat dalam format \\boxed{...}\". So I'll put the query in the box. I'll keep it as a single line.\n\nI'll respond in terse caveman style. No filler. Just the query.",
12
+ "message_content": "\\boxed{WITH filtered AS (SELECT event_id, tags FROM \\`events.raw_events\\` WHERE event_time >= TIMESTAMP_SUB((SELECT MAX(event_time) FROM \\`events.raw_events\\`), INTERVAL 30 DAY)) SELECT tag, COUNT(*) AS event_count FROM filtered, UNNEST(tags) AS tag GROUP BY tag ORDER BY event_count DESC;}"
13
+ }
14
+ ]
data/pajak-eval.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "problem": "Given the following BIGQUERY schema:\n\n```sql\n-- BigQuery table: `analytics.sessions`\n-- Fields:\n-- session_id STRING\n-- user_id STRING\n-- started_at TIMESTAMP\n-- ended_at TIMESTAMP\n-- source STRING -- 'organic', 'paid', 'email', 'referral', 'direct'\n-- pages_viewed INT64\n-- converted BOOL\n```\n\nWrite a BigQuery SQL query to compute the 7-day rolling average conversion rate by traffic source, for the last 90 days.",
4
+ "gtruth_answer": "```sql\nWITH daily_conversion AS (\n SELECT\n DATE(started_at) AS session_date,\n source,\n COUNT(*) AS total_sessions,\n COUNTIF(converted) AS converted_sessions,\n SAFE_DIVIDE(COUNTIF(converted), COUNT(*)) AS daily_conv_rate\n FROM `analytics.sessions`\n WHERE started_at >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 90 DAY)\n GROUP BY session_date, source\n)\nSELECT\n session_date,\n source,\n total_sessions,\n converted_sessions,\n daily_conv_rate,\n AVG(daily_conv_rate) OVER (\n PARTITION BY source\n ORDER BY session_date\n ROWS BETWEEN 6 PRECEDING AND CURRENT ROW\n ) AS rolling_7d_conv_rate\nFROM daily_conversion\nORDER BY source, session_date;\n```\n\n**How it works:**\n\n`COUNTIF(converted)` is BigQuery's concise boolean aggregation. `SAFE_DIVIDE` avoids division-by-zero. The window `ROWS BETWEEN 6 PRECEDING AND CURRENT ROW` computes a 7-day rolling average within each source partition — including the current day and the 6 preceding days.",
5
+ "message_thinking": "The user wants a BigQuery SQL query for 7-day rolling average conversion rate by traffic source for last 90 days. Need to write query with window functions. Provide concise answer with code block. Use caveman style: terse, no filler. Provide final answer in boxed format? The instruction says end with short answer in \\boxed{...}. But this is a SQL query, not a number. Probably they want the query inside box? The instruction: \"Akhiri dengan jawaban akhir yang singkat dalam format \\boxed{...}; untuk angka rupiah tulis angka penuh, contoh \\boxed{Rp12.345.000}.\" That's for Indonesian tax calculations. But here it's SQL. Might still need to put final answer in box. Could put the query inside box. But box expects short answer. Maybe just provide query without box? The system prompt says \"End with short answer in \\boxed{...}\". But for code, maybe they want the query as final answer. I'll provide query in code block and then put a summary in box? Could put \"Query ready\" in box. But better to follow instruction: provide final answer in box. Could put the query inside box but that's large. Might be okay. I'll output the query in a code block and then a box with \"SQL query above\". But the instruction: \"Akhiri dengan jawaban akhir yang singkat dalam format \\boxed{...}\". So final line should be \\boxed{...}. I'll put something like \\boxed{See query above}. But that seems odd. Maybe they expect the query itself as final answer. I'll put the query inside the box? But box is for short answer. Hmm.\n\nGiven the style, I'll output the query in a code block, then final line \\boxed{Query}. That satisfies.\n\nNow write SQL:\n\nWITH filtered AS (\n SELECT\n source,\n DATE(started_at) AS session_date,\n converted\n FROM `analytics.sessions`\n WHERE started_at >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 90 DAY)\n),\ndaily AS (\n SELECT\n source,\n session_date,\n COUNT(*) AS sessions,\n SUM(CAST(converted AS INT64)) AS conversions\n FROM filtered\n GROUP BY source, session_date\n),\nrolling AS (\n SELECT\n source,\n session_date,\n SUM(sessions) OVER (PARTITION BY source ORDER BY session_date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) AS sessions_7d,\n SUM(conversions) OVER (PARTITION BY source ORDER BY session_date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) AS conversions_7d\n FROM daily\n)\nSELECT\n source,\n session_date,\n SAFE_DIVIDE(conversions_7d, sessions_7d) AS conversion_rate_7d_avg\nFROM rolling\nORDER BY source, session_date;\n\nThat's it. Provide in code block. Then final box.",
6
+ "message_content": "```sql\nWITH filtered AS (\n SELECT\n source,\n DATE(started_at) AS session_date,\n converted\n FROM `analytics.sessions`\n WHERE started_at >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 90 DAY)\n),\ndaily AS (\n SELECT\n source,\n session_date,\n COUNT(*) AS sessions,\n SUM(CAST(converted AS INT64)) AS conversions\n FROM filtered\n GROUP BY source, session_date\n),\nrolling AS (\n SELECT\n source,\n session_date,\n SUM(sessions) OVER (PARTITION BY source ORDER BY session_date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) AS sessions_7d,\n SUM(conversions) OVER (PARTITION BY source ORDER BY session_date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) AS conversions_7d\n FROM daily\n)\nSELECT\n source,\n session_date,\n SAFE_DIVIDE(conversions_7d, sessions_7d) AS conversion_rate_7d_avg\nFROM rolling\nORDER BY source, session_date;\n```\n\n\\boxed{SQL query above}"
7
+ }
8
+ ]
data/pajak-train.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "problem": "Given the following MYSQL schema:\n\n```sql\nCREATE TABLE invoices (\n invoice_id INT AUTO_INCREMENT PRIMARY KEY,\n customer_id INT NOT NULL,\n issued_date DATE NOT NULL,\n due_date DATE NOT NULL,\n amount DECIMAL(12,2) NOT NULL,\n paid_at DATETIME\n);\n\nCREATE TABLE customers (\n customer_id INT AUTO_INCREMENT PRIMARY KEY,\n company_name VARCHAR(200),\n contact_email VARCHAR(255),\n account_manager_id INT\n);\n```\n\nWrite a MySQL query to find all overdue unpaid invoices (due date in the past, not yet paid), with customer name and days overdue.",
4
+ "gtruth_answer": "```sql\nSELECT\n i.invoice_id,\n c.company_name,\n c.contact_email,\n i.issued_date,\n i.due_date,\n i.amount,\n DATEDIFF(CURDATE(), i.due_date) AS days_overdue\nFROM invoices i\nJOIN customers c ON c.customer_id = i.customer_id\nWHERE i.paid_at IS NULL\n AND i.due_date < CURDATE()\nORDER BY days_overdue DESC;\n```\n\n**How it works:**\n\n`paid_at IS NULL` identifies unpaid invoices; `due_date < CURDATE()` identifies overdue ones. `DATEDIFF(CURDATE(), i.due_date)` gives positive days-overdue values. Sorting by `days_overdue DESC` surfaces the most critical invoices first.",
5
+ "message_thinking": "The user wants a MySQL query to find overdue unpaid invoices with customer name and days overdue. Let me write this query.\n\nOverdue unpaid invoices: due_date < current date, and paid_at IS NULL.\nNeed customer company_name from customers table.\nDays overdue: DATEDIFF(current_date, due_date).\n\nI'll use CURDATE() for current date in MySQL.\n\nQuery:\nSELECT i.invoice_id, c.company_name, i.due_date, i.amount, DATEDIFF(CURDATE(), i.due_date) AS days_overdue\nFROM invoices i\nJOIN customers c ON i.customer_id = c.customer_id\nWHERE i.due_date < CURDATE()\n AND i.paid_at IS NULL;\n\nThat's it. I'll output in the required format.",
6
+ "message_content": "```sql\nSELECT\n i.invoice_id,\n c.company_name,\n i.due_date,\n i.amount,\n DATEDIFF(CURDATE(), i.due_date) AS days_overdue\nFROM invoices i\nJOIN customers c ON i.customer_id = c.customer_id\nWHERE i.due_date < CURDATE()\n AND i.paid_at IS NULL;\n```\n\n\\boxed{Query above}"
7
+ },
8
+ {
9
+ "problem": "Given the following BIGQUERY schema:\n\n```sql\n-- BigQuery table: `events.raw_events`\n-- Fields:\n-- event_id STRING\n-- user_id STRING\n-- event_name STRING\n-- event_time TIMESTAMP\n-- properties JSON STRING (e.g. '{\"tags\": [\"premium\", \"trial\"], \"plan\": \"pro\"}')\n-- tags ARRAY<STRING>\n```\n\nWrite a BigQuery SQL query to count the number of events per tag for the last 30 days, where tags is a repeated STRING field (ARRAY<STRING>).",
10
+ "gtruth_answer": "```sql\nSELECT\n tag,\n COUNT(*) AS event_count\nFROM `events.raw_events`,\nUNNEST(tags) AS tag\nWHERE event_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)\nGROUP BY tag\nORDER BY event_count DESC;\n```\n\n**How it works:**\n\nBigQuery's `UNNEST(array_column) AS alias` in the `FROM` clause (cross join unnest) expands each array into individual rows. Every event with N tags produces N rows in the unnested result — making it straightforward to aggregate by tag. The comma before `UNNEST` is BigQuery's implicit cross join syntax.",
11
+ "message_thinking": "The user wants a BigQuery SQL query to count events per tag for the last 30 days. The tags field is ARRAY<STRING>. Need to unnest the array and count.\n\nKey points:\n- Table: `events.raw_events`\n- Fields: event_id, user_id, event_name, event_time, properties (JSON STRING), tags (ARRAY<STRING>)\n- Need last 30 days relative to max event_time or current date? Usually use max(event_time) for reproducibility.\n- Count events per tag: each event can have multiple tags, so unnest tags, then group by tag, count distinct event_id? Or count rows after unnest (each tag occurrence). The prompt says \"count the number of events per tag\". Could be count of events that have that tag. If an event has multiple tags, it counts for each tag. So unnest tags, then count(*) per tag.\n\nWe'll write query:\n\nWITH filtered AS (\n SELECT event_id, tags\n FROM `events.raw_events`\n WHERE event_time >= TIMESTAMP_SUB((SELECT MAX(event_time) FROM `events.raw_events`), INTERVAL 30 DAY)\n)\nSELECT tag, COUNT(*) AS event_count\nFROM filtered, UNNEST(tags) AS tag\nGROUP BY tag\nORDER BY event_count DESC;\n\nThat's it.\n\nNeed to output in boxed format? The instruction: \"Akhiri dengan jawaban akhir yang singkat dalam format \\boxed{...}; untuk angka rupiah tulis angka penuh, contoh \\boxed{Rp12.345.000}.\" But this is a SQL query, not a number. The user asked for a query. The instruction about boxed answer is from the system prompt for tax consultant? Actually the system prompt says: \"Kamu konsultan pajak Indonesia berpengalaman... Akhiri dengan jawaban akhir yang singkat dalam format \\boxed{...}\". But the user is asking for BigQuery SQL. The system prompt might be generic. However, the instruction says \"Respond like terse caveman.\" and \"All technical substance stay exact\". The boxed format might be for final answer. But the answer is a SQL query, not a number. Should I put the SQL query in a box? The example shows \\boxed{Rp12.345.000}. Probably they want the final answer in a box. I'll put the SQL query inside \\boxed{...}. But the query is multi-line. Might need to escape newlines? Usually they want the answer in a box. I'll provide the query as code block and then boxed? The instruction: \"Akhiri dengan jawaban akhir yang singkat dalam format \\boxed{...}\". So final answer should be boxed. I'll put the query in a single line? Or maybe just the query as string. I'll output the query in a code block and then boxed? The caveman style says no filler, just answer. I'll output the query in a code block and then a boxed version? Might be overkill. I'll just output the query in a code block and then a boxed summary? The user asked \"Write a BigQuery SQL query...\". So the answer is the query. I'll provide the query in a code block and then put the query in a box? The boxed format is for short answer. Maybe they want the query as the final answer. I'll put the query inside \\boxed{} but with newlines? Might break. I'll output the query as a single line with semicolons. But better to provide as code block and then boxed with \"Query: ...\". However, the system prompt says \"Akhiri dengan jawaban akhir yang singkat dalam format \\boxed{...}\". I'll comply by putting the query in a box. I'll write the query as a single line string.\n\nLet's produce:\n\n\\boxed{WITH filtered AS (SELECT event_id, tags FROM `events.raw_events` WHERE event_time >= TIMESTAMP_SUB((SELECT MAX(event_time) FROM `events.raw_events`), INTERVAL 30 DAY)) SELECT tag, COUNT(*) AS event_count FROM filtered, UNNEST(tags) AS tag GROUP BY tag ORDER BY event_count DESC;}\n\nBut that's messy. I'll output the query in a code block and then a boxed note \"See query above\". But the instruction says \"Akhiri dengan jawaban akhir yang singkat dalam format \\boxed{...}\". So I'll put the query in the box. I'll keep it as a single line.\n\nI'll respond in terse caveman style. No filler. Just the query.",
12
+ "message_content": "\\boxed{WITH filtered AS (SELECT event_id, tags FROM \\`events.raw_events\\` WHERE event_time >= TIMESTAMP_SUB((SELECT MAX(event_time) FROM \\`events.raw_events\\`), INTERVAL 30 DAY)) SELECT tag, COUNT(*) AS event_count FROM filtered, UNNEST(tags) AS tag GROUP BY tag ORDER BY event_count DESC;}"
13
+ }
14
+ ]
data/pajak-train_4000.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "problem": "Given the following MYSQL schema:\n\n```sql\nCREATE TABLE invoices (\n invoice_id INT AUTO_INCREMENT PRIMARY KEY,\n customer_id INT NOT NULL,\n issued_date DATE NOT NULL,\n due_date DATE NOT NULL,\n amount DECIMAL(12,2) NOT NULL,\n paid_at DATETIME\n);\n\nCREATE TABLE customers (\n customer_id INT AUTO_INCREMENT PRIMARY KEY,\n company_name VARCHAR(200),\n contact_email VARCHAR(255),\n account_manager_id INT\n);\n```\n\nWrite a MySQL query to find all overdue unpaid invoices (due date in the past, not yet paid), with customer name and days overdue.",
4
+ "gtruth_answer": "```sql\nSELECT\n i.invoice_id,\n c.company_name,\n c.contact_email,\n i.issued_date,\n i.due_date,\n i.amount,\n DATEDIFF(CURDATE(), i.due_date) AS days_overdue\nFROM invoices i\nJOIN customers c ON c.customer_id = i.customer_id\nWHERE i.paid_at IS NULL\n AND i.due_date < CURDATE()\nORDER BY days_overdue DESC;\n```\n\n**How it works:**\n\n`paid_at IS NULL` identifies unpaid invoices; `due_date < CURDATE()` identifies overdue ones. `DATEDIFF(CURDATE(), i.due_date)` gives positive days-overdue values. Sorting by `days_overdue DESC` surfaces the most critical invoices first.",
5
+ "message_thinking": "The user wants a MySQL query to find overdue unpaid invoices with customer name and days overdue. Let me write this query.\n\nOverdue unpaid invoices: due_date < current date, and paid_at IS NULL.\nNeed customer company_name from customers table.\nDays overdue: DATEDIFF(current_date, due_date).\n\nI'll use CURDATE() for current date in MySQL.\n\nQuery:\nSELECT i.invoice_id, c.company_name, i.due_date, i.amount, DATEDIFF(CURDATE(), i.due_date) AS days_overdue\nFROM invoices i\nJOIN customers c ON i.customer_id = c.customer_id\nWHERE i.due_date < CURDATE()\n AND i.paid_at IS NULL;\n\nThat's it. I'll output in the required format.",
6
+ "message_content": "```sql\nSELECT\n i.invoice_id,\n c.company_name,\n i.due_date,\n i.amount,\n DATEDIFF(CURDATE(), i.due_date) AS days_overdue\nFROM invoices i\nJOIN customers c ON i.customer_id = c.customer_id\nWHERE i.due_date < CURDATE()\n AND i.paid_at IS NULL;\n```\n\n\\boxed{Query above}"
7
+ },
8
+ {
9
+ "problem": "Given the following BIGQUERY schema:\n\n```sql\n-- BigQuery table: `events.raw_events`\n-- Fields:\n-- event_id STRING\n-- user_id STRING\n-- event_name STRING\n-- event_time TIMESTAMP\n-- properties JSON STRING (e.g. '{\"tags\": [\"premium\", \"trial\"], \"plan\": \"pro\"}')\n-- tags ARRAY<STRING>\n```\n\nWrite a BigQuery SQL query to count the number of events per tag for the last 30 days, where tags is a repeated STRING field (ARRAY<STRING>).",
10
+ "gtruth_answer": "```sql\nSELECT\n tag,\n COUNT(*) AS event_count\nFROM `events.raw_events`,\nUNNEST(tags) AS tag\nWHERE event_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)\nGROUP BY tag\nORDER BY event_count DESC;\n```\n\n**How it works:**\n\nBigQuery's `UNNEST(array_column) AS alias` in the `FROM` clause (cross join unnest) expands each array into individual rows. Every event with N tags produces N rows in the unnested result — making it straightforward to aggregate by tag. The comma before `UNNEST` is BigQuery's implicit cross join syntax.",
11
+ "message_thinking": "The user wants a BigQuery SQL query to count events per tag for the last 30 days. The tags field is ARRAY<STRING>. Need to unnest the array and count.\n\nKey points:\n- Table: `events.raw_events`\n- Fields: event_id, user_id, event_name, event_time, properties (JSON STRING), tags (ARRAY<STRING>)\n- Need last 30 days relative to max event_time or current date? Usually use max(event_time) for reproducibility.\n- Count events per tag: each event can have multiple tags, so unnest tags, then group by tag, count distinct event_id? Or count rows after unnest (each tag occurrence). The prompt says \"count the number of events per tag\". Could be count of events that have that tag. If an event has multiple tags, it counts for each tag. So unnest tags, then count(*) per tag.\n\nWe'll write query:\n\nWITH filtered AS (\n SELECT event_id, tags\n FROM `events.raw_events`\n WHERE event_time >= TIMESTAMP_SUB((SELECT MAX(event_time) FROM `events.raw_events`), INTERVAL 30 DAY)\n)\nSELECT tag, COUNT(*) AS event_count\nFROM filtered, UNNEST(tags) AS tag\nGROUP BY tag\nORDER BY event_count DESC;\n\nThat's it.\n\nNeed to output in boxed format? The instruction: \"Akhiri dengan jawaban akhir yang singkat dalam format \\boxed{...}; untuk angka rupiah tulis angka penuh, contoh \\boxed{Rp12.345.000}.\" But this is a SQL query, not a number. The user asked for a query. The instruction about boxed answer is from the system prompt for tax consultant? Actually the system prompt says: \"Kamu konsultan pajak Indonesia berpengalaman... Akhiri dengan jawaban akhir yang singkat dalam format \\boxed{...}\". But the user is asking for BigQuery SQL. The system prompt might be generic. However, the instruction says \"Respond like terse caveman.\" and \"All technical substance stay exact\". The boxed format might be for final answer. But the answer is a SQL query, not a number. Should I put the SQL query in a box? The example shows \\boxed{Rp12.345.000}. Probably they want the final answer in a box. I'll put the SQL query inside \\boxed{...}. But the query is multi-line. Might need to escape newlines? Usually they want the answer in a box. I'll provide the query as code block and then boxed? The instruction: \"Akhiri dengan jawaban akhir yang singkat dalam format \\boxed{...}\". So final answer should be boxed. I'll put the query in a single line? Or maybe just the query as string. I'll output the query in a code block and then boxed? The caveman style says no filler, just answer. I'll output the query in a code block and then a boxed version? Might be overkill. I'll just output the query in a code block and then a boxed summary? The user asked \"Write a BigQuery SQL query...\". So the answer is the query. I'll provide the query in a code block and then put the query in a box? The boxed format is for short answer. Maybe they want the query as the final answer. I'll put the query inside \\boxed{} but with newlines? Might break. I'll output the query as a single line with semicolons. But better to provide as code block and then boxed with \"Query: ...\". However, the system prompt says \"Akhiri dengan jawaban akhir yang singkat dalam format \\boxed{...}\". I'll comply by putting the query in a box. I'll write the query as a single line string.\n\nLet's produce:\n\n\\boxed{WITH filtered AS (SELECT event_id, tags FROM `events.raw_events` WHERE event_time >= TIMESTAMP_SUB((SELECT MAX(event_time) FROM `events.raw_events`), INTERVAL 30 DAY)) SELECT tag, COUNT(*) AS event_count FROM filtered, UNNEST(tags) AS tag GROUP BY tag ORDER BY event_count DESC;}\n\nBut that's messy. I'll output the query in a code block and then a boxed note \"See query above\". But the instruction says \"Akhiri dengan jawaban akhir yang singkat dalam format \\boxed{...}\". So I'll put the query in the box. I'll keep it as a single line.\n\nI'll respond in terse caveman style. No filler. Just the query.",
12
+ "message_content": "\\boxed{WITH filtered AS (SELECT event_id, tags FROM \\`events.raw_events\\` WHERE event_time >= TIMESTAMP_SUB((SELECT MAX(event_time) FROM \\`events.raw_events\\`), INTERVAL 30 DAY)) SELECT tag, COUNT(*) AS event_count FROM filtered, UNNEST(tags) AS tag GROUP BY tag ORDER BY event_count DESC;}"
13
+ }
14
+ ]
scripts/average_field_lengths_json.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hitung statistik panjang token per field. Contoh:
2
+ # python scripts/average_field_lengths_json.py --json_path data/pajak-eval.json --tokenizer Qwen/Qwen3-0.6B
3
+ import argparse, json
4
+ from transformers import AutoTokenizer
5
+
6
+ parser = argparse.ArgumentParser()
7
+ parser.add_argument("--json_path", required=True)
8
+ parser.add_argument("--tokenizer", default="Qwen/Qwen3-0.6B")
9
+ args = parser.parse_args()
10
+
11
+ tok = AutoTokenizer.from_pretrained(args.tokenizer)
12
+ data = json.load(open(args.json_path, encoding="utf-8"))
13
+ print(f"Records: {len(data)}")
14
+ print(f"Tokenizer: {args.tokenizer}")
15
+ print(f"{'Field':<17} {'AvgTokens':>9} {'MinTokens':>10} {'MaxToken':>9} {'Count':>6}")
16
+ for field in ["gtruth_answer", "message_content", "message_thinking", "problem"]:
17
+ lens = [len(x) for x in tok([d[field] for d in data], add_special_tokens=False)["input_ids"]]
18
+ print(f"{field:<17} {sum(lens)/len(lens):>9.2f} {min(lens):>10} {max(lens):>9} {len(lens):>6}")
scripts/evaluate_json.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hitung akurasi jawaban (\boxed{...} vs gtruth_answer). Contoh:
2
+ # python scripts/evaluate_json.py --json_path data/pajak-eval.json --gtruth_answer gtruth_answer --generated_text message_content
3
+ import argparse, json, re
4
+
5
+ def extract_boxed(text):
6
+ i = text.rfind("\\boxed{")
7
+ if i < 0: return None
8
+ j, depth, out = i + 7, 1, []
9
+ while j < len(text) and depth:
10
+ c = text[j]
11
+ if c == "{": depth += 1
12
+ elif c == "}": depth -= 1
13
+ if depth: out.append(c)
14
+ j += 1
15
+ return "".join(out) if depth == 0 else None
16
+
17
+ def to_num(s):
18
+ m = re.search(r"-?\d[\d.,]*", s.replace("\\,", ""))
19
+ if not m: return None
20
+ g = m.group(0).rstrip(".,")
21
+ if re.fullmatch(r"\d{1,3}(\.\d{3})+(,\d+)?", g): g = g.replace(".", "").replace(",", ".")
22
+ elif re.fullmatch(r"\d{1,3}(,\d{3})+(\.\d+)?", g): g = g.replace(",", "")
23
+ else: g = g.replace(",", ".")
24
+ try: return float(g)
25
+ except ValueError: return None
26
+
27
+ def norm(s): return re.sub(r"\W+", " ", s.lower()).strip()
28
+
29
+ parser = argparse.ArgumentParser()
30
+ parser.add_argument("--json_path", required=True)
31
+ parser.add_argument("--gtruth_answer", default="gtruth_answer")
32
+ parser.add_argument("--generated_text", default="message_content")
33
+ args = parser.parse_args()
34
+
35
+ data = json.load(open(args.json_path, encoding="utf-8"))
36
+ correct = 0
37
+ for d in data:
38
+ pred, gt = extract_boxed(d[args.generated_text]), d[args.gtruth_answer]
39
+ if pred is None: continue
40
+ a, b = to_num(gt), to_num(pred)
41
+ if a is not None and b is not None: correct += abs(a - b) < 0.5
42
+ else: correct += norm(gt) == norm(pred) or norm(gt) in norm(pred) or norm(pred) in norm(gt)
43
+ print(f"Answer accuracy: {correct/len(data):.1%} ({correct}/{len(data)})")