home
diamond Go Premium
Data Engineering Path  ·  Data & AI

Hands-on Quiz: Fine-Tuning & RLHF

Test your practical skills in fine-tuning datasets, LoRA hyperparameter configuration, and loss evaluation.


Challenge 1: LoRA Parameter Calculator

Given an input layer dimension $d=4096$, output layer dimension $k=4096$, and rank $r=16$, calculate:

  1. The total trainable parameters in the LoRA adapter ($B \cdot A$).
  2. The percentage parameter reduction compared to full fine-tuning of this layer.
def calculate_lora_efficiency(d: int, k: int, r: int):
    # Your calculation here
    pass
View Solution
def calculate_lora_efficiency(d: int, k: int, r: int):
    full_params = d * k
    lora_params = (d * r) + (r * k)
    reduction_pct = (1.0 - (lora_params / full_params)) * 100.0
    return {
        "lora_params": lora_params,
        "full_params": full_params,
        "reduction_percentage": round(reduction_pct, 2)
    }

# Test:
res = calculate_lora_efficiency(4096, 4096, 16)
print(res)
# {'lora params': 131072, 'full params': 16777216, 'reduction percentage': 99.22}

Challenge 2: ChatML Message Validator

Write a Python function that verifies whether an individual conversation dictionary contains valid roles in chronological alternating order (system -> user -> assistant).

View Solution
def is_valid_chatml(conversation: list[dict]) -> bool:
    if not conversation:
        return False

    expected_next = ["system", "user"]
    for msg in conversation:
        role = msg.get("role")
        if role not in expected_next:
            return False
        if role == "system":
            expected_next = ["user"]
        elif role == "user":
            expected_next = ["assistant"]
        elif role == "assistant":
            expected_next = ["user"]

    # Conversation must end with assistant response
    return conversation[-1].get("role") == "assistant"
Find this content helpful? ☕ Buy me a coffee

Entity Details

Create New Item

help

Submit Technical Query

Have a question or run into an issue? Describe it below, upload an optional screenshot, and our engineering team will answer it!

image Attach image (optional)

Submit Feedback

build Free Developer Utility Free Tool
gavel

Privacy & Legal Disclaimer

1. Client-Side Browser Processing

All utility tools on DeepEngineerHub (including Image to PDF, Text Formatters, JSON Converters, and Encryptors) execute 100% locally within your client browser using WebAssembly and JavaScript. No uploaded images, text, or documents are transmitted, collected, or stored on remote servers.

2. Limitation of Liability ("As-Is" Provision)

Tools and services are provided free of charge for convenience and educational purposes "as-is" without warranties of any kind. DeepEngineerHub shall not be held liable for any data loss, formatting inconsistencies, or indirect damages resulting from tool usage.

3. Open Source & Third-Party Software

Certain utilities utilize open-source client libraries (such as jsPDF, Mermaid.js, Pyodide) licensed under MIT, Apache, or BSD open licenses. All intellectual property remains with their respective copyright holders.