Add LLM logging and prompt experiment harness

This commit is contained in:
Adolfo Reyna
2026-03-17 11:13:22 -04:00
parent 727b7701c1
commit 7da02a9697
6 changed files with 678 additions and 45 deletions
+18
View File
@@ -279,3 +279,21 @@ The project now features a high-performance, Apple Silicon-optimized pipeline th
- Removed the explicit Chat Completions temperature override after discovering current GPT-5-family models reject non-default temperature values on this endpoint.
- Aligned the Ollama path with the OpenAI path by forwarding the same system instructions to local generation requests, including warmup calls.
- **Outcome:** GPT-backed runs now fail with useful diagnostics, OpenAI requests are compatible with current GPT-5-mini behavior, and local-vs-remote prompting is more consistent.
## Phase 32: LLM Request Logging + Prompt Replay Harness
- **Goal:** Make prompt behavior observable and reproducible so local LLM tuning can happen without rerunning live transcription.
- **Approach:**
- Added JSONL request logging for every LLM call, including full message payloads, timing, and the final response or error outcome.
- Added prompt-only test entry points in `main_v2.py` so line-correction and paragraph-refinement prompts can be sent directly without starting the transcription pipeline.
- Added replay-from-log support so a captured request can be resent with the current model or the originally logged model.
- Documented the new logging and replay workflow in `README.md` and added a default log path in `config.json`.
- **Outcome:** We can now inspect exactly what the app sends to the LLM, replay real requests on demand, and compare prompt changes against stored payloads and outputs.
## Phase 33: Grounded Paragraph Prompt Experiments
- **Goal:** Reduce paragraph drift and self-reinforcing hallucinations in the rolling LLM refiner.
- **Approach:**
- Built `prompt_experiments.py` to reconstruct representative paragraph-refinement samples from `distribute_debug.log` and send multiple prompt variants directly to Ollama.
- Compared several context arrangements, including the previous refined paragraph alone, raw-only windows, and mixed refined-plus-raw grounding strategies.
- Identified the best-performing variant as one that treats the new source window as primary evidence while using prior refined and prior raw text only when they clearly continue the thought.
- Updated `engine_llm.py` so live paragraph refinement now sends `PREVIOUS REFINED CONTEXT`, `PREVIOUS SOURCE TEXT`, and `NEW SOURCE TEXT` with a more conservative, grounding-oriented system prompt.
- **Outcome:** Paragraph refinement is now substantially better anchored to current source text, with less stale-context carryover and a much lower rate of unsupported content in direct Ollama tests.