Back to Documentation

AI & Machine Learning

Documentation for AI agents, models, and ML pipelines in the Peregrine platform

AI Agent Framework

Understanding AI Agents

Peregrine's AI agents are specialized assistants that automate healthcare workflows using natural language understanding and domain-specific knowledge.

Pre-built Agents

  • • Clinical Documentation Assistant
  • • Prior Authorization Processor
  • • Patient Risk Stratification
  • • Medication Reconciliation
  • • Care Gap Identifier

Agent Capabilities

  • • Natural language processing
  • • Multi-step reasoning
  • • Tool integration
  • • Memory persistence
  • • Async task execution

Creating Custom Agents

Build custom agents tailored to your organization's specific workflows.

const customAgent = new PeregrineAgent({
  name: 'Specialty Referral Coordinator',
  description: 'Manages specialty referrals and appointments',
  model: 'gpt-4-healthcare',
  
  tools: [
    'ehrLookup',
    'appointmentScheduler',
    'insuranceVerifier',
    'providerDirectory'
  ],
  
  systemPrompt: `You are a healthcare coordinator specializing in 
    managing specialty referrals. Your goal is to ensure patients 
    receive timely care while navigating insurance requirements.`,
    
  temperature: 0.3,
  maxTokens: 2000
});

// Deploy the agent
await customAgent.deploy({
  environment: 'production',
  scaling: {
    minInstances: 2,
    maxInstances: 10,
    targetConcurrency: 5
  }
});

Model Configuration

Available Models

ModelUse CaseContext WindowSpeed
gpt-4-healthcareComplex clinical reasoning128K tokensMedium
claude-medicalDocument analysis200K tokensFast
llama-clinicalReal-time assistance32K tokensVery Fast
biogpt-specializedBiomedical NLP8K tokensFast

Fine-tuning Models

Customize models with your organization's data for improved accuracy.

Fine-tuning Process

  1. 1
    Prepare Training Data

    Format your healthcare data according to our schema

  2. 2
    Configure Training Parameters

    Set learning rate, epochs, and validation split

  3. 3
    Monitor Training Progress

    Track loss metrics and validation performance

  4. 4
    Deploy Fine-tuned Model

    Test and deploy your custom model

Training Pipelines

Automated ML Pipelines

Set up automated pipelines for continuous model improvement.

# pipeline.yaml
name: clinical-nlp-pipeline
schedule: "0 2 * * *"  # Daily at 2 AM

stages:
  - name: data-collection
    source: 
      - ehr-database
      - clinical-notes
    filters:
      - deidentify
      - validate-format
      
  - name: preprocessing
    steps:
      - tokenization
      - medical-entity-recognition
      - feature-extraction
      
  - name: training
    model: bert-clinical
    parameters:
      batch_size: 32
      learning_rate: 0.0001
      epochs: 10
      
  - name: evaluation
    metrics:
      - accuracy
      - f1-score
      - auc-roc
    threshold: 0.85
    
  - name: deployment
    strategy: blue-green
    rollback_on_failure: true

Natural Language Processing

Medical NLP Capabilities

Clinical Entity Recognition

  • • Diagnosis codes (ICD-10)
  • • Procedure codes (CPT)
  • • Medication names and dosages
  • • Lab values and ranges
  • • Anatomical references

Advanced Features

  • • Temporal reasoning
  • • Negation detection
  • • Uncertainty quantification
  • • Relation extraction
  • • Clinical summarization

Example: Clinical Note Processing

const nlpProcessor = new ClinicalNLP();

const clinicalNote = `
Patient presents with acute chest pain, radiating to left arm.
No history of cardiac disease. BP 140/90, HR 95.
Started on aspirin 81mg daily and referred to cardiology.
`;

const analysis = await nlpProcessor.analyze(clinicalNote);

console.log(analysis);
// Output:
{
  "entities": {
    "symptoms": ["acute chest pain", "radiating to left arm"],
    "vitals": [
      { "type": "blood_pressure", "value": "140/90", "unit": "mmHg" },
      { "type": "heart_rate", "value": "95", "unit": "bpm" }
    ],
    "medications": [
      { "name": "aspirin", "dose": "81", "unit": "mg", "frequency": "daily" }
    ],
    "referrals": ["cardiology"]
  },
  "sentiment": "concerning",
  "urgency": "high"
}

AI/ML Best Practices

Development

  • • Always validate model outputs
  • • Implement human-in-the-loop for critical decisions
  • • Monitor for bias and fairness
  • • Version control your models

Production

  • • Set up continuous monitoring
  • • Implement gradual rollouts
  • • Maintain audit logs
  • • Regular model retraining