पाठ 33 / 33
Mixed Self-Check
यह पाठ अभी हिंदी में अनुवादित नहीं है, इसलिए अंग्रेज़ी में दिखाया जा रहा है।
Test yourself across tokenization, models, generation, fine-tuning and production before an exam or interview.
लेखक: Rahul Agarwal · 15 साल से वेब डेवलपर
Answer these without looking back
Try each question aloud, then check the section in brackets. (1) A tokenizer gives [CLS] play ##ing [SEP]; which algorithm family and which model family does this suggest? (Tokenizers.) (2) Why must attention_mask accompany padded batches? (Tokenizers.) (3) What warning tells you a classification head was randomly initialised, and when is it expected? (Models.) (4) Why slice out[0, prompt_len:] before decoding? (Generation.) (5) When would you choose beam search over sampling? (Generation.) (6) What does batched=True change in Dataset.map? (Datasets.) (7) Where does Trainer get the loss? (Fine-tuning.) (8) Why is accuracy misleading on imbalanced classes? (Metrics.) (9) How many bytes per parameter for bfloat16 and for 4-bit weights? (Quantization.) (10) Name two reasons to prefer safetensors and a pinned revision. (Security.) If any answer felt shaky, rerun that section's code and quiz before moving on.
A last end-to-end exercise
Fill in the blanks from memory, then compare with the earlier sections.
from transformers import pipeline
# 1. Pick a task and a model from the Hub (pin a revision in real projects)
gen = pipeline("text-generation", model="Qwen/Qwen2.5-0.5B-Instruct")
# 2. Format the conversation as messages, not raw strings
messages = [{"role": "user", "content": "Summarise LoRA in one sentence."}]
# 3. Control length and randomness explicitly
reply = gen(messages, max_new_tokens=60, do_sample=True, temperature=0.7)
# 4. Read the last message: the assistant's reply
print(reply[0]["generated_text"][-1]["content"])Spaced revision works
Come back to this self-check after one day, then after a week. Questions you can answer instantly the third time are truly learned; the rest point to the sections worth a second read.
त्वरित जाँच: You must run a 7B chat model on one 16 GB GPU and adapt it to your college's FAQ data. Which plan is most realistic?
- Load it in 4-bit and train LoRA adapters (QLoRA), then evaluate on held-out FAQs
- Full fine-tuning in float32
- Train a 7B model from scratch on the FAQ data
- Use zero-shot classification on the FAQ answers
Answer
Load it in 4-bit and train LoRA adapters (QLoRA), then evaluate on held-out FAQs — 4-bit weights for a 7B model take a few GB, leaving room for LoRA training. Full float32 fine-tuning needs many times more memory.