Views
No views yet
You are EventSpec, an expert MarTech analytics engineer. You convert free-form marketing tracking requests into clean, implementation-ready analytics event specifications.
Given a marketing tracking request, respond with a SINGLE valid JSON object and nothing else: no prose, no markdown, no code fences. The JSON must be strictly parseable.
The specification captures: a concise `request_summary`; the `business_goal`; the `tracking_scope` (platforms, page_or_screen, user_action, conversion_type); and a list of `recommended_events`. Each recommended event defines `event_name` (snake_case), `event_description`, `platform`, `event_type`, `required_parameters`, `optional_parameters`, `trigger_condition`, `consent_requirements`, and `deduplication_requirements`.
Use consistent snake_case event and parameter names, follow analytics best practices (GA4/GTM conventions where relevant), and respect privacy/consent requirements. Output only the JSON object.Convert this marketing tracking request into a clean analytics event specification.
Request:
<your tracking request here>1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4repo = "joshelu/qwen3-4b-eventspec-martech-merged"
5tok = AutoTokenizer.from_pretrained(repo)
6model = AutoModelForCausalLM.from_pretrained(repo, dtype=torch.bfloat16, device_map="auto")
7
8SYSTEM_PROMPT = (
9 "You are EventSpec, an expert MarTech analytics engineer. You convert free-form "
10 "marketing tracking requests into clean, implementation-ready analytics event "
11 "specifications.\n\n"
12 "Given a marketing tracking request, respond with a SINGLE valid JSON object and "
13 "nothing else: no prose, no markdown, no code fences. The JSON must be strictly "
14 "parseable.\n\n"
15 "The specification captures: a concise `request_summary`; the `business_goal`; the "
16 "`tracking_scope` (platforms, page_or_screen, user_action, conversion_type); and a "
17 "list of `recommended_events`. Each recommended event defines `event_name` "
18 "(snake_case), `event_description`, `platform`, `event_type`, `required_parameters`, "
19 "`optional_parameters`, `trigger_condition`, `consent_requirements`, and "
20 "`deduplication_requirements`.\n\n"
21 "Use consistent snake_case event and parameter names, follow analytics best "
22 "practices (GA4/GTM conventions where relevant), and respect privacy/consent "
23 "requirements. Output only the JSON object."
24)
25USER_PREFIX = "Convert this marketing tracking request into a clean analytics event specification."
26
27request = ("A pharmacy app wants to track refill reminders, refill started, refill submitted, "
28 "refill ready, and pickup completed, but no medication names or prescription numbers "
29 "should be sent.")
30
31messages = [
32 {"role": "system", "content": SYSTEM_PROMPT},
33 {"role": "user", "content": f"{USER_PREFIX}\n\nRequest:\n{request}"},
34]
35prompt = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
36inputs = tok(prompt, return_tensors="pt").to(model.device)
37
38out = model.generate(**inputs, max_new_tokens=2048, do_sample=False,
39 pad_token_id=tok.eos_token_id)
40print(tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))1from huggingface_hub import InferenceClient
2client = InferenceClient("https://YOUR-ENDPOINT.endpoints.huggingface.cloud", token="hf_...")
3resp = client.chat_completion(
4 messages=[
5 {"role": "system", "content": SYSTEM_PROMPT},
6 {"role": "user", "content": f"{USER_PREFIX}\n\nRequest:\n{request}"},
7 ],
8 max_tokens=2048,
9 temperature=0,
10)
11print(resp.choices[0].message.content)temperature = 0 (greedy) — best for stable, strictly parseable JSON.max_new_tokens >= 2048 — specs are long; a lower limit will truncate the JSON mid-string.json.loads; retry with a higher token limit if parsing fails.request_summary — one-line summary of the request.business_goal — the measurement objective.tracking_scope — { platforms, page_or_screen, user_action, conversion_type }.recommended_events — list of events, each with event_name (snake_case),
event_description, platform, event_type, required_parameters,
optional_parameters, trigger_condition, consent_requirements,
deduplication_requirements.implementation_notes, qa_criteria,
open_questions, and risk_flags, which the model produces as appropriate.joshelu/martech-event-taxonomy-mapper-training-data (private).
train split, minus every id appearing in the validation or test
split → 80 training rows (held-out eval stays honest).validation split (10 rows).json.dumps(output, separators=(",", ":"))),
validated as parseable before training.r=16, alpha=32, dropout=0.05,
target modules q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj.2e-4,
warmup ratio 0.05, cosine schedule, max length 2048, bf16, gradient checkpointing.0.320, eval mean token accuracy ≈ 0.924.max_new_tokens, long specs will be truncated and fail JSON parsing — keep
the limit high and validate the parse.