NotesB.Sc IT (AI)NLP & Large Language Models
Year 2 · Semester 2

NLP & Large Language Models Notes

Program:B.Sc IT (AI)
Semester:Semester 4
Hours:15
Units:8 Units

Subject Overview

How language models work, how to use them, and how to fine-tune them for specific tasks. Six modules trace the road from classical NLP and sequence models through the transformer architecture to working with frontier and open models — prompt engineering, structured outputs and function calling — closing with adaptation techniques and the evaluation and safety practices that responsible deployment requires.

Unit-wise Syllabus

8 units — click WhatsApp below to get the full notes for each

1

Unit 1: Classical NLP (2 hours)

  • Tokenization
  • stemming
  • TF-IDF
  • word2vec
  • GloVe
  • why embeddings changed everything
ProcessClassical NLP pipeline
  1. 1Raw text
  2. 2Tokenise

    Split into words or subwords

  3. 3Normalise

    Lowercase, stem or lemmatise

  4. 4Vectorise

    TF-IDF or word embeddings

  5. 5Model

    Classifier or similarity

Study guide

This module starts with classical NLP: tokenisation, stemming, TF-IDF, word2vec and GloVe and why embeddings changed everything. Understand embeddings as meaning represented by position in space.

2

Unit 2: Sequence Models (3 hours)

  • RNNs
  • LSTMs
  • the attention mechanism
  • the road from seq2seq to transformers
ProcessFrom RNNs to transformers
  1. 1RNN

    Reads one token at a time

  2. 2LSTM

    Gates help remember longer context

  3. 3Seq2seq

    Encoder-decoder for translation

  4. 4Attention

    Decoder looks back at all inputs

  5. 5Transformer

    Attention only, fully parallel

Study guide

You study sequence models: RNNs, LSTMs, the attention mechanism and the road from seq2seq to transformers. Attention is the idea to master; it explains the next unit.

3

Unit 3: Transformers Deep Dive (3 hours)

  • Self-attention
  • multi-head attention
  • positional encoding
  • reading the 'Attention is All You Need' paper
Key formulasInside the transformer
  • Scaled dot-product attention

    softmax(Q Kᵀ / √dk) V

  • Q, K, V

    Query, key and value projections of each token

  • Multi-head attention

    Several attention heads in parallel, concatenated

  • Positional encoding

    Adds word-order information

Study guide

The transformers deep dive covers self-attention, multi-head attention, positional encoding and reading the 'Attention Is All You Need' paper. Read the paper alongside a code walkthrough.

4

Unit 4: Working with LLMs (4 hours)

  • GPT
  • Claude
  • Llama and Mistral families
  • API usage
  • prompt engineering
  • structured outputs
  • function calling
ClassificationGetting reliable output from LLMs
Working with LLMs
  • Prompt engineering

    Clear role, context, examples

  • Structured outputs

    JSON that matches a schema

  • Function calling

    Model asks your code to run a tool

  • Model choice

    Claude, GPT, Llama, Mistral: cost vs quality

Study guide

You work with LLMs: the GPT, Claude, Llama and Mistral families, API usage, prompt engineering, structured outputs and function calling. Practise writing prompts and measuring the difference they make.

5

Unit 5: Fine-tuning & Adaptation (4 hours)

  • Full fine-tuning
  • LoRA
  • QLoRA
  • instruction tuning
  • when to fine-tune versus prompt versus RAG
ComparisonPrompting vs RAG vs fine-tuning
Use when
Cost

Prompting

Task fits in instructions and examples

Lowest

RAG

Model needs your up-to-date documents

Medium

LoRA / QLoRA fine-tuning

Need a specific style, format or skill

Higher, but far below full fine-tuning

Full fine-tuning

Large data and deep changes

Highest

Study guide

You study fine-tuning and adaptation: full fine-tuning, LoRA, QLoRA, instruction tuning and when to fine-tune versus prompt versus use RAG. Start with prompting, add RAG for knowledge and fine-tune only when necessary.

6

Unit 6: Evaluation & Safety (4 hours)

  • Benchmarks
  • hallucinations
  • prompt injection
  • content safety
  • bias detection
ClassificationLLM risks to evaluate
Evaluation and safety
  • Hallucination

    Confident but false answers

  • Prompt injection

    Malicious instructions hidden in input

  • Bias

    Unfair outputs for some groups

  • Content safety

    Harmful or toxic text

  • Benchmarks

    Measure quality consistently

Study guide

You study evaluation and safety: benchmarks, hallucinations, prompt injection, content safety and bias detection. Always test models on adversarial inputs, not only friendly ones.

7

Unit 7: Tools introduced

  • Hugging Face transformers
  • PEFT and TRL
  • OpenAI / Anthropic / open-source model APIs (Together, Groq, Replicate)
  • Ollama for running local models
  • LangSmith / Langfuse for LLM observability
ClassificationLLM toolkit
Tools
  • Transformers, PEFT, TRL

    Load, adapt and train models

  • Model APIs

    Anthropic, OpenAI, open-source hosts

  • Ollama

    Run models locally

  • LangSmith / Langfuse

    Trace and observe LLM apps

Study guide

The tools include Hugging Face transformers, PEFT and TRL, model APIs from OpenAI, Anthropic and open-source providers, Ollama for local models and LangSmith or Langfuse for observability. Run a small open model locally to understand cost and latency.

8

Unit 8: Mini-projects

  • Build a sentiment classifier using a fine-tuned BERT
  • fine-tune a 7B open-source model on a domain-specific dataset with LoRA
  • build a chatbot with structured outputs and tool use
ProcessFine-tuning a 7B model with LoRA
  1. 1Prepare an instruction dataset
  2. 2Load the base model in 4-bit

    QLoRA

  3. 3Attach LoRA adapters

    Train only small matrices

  4. 4Train and evaluate
  5. 5Merge or serve the adapter

Study guide

The mini-projects are a fine-tuned BERT sentiment classifier, a 7B open-source model fine-tuned on a domain dataset with LoRA and a chatbot with structured outputs and tool use. A fine-tuned domain model is a distinctive portfolio item.

Why NLP & Large Language Models Matters

Language models are the most visible and fast-moving area of AI. Understanding transformers, prompting, fine-tuning and evaluation prepares you for roles such as LLM engineer, AI application developer and applied scientist.

How to Prepare for NLP & Large Language Models

  • Implement a small transformer block to understand attention.
  • Evaluate every LLM feature with a test set, not just impressions.
  • Follow current model releases but build on fundamentals.

NLP & Large Language Models: Frequently Asked Questions

What is LoRA?

LoRA is a parameter-efficient fine-tuning method that trains small added matrices instead of all model weights, greatly reducing memory and cost.

What is a hallucination in an LLM?

A hallucination is a confident but incorrect or invented output produced by a language model.

Want the Complete Notes & Past Papers?

WhatsApp us and we'll send you the full notes, question banks, and previous year papers for NLP & Large Language Models.