9.5 Synthetic Instructions & Self-Instruct
합성 instruction은 전문가 작성 예시가 부족할 때 범위를 넓힙니다. 사람을 없애는 것이 아니라 specification, gold set, 어려운 slice, audit에 사람의 노력을 집중시킵니다. 유용한 파이프라인은 모든 생성 샘플을 재현 가능한 lineage를 가진 신뢰하지 않는 데이터로 취급합니다.
세 가지 생성 패턴
Self-Instruct 는 작은 seed set에서 instruction, instance, response를 생성하고 near duplicate를 걸러 task를 확장합니다 [1]. Evol-Instruct 는 기존 instruction을 깊이 또는 폭 방향으로 변형해 난이도와 범위를 조절합니다 [2]. Magpie 는 instruction-tuned model의 pre-query 상태를 사용해 그 모델이 학습한 대화 분포에서 그럴듯한 사용자 질의를 sampling합니다 [3].
세 방법의 목적은 다릅니다. Self-Instruct는 task family를 늘리고, Evol-Instruct는 변형을 제어하며, Magpie는 교사 모델 고유의 prompt prior를 sampling합니다. 어느 방법도 정확성, 새로움, 안전성, 제품 관련성을 보장하지 않습니다.
Evol-Instruct Progression
Click "Evolve" to mutate the prompt into a more complex instruction.
Base Instruction
Write a sorting algorithm.Analysis: A simple, generic request. The model will likely output a standard Bubble Sort or Quick Sort in Python without much thought.
Template은 생성 경계다
Magpie 방식은 모델별로 다릅니다. tokenizer가 다른 protocol을 정의하는데 <|user|> 같은 문자열을 직접 넣으면 안 됩니다. Generator와 judge 모두 tokenizer.apply_chat_template을 사용하고 각 템플릿을 독립적으로 고정합니다.
질의 생성에는 다음 role 또는 end-of-turn marker를 중단 토큰(stop token) 경계로 지정해야 합니다. 그렇지 않으면 교사가 assistant turn까지 생성하고 파이프라인이 답변 일부를 사용자 질의로 잘못 label할 수 있습니다. 이후 완성한 user message를 add_generation_prompt=True로 다시 rendering해 답변을 생성합니다.
아래는 의도적으로 framework-neutral하게 만든 교육용 sketch입니다. 정확한 inference backend에 맞춘 adapter code가 필요하며 production-ready loop는 아닙니다.
def render_query_prefix(tokenizer):
# 빈 user turn을 실제로 지원하는지는 template별로 검증해야 합니다.
return tokenizer.apply_chat_template(
[{"role": "user", "content": ""}],
tokenize=True,
add_generation_prompt=False,
)
def render_answer_prefix(tokenizer, query):
return tokenizer.apply_chat_template(
[{"role": "user", "content": query}],
tokenize=True,
add_generation_prompt=True,
)
# 고정한 generator tokenizer/template에서 ID를 구합니다.
query_stop_token_ids = resolve_next_role_or_eot_ids(generator_tokenizer)
query_ids = generate(
render_query_prefix(generator_tokenizer),
stop_token_ids=query_stop_token_ids,
max_new_tokens=512,
)
query = decode_generated_span_only(generator_tokenizer, query_ids)
answer_ids = generate(
render_answer_prefix(generator_tokenizer, query),
stop_token_ids=[generator_tokenizer.eos_token_id],
max_new_tokens=1024,
)
Decoded string을 len(prompt) 위치에서 잘라 생성 결과를 복구하면 안 됩니다. tokenizer normalization과 Unicode 때문에 문자 offset이 달라질 수 있습니다. token boundary를 보존하고 새로 생성된 token ID만 decode합니다.
생성, 검증, 판정, 감사
견고한 파이프라인은 독립된 gate를 둡니다.
- schema와 boundary 검사: role, EOS, language, length, empty field, tool schema
- 결정적 검증: sandbox에서 code 실행, verifier로 math 검사, JSON·tool argument 검증
- deduplication과 평가 격리: exact, near, semantic, benchmark contamination, private prompt neighbor
- judge scoring: 별도로 고정한 judge template과 target-domain rubric
- 사람 골드 감사(human gold audit): random sample과 모든 고위험·불확실·judge 불일치 사례
Reward threshold는 보편적이지 않습니다. 사람 gold label로 accept/review/reject 구간을 보정하고 language, domain, length, difficulty, safety slice별 precision을 보고합니다. 가능한 경우 여러 신호를 사용합니다. 문장을 잘 평가하는 judge도 틀린 프로그램을 승인할 수 있습니다.
Lineage와 Mixture 제어
각 candidate에 다음을 보존합니다.
- teacher model revision, tokenizer와 chat-template hash
- generator prompt 또는 seed task, mutation chain, random seed, decoding setting
- judge/verifier model과 rubric version, raw score, 실행 결과, 거부 사유(rejection reason)
- source license/consent, PII/secrets/safety 결정, stable sample/cluster ID
- generation timestamp, pipeline code/config/container, parent sample ID
모든 gate에서 slice별 yield를 기록합니다. 전체 yield가 높아도 safety, minority language, difficult example이 대부분 버려질 수 있습니다. 사람 작성, 검증된 합성, adversarial, retention data를 명시적 sampling weight로 혼합합니다. 교사의 기본 verbosity나 선호 topic이 학생 분포를 결정하게 두지 않습니다.
관련 prompt, response, mutation, synthetic sibling을 split 전에 같은 semantic cluster로 묶습니다. public benchmark, private evaluation, rubric, semantic neighbor, teacher-generated variant를 격리합니다. 벤치마크의 생성 paraphrase도 벤치마크 오염(benchmark contamination) 입니다.
재귀적 성능 저하 막기
모델 생성 샘플로 반복 학습하면 coverage가 줄거나 artifact가 증폭될 수 있지만, “model collapse”가 항상 하나의 점으로 수렴하는 결정적 과정은 아닙니다. 위험은 합성·실제 데이터를 선택하고 혼합하고 평가하는 방식에 따라 달라집니다 [4].
새로운 human data, 명시적 rare-slice target, source diversity, calibrated rejection sampling, semantic diversity metric, 고정한 human-authored retention evaluation을 사용합니다. Temperature만 높인다고 사라진 tail이 복원되지는 않으며 오류가 늘 수 있습니다.
학습 전 같은 token budget으로 synthetic mixture와 human-only baseline을 비교합니다. 작은 pilot 후 target slice 개선과 base-retention, safety, diversity regression 한도를 함께 요구합니다. 이전 manifest와 model bundle을 rollback용으로 보존합니다.
합성 instruction은 intervention 진단을 대신하지도 않습니다. 바뀌며 출처가 필요한 지식은 retrieval, 폭넓은 분포 적응은 continued pre-training, supervised behavior는 held-out evidence가 지지할 때 SFT를 사용합니다.
Quizzes
Quiz 1: Magpie 방식의 질의 생성이 다음 role boundary에서 멈춰야 하는 이유는 무엇인가요?
Role 또는 end-of-turn stop이 없으면 교사가 user query와 assistant answer 일부를 함께 생성할 수 있습니다. 그러면 파이프라인이 role을 잘못 배정하고 손상된 boundary를 학습합니다.
Quiz 2: Generator와 judge template을 별도로 고정해야 하는 이유는 무엇인가요?
두 모델이 서로 다른 role token과 BOS/EOS 규칙을 가진 계열일 수 있기 때문입니다. 하나의 수동 format을 함께 쓰면 생성과 judge calibration이 모두 무효가 될 수 있습니다.
Quiz 3: 합성 샘플의 lineage는 무엇을 재구성할 수 있어야 하나요?
Teacher, prompt 또는 parent, mutation chain, seed, decoding setting, tokenizer/template, judge와 rubric, verifier output, rejection decision, code/config, stable sample·cluster identity를 재구성해야 합니다.
Quiz 4: Judge score가 높아도 안전한 학습 데이터가 아닐 수 있는 이유는 무엇인가요?
Judge가 generator와 style bias를 공유하거나, domain 밖에 있거나, verbosity를 선호하거나, 실행·안전 오류를 놓칠 수 있습니다. 보정한 human gold audit와 결정적 verifier가 독립 검사 역할을 합니다.
References
- Wang, Y., et al. (2022). Self-Instruct: Aligning Language Models with Self-Generated Instructions. arXiv:2212.10560.
- Xu, C., et al. (2023). WizardLM: Empowering Large Language Models to Follow Complex Instructions. arXiv:2304.12244.
- Xu, Z., et al. (2024). Magpie: Alignment Data Synthesis from Scratch by Prompting Aligned LLMs with Nothing. arXiv:2406.08464.
- Shumailov, I., et al. (2024). AI models collapse when trained on recursively generated data. Nature.