Command Palette

Search for a command to run...

Hectal
Phase 10: Security and Privacy (Defensive)
RAG and Vector Search · Exercise 6 of 6 Previous
Advanced

Quarantine passages that give orders

Write split_hits(hits, phrases). hits is a list of (doc_id, text) pairs and phrases a list of lower-case phrases. A hit is suspicious when any phrase appears in its lower-cased text.

Return a pair (clean_ids, quarantined_ids): two lists of ids, each in the original order. Then write output_ok(answer, sent_ids) that returns True only when the answer contains a citation like [D2] for at least one id in sent_ids.

What Check tests

  1. Separates the planted passage
  2. Keeps the original order in both lists
  3. Nothing suspicious means nothing quarantined
  4. A cited answer passes the output check
  5. A bare answer is blocked
  6. A citation to a source that was not sent is blocked

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

main.py
Sign in to run your code.

Output

Press Run to see what your program prints.