- Home
- Skills
- Muratcankoylan
- Agent Skills For Context Engineering
- Book Sft Pipeline
book-sft-pipeline_skill
- Python
12.1k
GitHub Stars
2
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill muratcankoylan/agent-skills-for-context-engineering --skill book-sft-pipeline- README.md2.4 KB
- SKILL.md13.9 KB
Overview
This skill provides a complete pipeline to convert books (preferably ePub) into SFT datasets and train style-transfer models using LoRA. It covers extraction, intelligent segmentation, diverse instruction generation, dataset assembly, LoRA training, and validation aimed at capturing authorial voice rather than memorizing plots. Use it when building small, efficient style models and preparing training artifacts for platforms like Tinker.
How this skill works
The pipeline extracts paragraph-level text from ePub files, removes front/back matter, and segments the text into semantically coherent chunks (150–400 words) with overlap. A fast LLM generates concise scene descriptions from each chunk using many system and prompt templates to produce diverse instruction–response pairs. Those pairs are assembled into a message-format JSONL dataset, then used to train a LoRA adapter on a base model, and finally validated with modern-scenario tests and originality checks.
When to use it
- Creating fine-tuning datasets from literary works or collections of books
- Training author-voice or style-transfer models (LoRA) on small to mid-sized models (≤8B)
- Preparing SFT datasets for platforms like Tinker or similar training services
- Designing segmentation pipelines for long-form content to preserve coherence
- Validating that a model learned style rather than memorized content
Best practices
- Always prefer ePub over PDF; extract from paragraph tags to avoid OCR artifacts
- Segment at paragraph boundaries into 150–400 word chunks and include small overlaps
- Use many diverse system prompts and 15+ prompt templates to avoid memorization
- Train adapters on base (non-instruct) models for better malleability
- Reserve a held-out test set (≥50 examples) and run modern-scenario tests to verify style transfer
- Search training data for verbatim output phrases to check originality
Example use cases
- Convert a single novel into 500–1000 SFT examples and train a LoRA adapter for an 8B base model
- Create a dataset from multiple short books to reduce character-name leakage and improve generalization
- Produce variants per chunk (2–4) with different system prompts to expand training diversity
- Validate a style adapter by asking it to write modern scenarios (texting, climate anxiety) in the author’s voice
- Integrate the orchestrator agent to resume failed phases and produce audit artifacts for debugging
FAQ
Base models are more malleable for low-level style patterns. Instruction-tuned models carry prior instruction mappings that resist overwriting, making style transfer harder.
How do I avoid the model repeating exact sentences from the book?
Use diverse prompts, limit epochs (e.g., ≤3), train on multiple books or synthetic variations, and grep your dataset for training phrases to ensure outputs are novel.