Sunday, October 05, 2025

Choosing model - closed source or open source

 




How to choose an Model?

 


LLM Pre-training

Definition of Pre-training

Pre-training is the process of training a model on vast, diverse, and largely unlabeled data to learn general representations and patterns of a domain — such as language, vision, audio, or sensor data — before it is specialized for specific tasks.

It is a self-supervised learning stage where the model develops an internal “world model” by predicting or reconstructing parts of its input (e.g., the next token, masked pixel, next audio frame, or next action).
The goal is not to perform a narrow task, but to build a foundation of understanding that later fine-tuning, prompting, or reinforcement can adapt to many downstream objectives.


🧠 Core Idea

Pre-training = learning how the world looks, sounds, or reads
before learning how to do something with that knowledge.

General Formulation

AspectDescription
InputLarge, diverse, unlabeled data (text, images, audio, code, trajectories, etc.)
ObjectivePredict missing or future parts of data (self-supervised task)
OutcomeDense, structured representations (embeddings) capturing meaning and relationships
PurposeBuild transferable understanding to accelerate later adaptation

Why It Matters

Pre-training converts raw data → reusable intelligence.
Once the base model is pretrained, it can be:

  • Fine-tuned for specialized tasks,

  • Aligned for human intent (via RLHF),

  • Connected to live knowledge (via RAG).

It’s the difference between:

teaching a brain how to think and perceive,
versus teaching it what to think or do.


When You Should Pre-train

You should pre-train from scratch only when:

  • You need a new base model (new architecture, tokenizer, or modality);

  • Existing models don’t cover your language or data type (e.g., low-resource languages, medical imaging, genomic data);

  • You want full control over knowledge, bias, and compliance;

  • You’re performing foundational research into architectures or training dynamics.

Otherwise — reuse and fine-tune an existing pre-trained foundation. 

 









What is the need for LLM Finetuning?

 Reason number 1



You might not want the above result, rather something like below would help you


Reason number 2 for LLM fine tuning



Reason number for LLM Fine Tuning








Another reason to fine tune








LLM Fine-tuning

Next Layer: Fine-Tuning

Where RAG retrieves knowledge dynamically, fine-tuning actually modifies the model’s brain — it teaches the LLM new patterns or behaviors by updating its internal weights.


⚙️ How Fine-Tuning Works

  1. Start with a pretrained model (e.g., GPT-3.5, Llama-3, Mistral).

  2. Prepare training data — examples of how you want the model to behave:

    • Inputs → desired outputs

    • e.g., “User story → corresponding UAT test case”

  3. Train the model on these examples (using supervised learning or reinforcement learning).

  4. The model’s weights are adjusted, internalizing the new style, tone, or domain language.

After fine-tuning, the model natively performs the desired task without needing the examples fed each time.


⚖️ RAG vs Fine-Tuning: Clear Comparison

AspectRAG (Retrieval-Augmented Generation)Fine-Tuning
MechanismAdds external info at runtimeAlters model weights via training
When UsedWhen data changes often or is largeWhen you need consistent behavior or reasoning style
Data TypeDocuments, databases, APIsLabeled prompt–response pairs
CostLow (no retraining)High (GPU time, expertise, re-training)
FreshnessInstantly updatableRequires re-training to update
ControlYou control retrieved sourcesYou control reasoning patterns
Example UseAsk questions about new policiesTeach model to write test cases in your company’s format
AnalogyReading from a manual before answeringRewriting the brain to remember the manual forever

🧩 Combining Both: RAG + Fine-Tuning = Domain-Native AI

The real power comes when both are used together:

LayerRole
Fine-TuningTeaches the model how to think — e.g., how to structure a UAT test case, how to handle defects, your tone/style.
RAGGives it the latest knowledge — e.g., current epics, Jira stories, or Salesforce objects from your live data.

So the LLM becomes:

A fine-tuned specialist with a live retrieval memory.


🧬 Example: In Your AGL Salesforce / UAT Context

StepExample
Fine-tuningYou fine-tune the LLM on 1,000 existing UAT test cases and business rules. Now it understands your structure and tone.
RAG layerYou connect it to Jira and Confluence via embeddings, so when you ask, “Generate UAT test cases for Drop-3 Call Centre Epics,” it retrieves the latest epics and acceptance criteria.
ResultYou get context-aware, properly formatted, accurate UAT cases consistent with AGL’s standards.

That’s enterprise-grade augmentation — the model both knows how to think like your testers and knows what’s new from your systems.


🧠 Summary Table

CapabilityBase LLM+ RAG+ Fine-Tuning+ Both
General reasoning
Access to private or new data⚠ (only if baked in)
Domain vocabulary & formats
Updatable knowledge
Low hallucination✅✅
Cost to buildLowMedium–HighMedium

🚀 The Strategic Rule of Thumb

If your problem is...Then use...
“Model doesn’t know the latest information.”RAG
“Model doesn’t behave or write like us.”Fine-Tuning
“Model doesn’t know and doesn’t behave correctly.”Both

That’s the progressive architecture:

  • RAG extends knowledge.

  • Fine-tuning embeds behavior.

  • Together, they form the foundation for enterprise-grade AI systems.

If we already have automation, what's the need for Agents?

“Automation” and “agent” sound similar — but they solve very different classes of problems. Automation = Fixed Instruction → Fixed Outcome ...