DenseFeed / scripts /generate_synthetic_data.py
j14i's picture
feat: SmolLM2-135M ranker fine-tuning pipeline + BAML streaming improvements
ad58b0c
Raw
History Blame Contribute Delete
2.42 kB
#!/usr/bin/env python3
import json
import random
import pathlib
def generate():
out_dir = pathlib.Path("data")
out_dir.mkdir(exist_ok=True)
titles = [
"Apple releases new MLX framework for Apple Silicon",
"How to use Rust in your backend",
"An introduction to QLoRA fine-tuning",
"Why we migrated from React to Vue",
"The future of AI is smaller models",
"Python 3.13 released with new features",
"Understanding Generalized Knowledge Distillation",
"Building a podcast generator with Edge-TTS"
]
with open("data/rank_log_filter.jsonl", "w") as f1, open("data/rank_log_score.jsonl", "w") as f2:
for i in range(100):
title = random.choice(titles) + f" - Part {i}"
source = random.choice(["hn", "arxiv", "github", "rss"])
summary = "This is a synthetic summary about " + title
is_relevant = any(k in title for k in ["MLX", "QLoRA", "AI", "models", "podcast"])
verdict = "KEEP" if is_relevant else "DROP"
if is_relevant:
score = random.randint(7, 10)
reason = "Highly relevant to our technical podcast about AI and ML on macOS."
reasoning = "This article explicitly mentions MLX and Apple Silicon. Since our audience is senior engineers interested in local AI, this is a strong KEEP."
else:
score = random.randint(1, 4)
reason = "Not relevant enough for the podcast theme."
reasoning = "This article is about a general topic that doesn't fit our core focus on AI, local models, or macOS development. It lacks deep technical signal."
f1.write(json.dumps({
"title": title,
"source": source,
"summary": summary,
"reasoning": reasoning,
"verdict": verdict
}) + "\n")
f2.write(json.dumps({
"title": title,
"source": source,
"summary": summary,
"reasoning": reasoning,
"score": score,
"reason": reason
}) + "\n")
print("Generated synthetic data in data/rank_log_filter.jsonl and data/rank_log_score.jsonl")
if __name__ == "__main__":
generate()