LocalLLM Forum — Run it locally. Own your models.

Building a clean instruction dataset from your own chat logs

I posted by IngridMarchetti #datasets#jsonl#fine-tuning 3 posts 1,108 views
I

Before anyone reaches for a scraped dataset, consider that you're already sitting on the most valuable training data you'll ever get: your own chat logs, cleaned up. Here's the pipeline I use, end to end.

Target format

One JSON object per line, chat-message format — this loads directly into most SFT trainers:

{"messages": [
  {"role": "system", "content": "You are a concise technical assistant."},
  {"role": "user", "content": "Why does KV cache memory grow linearly with context length?"},
  {"role": "assistant", "content": "Because each generated token appends one key and one value vector per layer. With 40 layers and a head dimension of 128, every token adds roughly 10 KB in fp16 — so 32k tokens of context means about 320 MB of cache, regardless of the model's weights."}
]}

The pipeline

  1. Export and filter — keep only turns where you didn't immediately correct the answer. My acceptance rate was about 30%.
  2. Exact dedup — hash the normalised user turn; drop repeats.
  3. Near dedup — MinHash with a 0.85 Jaccard threshold. This removed another 18% that exact hashing missed.
  4. PII scrubbing — regex for emails, phone numbers, API keys and IPv4 addresses, then a NER pass for names and addresses. Assume your logs contain your own credentials. Mine did.
  5. Length filter — drop assistant turns under 20 tokens ("Yes.") and over 1,024 (usually pasted logs, not answers).

Funnel

raw exported turns        41,300
after acceptance filter   12,905
after exact dedup         11,412
after MinHash dedup        9,358
after PII/length filter   12,847 → 9,102   (final)

9,102 clean pairs was enough for a respectable LoRA on an 8B — the model picked up my documentation style within 2 epochs. Quality over quantity is not a slogan here, it's the whole game.

"Pushing 24GB to its limits since 2023." — Ingrid Marchetti, Bergen
M

Useful write-up, thanks. Question on the MinHash step: what similarity threshold did you settle on, and did you find 0.85 too aggressive for technical Q&A? Two questions about, say, VRAM sizing can share 90% of their wording while needing genuinely different answers.

I've been using 0.90 and still caught myself reviewing the dropped pairs manually. Also, do you dedup on the user turn only, or on the (user, assistant) pair? Deduping on the pair keeps the same question with two good phrasings of the answer, which I think is what you want.

Ryzen 7950X + RTX 4090 · São Paulo
Y
M MateusKeller replied
…do you dedup on the user turn only, or on the (user, assistant) pair?…

Adding one warning from my own attempt at this: your logs are full of your voice, and after a few epochs the fine-tuned model starts doing an impression of you — same openings, same hedging, same jokes. Sometimes that's the goal, but if you want a generally useful assistant, mix in 20–30% of rewritten or synthetic variants so it doesn't collapse into a single register.

Also second the PII paranoia. I found a live API key in month-old logs that I'd completely forgotten pasting. Scrub first, train second, and rotate anything that ever touched a log file.

If the fans are audible, the build isn't finished.
Want to join the discussion? Register or log in to reply. Register Log in
Reply
Ctrl+Enter to submit
post 1 of 3