Skip to content

Repository files navigation

Lydia's Blog Finetuning Project

Successfully finetuned Llama 3.1 70B on your Substack blog posts to generate content in your writing style.


πŸŽ‰ What's Done

βœ… Finetuned Model: lydia-blog-llama70b-v1 (Llama 3.1 70B)
βœ… Training Data: 114 high-quality examples from your blog
βœ… Training Cost: $0.13
βœ… Final Loss: 0.2336 (excellent!)
βœ… Sample Quality: Generates text that sounds like you


πŸš€ Quick Start: Generate Samples

python3 sample_correctly.py

This will generate 500-token samples from your finetuned Llama 70B model.

Your finetuned checkpoint:

tinker://5e055c1d-a64d-5886-bb21-d59f26ce83b2:train:0/sampler_weights/ephemeral_175

πŸ“ Important Files

Core Files (KEEP):

  • blogposts_unified_instruction.jsonl - Training dataset (114 examples)
  • sample_correctly.py - Working script to generate samples
  • tinker_train_llama70b.py - Training script used
  • substack-feed.rss - Original blog RSS feed
  • training_llama70b.log - Training results and sample outputs
  • requirements.txt - Python dependencies

Data Preparation (KEEP):

  • parse_rss_to_plaintext.py - RSS β†’ Plaintext converter
  • create_all_formats.py - Format generator
  • create_unified_format.py - Unified format creator
  • clean_bad_examples.py - Removed incomplete examples
  • validate_unified.py - Data validator

πŸ’° Costs

Training (Complete):

  • Llama 70B training: $0.13 (3 epochs, LoRA)
  • Training time: ~10 minutes

Inference (Per Use):

  • ~1,500 tokens: < $0.01
  • Much cheaper than training!

πŸ“Š Training Results

Your finetuned Llama 70B achieved:

Metric Value
Final Loss 0.2336
Training Examples 114
Epochs 3
Method LoRA (Low-Rank Adaptation)
Base Model meta-llama/Llama-3.1-70B

Sample Output Quality:

Prompt: "Write a blog post about AI safety:"

Output:

"Today I was fortunate enough to hear from a law student interested in avoiding catastrophic existential risk from superintelligence. In response to his questions, I wrote the following: Hey [..]! Thank you for coming to me with your questions :) I'm so glad there are more people thinking about this!..."

βœ… Matches your casual, personal tone
βœ… Uses your vocabulary and phrasing
βœ… Maintains your conversational style


🎯 What Your Model Can Do

After training on your blog posts, the model can:

  1. Generate blog posts in your writing style

    • Prompt: "Write a blog post about AI alignment:"
    • Gets your tone, structure, and voice right
  2. Answer questions about your work

    • Prompt: "What are your thoughts on revealed preferences?"
    • Draws from your actual blog content
  3. Follow instructions on related topics

    • Prompt: "Tell me about mutual information:"
    • Uses your writing as a foundation

πŸ”„ How to Use Your Model

Generate Samples:

python3 sample_correctly.py

Download Weights Locally:

tinker download lydia-blog-llama70b-v1

View Training Logs:

cat training_llama70b.log

πŸ“š Training Data Details

Dataset: blogposts_unified_instruction.jsonl

  • 114 examples (cleaned from 133 - removed bad summaries)
  • ~91,000 tokens
  • Average: 800 tokens/example

Data Sources:

  • 20 completion examples (full blog posts)
  • 33 instruction examples (prompted writing)
  • 61 Q&A examples (questions about your work)

Format:

{
  "prompt": "Write a blog post about AI safety:",
  "completion": "Today I was fortunate enough to hear from..."
}

πŸ”§ Technical Details

Training Configuration:

BASE_MODEL = "meta-llama/Llama-3.1-70B"
NUM_EPOCHS = 3
LEARNING_RATE = 5e-5
BATCH_SIZE = 4
METHOD = "LoRA" (Low-Rank Adaptation)

Why These Settings:

  • Llama 70B: Best balance of quality and cost
  • LoRA: 11% cheaper than full finetuning, similar results
  • 3 epochs: Prevents overfitting on small dataset
  • Learning rate 5e-5: Standard for LoRA finetuning

πŸ’‘ Tips for Best Results

When Generating:

  • Temperature 0.7: Good balance (used in sample_correctly.py)
  • Max tokens 500: Long enough for complete thoughts
  • Stop sequence \n\n\n: Prevents rambling

Prompt Examples:

  • βœ… "Write a blog post about [topic]:"
  • βœ… "What are your thoughts on [concept]?"
  • βœ… "Explain [idea] in your words:"
  • ❌ Avoid overly generic prompts

πŸ”„ To Retrain (If Needed)

1. Update Your RSS Feed:

curl https://lydianottingham.substack.com/feed > substack-feed.rss

2. Regenerate Training Data:

python3 parse_rss_to_plaintext.py
python3 create_all_formats.py
python3 create_unified_format.py
python3 clean_bad_examples.py
python3 validate_unified.py

3. Retrain:

python3 tinker_train_llama70b.py

πŸ“ˆ Cost Projections

Scenario Cost
Current model (done) $0.13
Retrain with more data ~$0.15-0.25
Daily inference (100 prompts) ~$1-2
Monthly inference (3000 prompts) ~$30-60

πŸŽ“ What We Learned

What Worked Well:

  • βœ… Llama 70B captured your style better than smaller models
  • βœ… Cleaning bad examples improved quality significantly
  • βœ… Unified format (mixing completions, instructions, Q&A) created a versatile model
  • βœ… 3 epochs was the sweet spot (loss 0.23 vs 2.65 initially)

Challenges Overcome:

  • ❌ Initial sampling scripts didn't work (wrong API calls)
  • ❌ Created many extra training runs accidentally
  • βœ… Final solution: Use create_sampling_client(model_path=checkpoint)

πŸ“– Resources


πŸŽ‰ Summary

You now have a production-ready, finetuned Llama 70B model that:

  • Writes blog posts in your voice
  • Answers questions about your work
  • Follows instructions on related topics
  • Cost only $0.13 to train
  • Generates high-quality output

Ready to use! Run python3 sample_correctly.py to start generating.


Last updated: November 19, 2025

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages