Modern language-model development depends on more than pre-training. To make a foundation model useful, controllable, and aligned with human expectations, teams typically combine supervised fine-tuning (SFT) with preference-optimization or reinforcement-learning methods such as reinforcement learning from human feedback (RLHF). Together, RLHF and SFT pipelines transform a general-purpose base model into a system that follows instructions, respects policy constraints, communicates clearly, and performs well on domain-specific tasks.
For Indian AI startups, research groups, and public-sector technology teams, these pipelines are especially relevant when adapting models to Indian languages, regulated workflows, enterprise data, or multilingual user experiences. The challenge is not simply selecting an algorithm. It is designing a reproducible data, training, evaluation, and deployment system in which every stage can be audited and improved.
What Are RLHF and SFT Pipelines?
An SFT pipeline trains a pre-trained language model on curated examples of desired behavior. Each example generally contains an instruction, optional context, and a high-quality response. The model learns through next-token prediction to imitate those responses.
An RLHF pipeline uses human or expert preferences to optimize a model beyond direct imitation. Annotators compare candidate outputs, a preference model learns which responses are better, and an optimization algorithm updates the policy model to produce higher-scoring outputs while limiting harmful or unstable changes.
A practical end-to-end system often looks like this:
1. Base model selection and profiling
2. Instruction and demonstration data collection
3. Data cleaning, filtering, and governance
4. Supervised fine-tuning
5. Preference-pair or ranking data collection
6. Reward or preference-model training
7. Policy optimization or direct preference optimization
8. Safety, capability, and regression evaluation
9. Serving, monitoring, and continuous improvement
The stages are iterative rather than strictly linear. Evaluation findings may require new demonstrations, revised annotation rules, or a narrower optimization objective.
Stage 1: Choose and Profile the Base Model
The base model determines the computational cost, context window, tokenizer behavior, language coverage, and achievable quality ceiling. Before training, profile it on representative tasks rather than relying only on public benchmark scores.
Important profiling dimensions include:
- Instruction-following ability before fine-tuning
- Support for Hindi, Tamil, Telugu, Bengali, Marathi, and other target languages
- Code-switching between English and Indian languages
- Context-window limits and long-document behavior
- Hallucination rates on domain questions
- Toxicity, privacy leakage, and unsafe-completion tendencies
- Tokenization efficiency for target scripts
- Inference latency and memory requirements
For resource-constrained teams, parameter-efficient fine-tuning methods such as LoRA, QLoRA, adapters, and low-rank updates can reduce GPU memory requirements. However, quantization and adapter choices should be tested for their effect on multilingual quality, factuality, and downstream alignment—not evaluated only by training cost.
Stage 2: Build High-Quality SFT Data
SFT data is the behavioral foundation of the final model. A smaller, carefully written dataset can outperform a larger collection of noisy or contradictory examples. Each record should have a clear task objective and an answer that represents the intended production standard.
A robust instruction record may contain:
{
"instruction": "Summarise the policy in plain language.",
"context": "Source document or conversation context",
"response": "A concise, accurate, and properly qualified answer",
"metadata": {
"domain": "public_policy",
"language": "en-IN",
"risk_level": "medium",
"source": "expert_authored"
}
}SFT data quality controls
Use automated and human checks to identify:
- Duplicates and near-duplicates
- Prompt-response mismatches
- Unsupported factual claims
- Unsafe advice or privacy violations
- Excessive verbosity and repetitive phrasing
- Language or script errors
- Leakage of system prompts, credentials, or personal data
- Conflicts between examples and product policy
For India-focused applications, include realistic linguistic variation: formal English, Indian English, transliterated Hindi, code-mixed queries, regional names, local units, and domain terminology. Do not assume that translating English examples creates culturally or linguistically adequate data. Native-speaker review is essential for safety-sensitive and public-facing systems.
Designing the SFT Training Run
SFT commonly uses causal language-model loss over the assistant response. In chat formats, teams usually mask the loss on system and user tokens so that optimization focuses on generating the target assistant message. Incorrect chat templates can silently degrade training, especially when special tokens, role markers, or end-of-turn tokens are inconsistent.
Key configuration decisions include:
- Learning rate and scheduler
- Effective batch size and gradient accumulation
- Maximum sequence length
- Packing strategy for short examples
- Number of epochs and early-stopping criteria
- Weight decay and gradient clipping
- Mixed precision, checkpointing, and distributed strategy
- Full-parameter versus parameter-efficient tuning
Track training loss, validation loss, task-specific metrics, and qualitative samples at regular checkpoints. A falling loss does not guarantee better instruction following. Overfitting can produce polished but brittle responses, particularly when examples are narrow or stylistically uniform.
Stage 3: Collect Preference Data for RLHF
After SFT, generate multiple responses to the same prompt and ask trained annotators to rank or compare them. Preference data should represent real production trade-offs rather than simple stylistic choices.
A comparison record can include:
{
"prompt": "Explain the tax concept without giving personalised legal advice.",
"chosen": "Accurate answer with scope limits and a recommendation to consult a qualified professional.",
"rejected": "Confident but unsupported personalised conclusion.",
"metadata": {
"risk_domain": "financial_guidance",
"locale": "India",
"criteria": ["accuracy", "helpfulness", "safety"]
}
}Annotation guidelines should define what makes an answer better. Typical criteria include correctness, relevance, completeness, clarity, instruction adherence, uncertainty calibration, harmlessness, and cultural appropriateness. When criteria conflict, the rubric must state the priority order.
Human feedback operations
High-quality annotation requires:
- Written rubrics with positive and negative examples
- Training and calibration rounds
- Agreement measurement, such as pairwise agreement or Krippendorff’s alpha
- Escalation paths for ambiguous and high-risk cases
- Separation of annotator identity from model-training records
- Fair compensation and appropriate psychological support for harmful-content review
For medical, legal, financial, or public-service use cases, domain experts should review a sample or directly label high-risk examples. General annotators may judge fluency but miss subtle factual or regulatory errors.
Preference Models and Reward Modeling
Traditional RLHF trains a reward model on preference comparisons. Given a prompt and response, the reward model produces a scalar score. For a chosen response \(y^+\) and rejected response \(y^-\), a common pairwise objective is:
\[
\mathcal{L} = -\log \sigma(r(x,y^+) - r(x,y^-))
\]
where \(r\) is the reward model and \(\sigma\) is the logistic function. The model learns that preferred answers should receive higher scores.
Reward-model quality depends heavily on preference-data coverage. Common failure modes include:
- Rewarding verbosity instead of correctness
- Learning annotator or demographic bias
- Penalising legitimate uncertainty
- Overfitting to formatting patterns
- Missing long-context failures
- Producing reward-hacking incentives
Evaluate the reward model on held-out comparisons, subgroup slices, adversarial examples, and disagreement cases. A high validation accuracy on randomly split data can be misleading when near-duplicate prompts occur across splits.
Policy Optimization: PPO and Modern Alternatives
In classical RLHF, proximal policy optimization (PPO) updates the SFT model, treated as the initial policy, using reward-model scores. A reference model constrains the policy through a Kullback–Leibler penalty so that optimization does not move too far from the supervised behavior:
\[
R(x,y) = r(x,y) - \beta D_{KL}(\pi_{\theta} || \pi_{ref})
\]
PPO can be powerful but operationally demanding. It requires careful rollout generation, reward normalization, policy and value networks, KL monitoring, checkpoint management, and sensitivity analysis. Instability may appear as repetition, refusal inflation, reward hacking, or degradation on capabilities not represented in the reward data.
Many teams now use preference-optimization methods such as Direct Preference Optimization (DPO), IPO, ORPO, or related algorithms. These methods can optimize preference pairs without training a separate online RL loop. They are often simpler to reproduce and more economical for small teams, although they still depend on sound preference data and careful validation.
The choice should reflect the objective:
- Use SFT when reliable demonstrations are available and imitation is sufficient.
- Use DPO-like methods when preference pairs are strong and simpler optimization is valuable.
- Use PPO or online RL when exploration, dynamic rewards, or complex multi-step objectives justify the added infrastructure.
- Combine methods when a staged approach improves stability—for example, SFT followed by preference optimization and targeted safety tuning.
Evaluation: Measure More Than Loss
A production evaluation suite should combine automatic metrics, expert review, adversarial testing, and live monitoring. Useful categories include:
- Instruction adherence
- Factuality and citation accuracy
- Helpfulness and completeness
- Safety and policy compliance
- Refusal quality and appropriate uncertainty
- Robustness to prompt injection and jailbreaks
- Multilingual and code-mixed performance
- Fairness across names, regions, genders, and dialects
- Latency, throughput, and cost per request
Build a fixed regression set, a rotating challenge set, and hidden evaluation prompts. Slice results by language, domain, user intent, risk level, prompt length, and model temperature. For Indian deployments, test regional-language spelling variation, transliteration, public-scheme terminology, Indian date and number formats, and ambiguity around local institutions.
Human evaluation should use blinded comparisons where possible. Pairwise judgments are generally easier to calibrate than absolute scores, but they should be supplemented by factuality checklists and expert review for high-stakes tasks.
Safety, Privacy, and Governance
RLHF and SFT do not automatically make a model safe. Safety must be implemented across data, training, inference, and operations.
Recommended controls include:
- Remove personal data and secrets from training records
- Maintain consent and provenance documentation
- Apply access controls to raw annotations
- Version datasets, prompts, rubrics, checkpoints, and evaluation results
- Red-team harmful and culturally sensitive scenarios
- Add input and output policy filters where appropriate
- Log model version, policy version, and safety decisions
- Provide incident response and rollback procedures
Indian organisations should consider the Digital Personal Data Protection Act, 2023, contractual data-processing obligations, sectoral requirements, and cross-border data-transfer constraints. Legal review is necessary for the specific deployment context; technical de-identification alone is not a complete compliance strategy.
Infrastructure and MLOps Architecture
A reproducible pipeline typically includes an object store for immutable datasets, a metadata catalogue, a training orchestrator, experiment tracking, a model registry, and automated evaluation jobs. Every model artifact should be traceable to its base checkpoint, dataset version, code commit, hyperparameters, and evaluation report.
A practical stack may include:
- GPU training via Kubernetes, Slurm, or managed cloud infrastructure
- Distributed training with FSDP or DeepSpeed
- Dataset processing with Python, Spark, or Ray where scale requires it
- Experiment tracking through MLflow, Weights & Biases, or an internal system
- Evaluation harnesses with versioned prompts and deterministic seeds
- Model serving through vLLM, Text Generation Inference, or equivalent systems
- Monitoring for latency, token usage, refusals, user feedback, and safety incidents
Control cost by using parameter-efficient tuning, gradient checkpointing, efficient sequence packing, spot capacity where reliable, and smaller models for data iteration. Do not optimise infrastructure before validating the data and evaluation design; poor labels multiplied across expensive GPUs remain poor labels.
Common Failure Modes and Fixes
Overfitting to annotator style
If every preferred answer has the same tone or length, the model may imitate style rather than quality. Diversify annotators and explicitly score substance.
Reward hacking
The model may learn to sound safe, cite fabricated sources, or produce lengthy disclaimers. Add adversarial evaluations and reward factual utility, not surface signals.
Catastrophic capability regression
Narrow alignment data can damage coding, reasoning, or multilingual performance. Keep broad capability tests and mix representative data where appropriate.
Inconsistent chat formatting
Different templates during preprocessing, training, and inference cause severe quality loss. Treat the tokenizer and chat template as versioned production dependencies.
Data leakage
Duplicates between training and evaluation inflate results. Use semantic near-duplicate detection and source-level splitting.
Excessive refusal
Safety tuning can cause the model to reject benign requests. Evaluate refusal precision and teach safe, useful alternatives rather than blanket denial.
A Practical Implementation Roadmap
For an early-stage AI team, a staged plan reduces risk:
1. Define target users, risk boundaries, and measurable success criteria.
2. Profile candidate base models on representative Indian-language and domain tasks.
3. Create a small expert-reviewed SFT set and establish a regression suite.
4. Run parameter-efficient SFT and inspect failures manually.
5. Generate candidate responses and build calibrated preference data.
6. Compare DPO-style optimization with a stronger SFT baseline.
7. Add targeted safety and domain evaluations before scaling training.
8. Register the best checkpoint with full data and experiment lineage.
9. Deploy behind monitoring, rate limits, and rollback controls.
10. Feed verified production failures back into the next data cycle.
The most successful RLHF and SFT pipelines are measurement systems as much as training systems. They make it possible to identify whether a failure comes from data quality, model capacity, optimization, prompting, retrieval, or serving configuration.
FAQ: RLHF and SFT Pipelines
Is SFT required before RLHF?
Usually, yes. SFT gives the model a stable instruction-following starting point and makes preference optimization more efficient. Direct preference training from a raw base model is possible but generally harder to control.
Is RLHF better than SFT?
Neither is universally better. SFT is efficient for learning explicit demonstrations, while RLHF or preference optimization helps encode comparative qualities such as helpfulness, safety, and response prioritisation.
How much data is needed?
There is no fixed number. Hundreds of expert-quality examples can establish a narrow behavior, while broad multilingual products may require tens or hundreds of thousands of demonstrations and preference comparisons. Coverage and label quality matter more than raw volume.
Can startups avoid PPO?
Yes. DPO and related methods are often easier to implement and can work well with reliable preference pairs. PPO remains useful when online rewards or exploration justify its operational complexity.
What should Indian teams prioritise?
Prioritise native-language quality, code-mixed evaluation, data provenance, privacy, domain expertise, and realistic testing across Indian user contexts. English-only benchmarks are insufficient for many Indian deployments.
Apply for AI Grants India
Building an RLHF or SFT pipeline for an Indian AI product? Apply through AI Grants India to discover support and opportunities for your research or startup. Share your technical roadmap, target impact, and funding needs with the AI Grants India ecosystem.