File size: 3,419 Bytes
5fc8c9d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# okto_version: "1.2"
PROJECT "CompleteV12Example"
DESCRIPTION "Complete example demonstrating all v1.2 features"

ENV {

  accelerator: "gpu"

  min_memory: "16GB"

  precision: "fp16"

  backend: "oktoseek"

  install_missing: true
}

DATASET {

  train: "examples/datasets/demo_train.jsonl"

  validation: "examples/datasets/demo_train.jsonl"

  format: "jsonl"

  type: "chat"

  language: "en"
}

MODEL {

  name: "complete-v12-model"

  base: "google/flan-t5-base"

  device: "cuda"
  
  ADAPTER {

    type: "lora"

    path: "./adapters/my-adapter"

    rank: 16

    alpha: 32
  }
}

TRAIN {

  epochs: 10

  batch_size: 32

  learning_rate: 0.0001

  optimizer: "adamw"

  scheduler: "cosine"

  device: "cuda"

  checkpoint_steps: 100
}

METRICS {
  accuracy
  loss
  perplexity
  f1
  confidence
}

MONITOR {

  metrics: [
    "loss",
    "val_loss",
    "accuracy",
    "gpu_usage",
    "ram_usage",
    "throughput",
    "latency",
    "confidence"
  ]
  
  notify_if {
    loss > 2.0
    gpu_usage > 90%
    temperature > 85
    hallucination_score > 0.5
  }

  

  log_to: "logs/training.log"
}

BEHAVIOR {

  mode: "chat"

  personality: "assistant"

  verbosity: "medium"

  language: "en"

  avoid: ["politics", "violence", "hate"]

  fallback: "How can I help you?"

  prompt_style: "User: {input}\nAssistant:"
}

STABILITY {

  stop_if_nan: true

  stop_if_diverges: true

  min_improvement: 0.001
}

EXPLORER {
  try {

    lr: [0.0003, 0.0001]

    batch_size: [16, 32]
  }

  max_tests: 4

  pick_best_by: "val_loss"
}

CONTROL {
  on_epoch_end {
    SAVE model
    LOG "Epoch completed"
    
    IF loss > 2.0 {
      SET LR = 0.00005
      LOG "High loss detected"
      
      WHEN gpu_usage > 90% {
        SET batch_size = 16
        LOG "Reducing batch size due to GPU pressure"
      }
    }
    
    IF val_loss > 2.5 {
      STOP_TRAINING
    }
    
    IF accuracy > 0.9 {
      SAVE "best_model"
      LOG "High accuracy reached"
    }
  }

  

  validate_every: 200
  
  WHEN gpu_memory < 12GB {

    SET batch_size = 16

  }

  

  EVERY 500 steps {

    SAVE checkpoint

  }

}



INFERENCE {

  mode: "chat"

  format: "User: {input}\nAssistant:"

  exit_command: "/exit"

  

  params {

    temperature: 0.7

    max_length: 120

    top_p: 0.9

    beams: 2

    do_sample: true

  }

  

  CONTROL {

    IF confidence < 0.3 { RETRY }

    IF hallucination_score > 0.5 { REPLACE WITH "I'm not certain about that." }
  }
}

GUARD {
  prevent {
    hallucination
    toxicity
    bias
    data_leak
    unsafe_code
  }

  

  detect_using: ["classifier", "regex", "embedding"]
  
  on_violation {
    REPLACE

    with_message: "Sorry, this request is not allowed."
  }
}

SECURITY {
  input_validation {

    max_length: 500

    disallow_patterns: [
      "<script>",
      "DROP TABLE",
      "rm -rf"
    ]
  }
  
  output_validation {

    prevent_data_leak: true

    mask_personal_info: true
  }
  
  rate_limit {

    max_requests_per_minute: 60
  }
  
  encryption {

    algorithm: "AES-256"
  }
}

EXPORT {

  format: ["okm", "onnx", "gguf"]

  path: "export/"
}

DEPLOY {

  target: "api"

  host: "0.0.0.0"

  endpoint: "/chatbot"

  requires_auth: true

  port: 9000

  max_concurrent_requests: 100

  protocol: "http"

  format: "onnx"
}