Update quread/llm_explain.py
Browse files- quread/llm_explain.py +13 -25
quread/llm_explain.py
CHANGED
|
@@ -38,41 +38,29 @@ def _build_grounded_prompt(
|
|
| 38 |
top_lines = [f"- {b}: {p:.4f}" for b, p in probs_top]
|
| 39 |
|
| 40 |
return f"""
|
| 41 |
-
You are a quantum
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
## Gate-by-gate explanation
|
| 46 |
-
Explain what each operation did in plain English.
|
| 47 |
-
|
| 48 |
-
## What the results mean
|
| 49 |
-
Explain superposition vs entanglement based on the probabilities shown.
|
| 50 |
-
|
| 51 |
-
## Compare to a Bell state
|
| 52 |
-
Say whether this matches any Bell state (|Φ+>, |Φ->, |Ψ+>, |Ψ->). If it matches, name it.
|
| 53 |
-
If it differs, explain exactly how it differs.
|
| 54 |
-
|
| 55 |
-
## How this looks on real hardware
|
| 56 |
-
Explain what would change on a real device: shot noise, readout error, decoherence, and why 00/11 might appear slightly.
|
| 57 |
-
|
| 58 |
-
## Debugging tips (2)
|
| 59 |
-
Give 2 concrete tips (endianness, control/target, measurement mapping).
|
| 60 |
-
|
| 61 |
-
DATA (do not go beyond this):
|
| 62 |
Qubits: {n_qubits}
|
| 63 |
-
|
| 64 |
-
Circuit operations:
|
| 65 |
{chr(10).join(ops_lines)}
|
| 66 |
|
| 67 |
-
|
| 68 |
{state_ket}
|
| 69 |
|
| 70 |
-
Top
|
| 71 |
{chr(10).join(top_lines)}
|
| 72 |
|
| 73 |
Shots: {shots if shots is not None else "N/A"}
|
| 74 |
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
""".strip()
|
| 77 |
|
| 78 |
|
|
|
|
| 38 |
top_lines = [f"- {b}: {p:.4f}" for b, p in probs_top]
|
| 39 |
|
| 40 |
return f"""
|
| 41 |
+
You are a quantum tutor. Use ONLY the DATA section.
|
| 42 |
+
Do NOT repeat instructions or the DATA. Do NOT restate the question.
|
| 43 |
+
Write ONLY the ANSWER section.
|
| 44 |
|
| 45 |
+
### DATA
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
Qubits: {n_qubits}
|
| 47 |
+
Ops:
|
|
|
|
| 48 |
{chr(10).join(ops_lines)}
|
| 49 |
|
| 50 |
+
State:
|
| 51 |
{state_ket}
|
| 52 |
|
| 53 |
+
Top probs:
|
| 54 |
{chr(10).join(top_lines)}
|
| 55 |
|
| 56 |
Shots: {shots if shots is not None else "N/A"}
|
| 57 |
|
| 58 |
+
### ANSWER
|
| 59 |
+
A) Gate-by-gate:
|
| 60 |
+
B) Meaning (superposition/entanglement):
|
| 61 |
+
C) Bell-state comparison (Φ±, Ψ±):
|
| 62 |
+
D) Real hardware (noise + why forbidden states may appear):
|
| 63 |
+
E) Debug tips (2):
|
| 64 |
""".strip()
|
| 65 |
|
| 66 |
|