Skip to content

CI/CD Pipeline Example

Monitor cognitive coherence as part of your model training pipeline.

GitHub Actions

# .github/workflows/loc-check.yml
name: LOC Cognitive Check
on:
  push:
    paths: ['models/**', 'training/**']

jobs:
  loc-audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'
      - run: pip install aime-loc

      - name: Run Training Audit
        env:
          AIME_API_KEY: ${{ secrets.AIME_API_KEY }}
        run: |
          python -c "
          from aime_loc import LOC
          loc = LOC()
          audit = loc.training_audit(
              base='${{ vars.BASE_MODEL }}',
              trained='${{ vars.TRAINED_MODEL }}',
              method='${{ vars.TRAINING_METHOD }}',
          )
          print(f'TC Delta: {audit.comparison.overall_delta:+.2f}pp')

          # Fail if TC drops by more than 2pp
          if audit.comparison.overall_delta < -2.0:
              print('FAIL: Training degraded cognitive coherence significantly')
              exit(1)
          print('PASS: Cognitive coherence preserved')
          "

Python Script

#!/usr/bin/env python3
"""Post-training cognitive coherence check."""

import sys
from aime_loc import LOC

def check_training(base: str, trained: str, method: str, threshold: float = -2.0):
    loc = LOC()
    audit = loc.training_audit(base=base, trained=trained, method=method)

    print(f"Base:    {audit.base_profile.tc_score:.2f}%")
    print(f"Trained: {audit.trained_profile.tc_score:.2f}%")
    print(f"Delta:   {audit.comparison.overall_delta:+.2f}pp")

    audit.save_report("training_audit.md")

    if audit.comparison.overall_delta < threshold:
        print(f"FAIL: TC dropped below threshold ({threshold}pp)")
        sys.exit(1)

    print("PASS")

if __name__ == "__main__":
    check_training(sys.argv[1], sys.argv[2], sys.argv[3])