home
diamond Go Premium
Data Engineering Path  ·  Data & AI

Hands-on Quiz: MLOps and LLMOps

Test your understanding of production deployment, streaming protocols, and semantic caching.


Challenge 1: Server-Sent Events Formatter

Write a Python generator function that formats raw string chunks into the standard Server-Sent Events (SSE) protocol specification with data: prefix and double newline terminator.

def format_sse_stream(token_generator):
    # Your implementation here
    pass
View Solution
import json

def format_sse_stream(token_generator):
    for token in token_generator:
        payload = json.dumps({"token": token})
        yield f"data: {payload}

"
    yield "data: [DONE]

"

Challenge 2: Cosine Similarity Matcher for Semantic Cache

Given a target embedding vector $A$ and a candidate cached vector $B$, write the cosine similarity formula using NumPy and return True if similarity is $\ge 0.95$.

View Solution
import numpy as np

def is_semantic_cache_hit(vec_a: list[float], vec_b: list[float], threshold: float = 0.95) -> bool:
    a = np.array(vec_a)
    b = np.array(vec_b)
    cosine_sim = np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))
    return float(cosine_sim) >= threshold
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.