Local LLM Evaluation Framework for Clinical Conversational Move Classification

Project Overview and Architectural Objectives

  • Primary Goal: Development and evaluation of automated classifiers for complex, nuanced qualitative data derived from clinical discourse, specifically targeting clinician conversational moves that cannot be classified by simple noun matching (such as traditional Quantitative Ethnography / QE codes).

  • Core Challenge:

    • Existing classification relies on dense, intricate regular expressions characterized by long relational patterns across words, spacing, and syntactic structures.

    • Research aims to evaluate whether local Large Language Models (LLMs) can match or exceed the performance of hand-crafted regular expressions.

  • Long-Term vs. Short-Term Scope:

    • The current scope is contained strictly within this specific healthcare discourse project.

    • Insights gained regarding small model affordances, limitations, and prompt distillation will inform future implementations in contexts where cloud-based commercial models cannot be deployed.

Data Governance, Healthcare Privacy, and Computing Infrastructure

  • Data Sensitivity and Compliance Constraints:

    • The underlying qualitative corpus comprises protected healthcare data subject to strict privacy requirements.

    • Data cannot be transmitted to external, third-party commercial APIs (e.g., public or non-enterprise versions of Gemini or Claude).

    • Eventual institutional deployment requires full HIPAA certification to run within University of Wisconsin (UW) enterprise systems.

  • Permissible Computing Environments:

    • Local machines capable of executing models completely offline without external network communication.

    • Dedicated institutional server infrastructure, such as the Center for High Throughput Computing or other UW-controlled spaces where self-hosted models operate in total isolation.

    • Peer-to-peer data transfers via direct email between authorized team members are permitted for local setup, but uploading to unsecured, non-protected public servers is strictly prohibited.

Classification Scheme: Regular Expressions and Code Aggregation

  • Ground Truth Benchmark:

    • The current iterations of the regular expression classifiers serve as the ground truth benchmark for evaluating LLM classification accuracy.

    • Regular expressions remain in a continuous state of revision but are sufficiently stabilized for comparative experimentation.

  • Code Hierarchy and Element Condensation:

    • Granular Level: The regular expression classifiers currently code for approximately 1212 distinct codes.

    • Condensed Level: The 1212 granular codes aggregate completely into 77 overarching core elements.

    • Structural Mapping:

    • There are no standalone parent codes in the regular expression architecture; only child codes exist (e.g., labeled systematically as Code 3a, Code 3b, etc.).

    • The child codes map exhaustively and deterministically to the core elements—they represent the exact sum of their constituent parts with no missing or unmapped children.

Experimental Comparison Framework: Four Input Paradigms

To rigorously identify what distinct types of information contribute to model success or failure, the experiment isolates four distinct training/context conditions. These conditions must be evaluated independently without cross-contamination or information leakage:

  • Condition 1: Theoretical Literature (Articles & Theory):

    • Input: Scientific articles and theoretical documentation detailing the specific clinical protocol, its conceptual framework, and its conversational rationale.

    • Expectation: Serves as a baseline benchmark; anticipated to perform poorly in practice, but intended to reveal qualitative edge cases and surprising competencies where high-level theory alone succeeds.

  • Condition 2: Traditional Code Book:

    • Input: Formal qualitative code books containing explicit code names, operational definitions, and walk-through examples.

    • Data Privacy Precaution: Real patient data examples in the code book must be manually sanitized and rewritten in researcher language before any ingestion to ensure no raw clinical discourse is leaked.

  • Condition 3: Reverse-Engineering Existing Classifiers:

    • Input: The raw regular expressions currently used for classification.

    • Objective: Determine whether an LLM can derive underlying semantic logic and improve classification boundaries directly from algorithmic syntax.

  • Condition 4: Sample of Coded Qualitative Lines:

    • Input: Exemplar datasets comprising 2525 to 5050 positively coded lines for each target concept.

    • Quality Assurance: Samples drawn from regular expression output must be hand-checked and validated by human researchers to eliminate false positives prior to training.

Small Model Constraints and Large-to-Small Distillation Strategy

  • Rationale for Small/Local Models:

    • Operational Necessity: High-security environments—such as clinical settings, hospitals, and public schools—forbid the use of external proprietary APIs.

    • Resource and Cost Optimization: Identifying the performance ratio between large commercial models and local small models. If a small model achieves 97%97\% of the performance of a large model, the resource, operational, and financial cost-benefit analysis favors local deployment.

  • Context Window Degradation:

    • Empirical observation reveals that providing smaller models with too much uncurated information simultaneously overloads their limited context windows, degrading overall performance.

    • Modular experimentation isolates which specific input types provide actionable leverage.

  • Distillation Architecture via Markdown Generation:

    • Upstream Processing: A larger, high-capability model (e.g., Claude Opus) can ingest sanitized theory, modified code books, and regular expressions.

    • Context Distillation: The large model synthesizes these disparate documents into structured, optimized Markdown files.

    • Downstream Execution: The local, smaller model utilizes these synthesized Markdown files as an authoritative "word of god" prompt, achieving focused accuracy within constrained context parameters.

  • Future Architectures:

    • Subsequent experimental phases may test multi-agentic consensus, where models trained on distinct isolated conditions interact and communicate to establish a final code.

Evaluation Metrics, Consistency Distributions, and Disagreement Analysis

  • Comparative Disagreement Analysis:

    • Full corpus coding will be executed independently across the models and compared directly against regular expression outputs.

    • Summary statistics will be computed to identify systematic classification biases or failure modes (e.g., models consistently undercoding specific conversational moves, failing to identify surgical discourse, or systematically misclassifying discourse unique to specialties like podiatry).

    • Researchers will conduct qualitative, manual hand-checks on all discrepant lines to unpack the root causes of misalignment.

  • Classification Consistency and Probabilistic Distributions:

    • Deterministic binary outputs (11 or 00) over a single pass fail to measure classification confidence and model stability.

    • Each model will execute classifications over each line of data across a distribution of at least 100100 iterations (with capacity to scale to 10,00010,000 iterations).

    • Consistency Metrics:

    • Output is evaluated as a probabilistic value between 0.00.0 and 1.01.0.

    • A value of 0.90.9 reflects that the line was classified as positive in 99 out of 1010 iterations.

    • Values of exactly 1.01.0 or 0.00.0 indicate absolute (100%100\%) consistency.

    • Values hovering around 0.50.5 indicate high instability and low model confidence for that conversational line.

    • Optional confidence intervals can be computed to mathematically formalize stability.

Questions & Discussion

  • Project Architecture Clarification:

    • Question/Clarification: Request for a high-level summary recap of the project architecture to conceptualize how the dataset, classifiers, benchmarks, and local hosting fit together.

    • Response: The qualitative dataset contains clinical interactions coded across roughly 1212 granular dimensions (condensable to 77 elements). Rather than creating classifiers from scratch, well-established regular expressions exist as the ground truth benchmark. The primary research question is whether locally hosted LLMs can perform as well as or better than these benchmark regular expressions, serving this specific clinical project now while generating empirical baseline knowledge for future projects.

  • Experimental Structuring and Information Uploads:

    • Question/Proposal: Proposal to segment the experiment into discrete parts, sketch them out on a board, and test whether components can be attached directly into a cloud-based Claude chat.

    • Response: The theoretical literature, the sanitized code book, and regular expressions can be ingested by Claude once examples are scrubbed of raw patient discourse. The sample of coded qualitative lines must never be uploaded to an external cloud platform because it consists of real healthcare data.

  • Intermediate Distillation via Markdown:

    • Question/Proposal: Suggestion to feed the theoretical literature, sanitized code book, and regular expressions into Claude to generate structured Markdown files, which a local model then treats as authoritative instruction.

    • Response: Approved as an eventual distillation approach, but intentionally deferred. The research objective requires testing each input paradigm in complete isolation first to learn the distinct strengths, weaknesses, and affordances of each information source before compounding them into an integrated prompt file.

  • Execution Steps and Disagreement Review:

    • Question/Clarification: Clarification regarding the immediate next steps once prompt artifacts are generated, including review structures between team members.

    • Response: Select one experimental condition, code the entire dataset, compare outputs directly against the regular expression baseline, review descriptive summary statistics for patterns in errors, and perform qualitative hand-checks on line-by-line disagreements.

  • Local Hardware Specifications and Simulation Pipeline:

    • Question/Proposal: Proposal to leverage a high-end local PC ($2,000\$2,000 custom build) to host and simulate the four isolated models locally rather than relying on external hosted APIs.

    • Response: The plan to run the experiments entirely on the local $2,000\$2,000 PC is fully accepted, as local execution aligns with data security boundaries and allows arbitrary iteration scaling (100100 to 10,00010,000 iterations) without external API costs or data leakage.