alignmenter 0.0.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. alignmenter/__init__.py +14 -0
  2. alignmenter/cli.py +1815 -0
  3. alignmenter/config.py +99 -0
  4. alignmenter/data/configs/demo_config.yaml +15 -0
  5. alignmenter/data/configs/judges/safety_prompt.txt +2 -0
  6. alignmenter/data/configs/persona/default.yaml +15 -0
  7. alignmenter/data/configs/run.yaml +12 -0
  8. alignmenter/data/configs/safety_keywords.yaml +7 -0
  9. alignmenter/data/datasets/demo_conversations.jsonl +60 -0
  10. alignmenter/providers/__init__.py +47 -0
  11. alignmenter/providers/anthropic.py +87 -0
  12. alignmenter/providers/base.py +57 -0
  13. alignmenter/providers/classifiers.py +83 -0
  14. alignmenter/providers/embeddings.py +126 -0
  15. alignmenter/providers/judges.py +105 -0
  16. alignmenter/providers/local.py +102 -0
  17. alignmenter/providers/openai.py +151 -0
  18. alignmenter/reporting/__init__.py +6 -0
  19. alignmenter/reporting/html.py +721 -0
  20. alignmenter/reporting/json_out.py +33 -0
  21. alignmenter/run_config.py +106 -0
  22. alignmenter/runner.py +410 -0
  23. alignmenter/scorers/__init__.py +7 -0
  24. alignmenter/scorers/authenticity.py +337 -0
  25. alignmenter/scorers/safety.py +231 -0
  26. alignmenter/scorers/stability.py +104 -0
  27. alignmenter/scripts/__init__.py +1 -0
  28. alignmenter/scripts/bootstrap_dataset.py +142 -0
  29. alignmenter/scripts/calibrate_persona.py +196 -0
  30. alignmenter/scripts/run_openai_demo.py +74 -0
  31. alignmenter/scripts/sanitize_dataset.py +185 -0
  32. alignmenter/utils/__init__.py +7 -0
  33. alignmenter/utils/io.py +47 -0
  34. alignmenter/utils/tokens.py +46 -0
  35. alignmenter/utils/yaml.py +15 -0
  36. alignmenter-0.0.4.dist-info/METADATA +681 -0
  37. alignmenter-0.0.4.dist-info/RECORD +41 -0
  38. alignmenter-0.0.4.dist-info/WHEEL +5 -0
  39. alignmenter-0.0.4.dist-info/entry_points.txt +2 -0
  40. alignmenter-0.0.4.dist-info/licenses/LICENSE +201 -0
  41. alignmenter-0.0.4.dist-info/top_level.txt +1 -0
@@ -0,0 +1,681 @@
1
+ Metadata-Version: 2.4
2
+ Name: alignmenter
3
+ Version: 0.0.4
4
+ Summary: Persona-aligned evaluation toolkit for auditing conversational AI authenticity, safety, and stability.
5
+ Author: Alignmenter
6
+ License: Apache License
7
+ Version 2.0, January 2004
8
+ http://www.apache.org/licenses/
9
+
10
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11
+
12
+ 1. Definitions.
13
+
14
+ "License" shall mean the terms and conditions for use, reproduction,
15
+ and distribution as defined by Sections 1 through 9 of this document.
16
+
17
+ "Licensor" shall mean the copyright owner or entity authorized by
18
+ the copyright owner that is granting the License.
19
+
20
+ "Legal Entity" shall mean the union of the acting entity and all
21
+ other entities that control, are controlled by, or are under common
22
+ control with that entity. For the purposes of this definition,
23
+ "control" means (i) the power, direct or indirect, to cause the
24
+ direction or management of such entity, whether by contract or
25
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
26
+ outstanding shares, or (iii) beneficial ownership of such entity.
27
+
28
+ "You" (or "Your") shall mean an individual or Legal Entity
29
+ exercising permissions granted by this License.
30
+
31
+ "Source" form shall mean the preferred form for making modifications,
32
+ including but not limited to software source code, documentation
33
+ source, and configuration files.
34
+
35
+ "Object" form shall mean any form resulting from mechanical
36
+ transformation or translation of a Source form, including but
37
+ not limited to compiled object code, generated documentation,
38
+ and conversions to other media types.
39
+
40
+ "Work" shall mean the work of authorship, whether in Source or
41
+ Object form, made available under the License, as indicated by a
42
+ copyright notice that is included in or attached to the work
43
+ (an example is provided in the Appendix below).
44
+
45
+ "Derivative Works" shall mean any work, whether in Source or Object
46
+ form, that is based on (or derived from) the Work and for which the
47
+ editorial revisions, annotations, elaborations, or other modifications
48
+ represent, as a whole, an original work of authorship. For the purposes
49
+ of this License, Derivative Works shall not include works that remain
50
+ separable from, or merely link (or bind by name) to the interfaces of,
51
+ the Work and Derivative Works thereof.
52
+
53
+ "Contribution" shall mean any work of authorship, including
54
+ the original version of the Work and any modifications or additions
55
+ to that Work or Derivative Works thereof, that is intentionally
56
+ submitted to Licensor for inclusion in the Work by the copyright owner
57
+ or by an individual or Legal Entity authorized to submit on behalf of
58
+ the copyright owner. For the purposes of this definition, "submitted"
59
+ means any form of electronic, verbal, or written communication sent
60
+ to the Licensor or its representatives, including but not limited to
61
+ communication on electronic mailing lists, source code control systems,
62
+ and issue tracking systems that are managed by, or on behalf of, the
63
+ Licensor for the purpose of discussing and improving the Work, but
64
+ excluding communication that is conspicuously marked or otherwise
65
+ designated in writing by the copyright owner as "Not a Contribution."
66
+
67
+ "Contributor" shall mean Licensor and any individual or Legal Entity
68
+ on behalf of whom a Contribution has been received by Licensor and
69
+ subsequently incorporated within the Work.
70
+
71
+ 2. Grant of Copyright License. Subject to the terms and conditions of
72
+ this License, each Contributor hereby grants to You a perpetual,
73
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
74
+ copyright license to reproduce, prepare Derivative Works of,
75
+ publicly display, publicly perform, sublicense, and distribute the
76
+ Work and such Derivative Works in Source or Object form.
77
+
78
+ 3. Grant of Patent License. Subject to the terms and conditions of
79
+ this License, each Contributor hereby grants to You a perpetual,
80
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
81
+ (except as stated in this section) patent license to make, have made,
82
+ use, offer to sell, sell, import, and otherwise transfer the Work,
83
+ where such license applies only to those patent claims licensable
84
+ by such Contributor that are necessarily infringed by their
85
+ Contribution(s) alone or by combination of their Contribution(s)
86
+ with the Work to which such Contribution(s) was submitted. If You
87
+ institute patent litigation against any entity (including a
88
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
89
+ or a Contribution incorporated within the Work constitutes direct
90
+ or contributory patent infringement, then any patent licenses
91
+ granted to You under this License for that Work shall terminate
92
+ as of the date such litigation is filed.
93
+
94
+ 4. Redistribution. You may reproduce and distribute copies of the
95
+ Work or Derivative Works thereof in any medium, with or without
96
+ modifications, and in Source or Object form, provided that You
97
+ meet the following conditions:
98
+
99
+ (a) You must give any other recipients of the Work or
100
+ Derivative Works a copy of this License; and
101
+
102
+ (b) You must cause any modified files to carry prominent notices
103
+ stating that You changed the files; and
104
+
105
+ (c) You must retain, in the Source form of any Derivative Works
106
+ that You distribute, all copyright, patent, trademark, and
107
+ attribution notices from the Source form of the Work,
108
+ excluding those notices that do not pertain to any part of
109
+ the Derivative Works; and
110
+
111
+ (d) If the Work includes a "NOTICE" text file as part of its
112
+ distribution, then any Derivative Works that You distribute must
113
+ include a readable copy of the attribution notices contained
114
+ within such NOTICE file, excluding those notices that do not
115
+ pertain to any part of the Derivative Works, in at least one
116
+ of the following places: within a NOTICE text file distributed
117
+ as part of the Derivative Works; within the Source form or
118
+ documentation, if provided along with the Derivative Works; or,
119
+ within a display generated by the Derivative Works, if and
120
+ wherever such third-party notices normally appear. The contents
121
+ of the NOTICE file are for informational purposes only and
122
+ do not modify the License. You may add Your own attribution
123
+ notices within Derivative Works that You distribute, alongside
124
+ or as an addendum to the NOTICE text from the Work, provided
125
+ that such additional attribution notices cannot be construed
126
+ as modifying the License.
127
+
128
+ You may add Your own copyright statement to Your modifications and
129
+ may provide additional or different license terms and conditions
130
+ for use, reproduction, or distribution of Your modifications, or
131
+ for any such Derivative Works as a whole, provided Your use,
132
+ reproduction, and distribution of the Work otherwise complies with
133
+ the conditions stated in this License.
134
+
135
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
136
+ any Contribution intentionally submitted for inclusion in the Work
137
+ by You to the Licensor shall be under the terms and conditions of
138
+ this License, without any additional terms or conditions.
139
+ Notwithstanding the above, nothing herein shall supersede or modify
140
+ the terms of any separate license agreement you may have executed
141
+ with Licensor regarding such Contributions.
142
+
143
+ 6. Trademarks. This License does not grant permission to use the trade
144
+ names, trademarks, service marks, or product names of the Licensor,
145
+ except as required for reasonable and customary use in describing the
146
+ origin of the Work and reproducing the content of the NOTICE file.
147
+
148
+ 7. Disclaimer of Warranty. Unless required by applicable law or
149
+ agreed to in writing, Licensor provides the Work (and each
150
+ Contributor provides its Contributions) on an "AS IS" BASIS,
151
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
152
+ implied, including, without limitation, any warranties or conditions
153
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
154
+ PARTICULAR PURPOSE. You are solely responsible for determining the
155
+ appropriateness of using or redistributing the Work and assume any
156
+ risks associated with Your exercise of permissions under this License.
157
+
158
+ 8. Limitation of Liability. In no event and under no legal theory,
159
+ whether in tort (including negligence), contract, or otherwise,
160
+ unless required by applicable law (such as deliberate and grossly
161
+ negligent acts) or agreed to in writing, shall any Contributor be
162
+ liable to You for damages, including any direct, indirect, special,
163
+ incidental, or consequential damages of any character arising as a
164
+ result of this License or out of the use or inability to use the
165
+ Work (including but not limited to damages for loss of goodwill,
166
+ work stoppage, computer failure or malfunction, or any and all
167
+ other commercial damages or losses), even if such Contributor
168
+ has been advised of the possibility of such damages.
169
+
170
+ 9. Accepting Warranty or Additional Support. While redistributing
171
+ the Work or Derivative Works thereof, You may choose to offer,
172
+ and charge a fee for, acceptance of support, warranty, indemnity,
173
+ or other liability obligations and/or rights consistent with this
174
+ License. However, in accepting such obligations, You may act only
175
+ on Your own behalf and on Your sole responsibility, not on behalf
176
+ of any other Contributor, and only if You agree to indemnify,
177
+ defend, and hold each Contributor harmless for any liability
178
+ incurred by, or claims asserted against, such Contributor by reason
179
+ of your accepting any such warranty or additional liability.
180
+
181
+ END OF TERMS AND CONDITIONS
182
+
183
+ APPENDIX: How to apply the Apache License to your work.
184
+
185
+ To apply the Apache License to your work, attach the following
186
+ boilerplate notice, with the fields enclosed by brackets "[]"
187
+ replaced with your own identifying information. (Don't include
188
+ the brackets!) The text should be enclosed in the appropriate
189
+ comment syntax for the file format. We also recommend that a
190
+ file or class name and description of purpose be included on the
191
+ same "printed page" as the copyright notice for easier
192
+ identification within third-party archives.
193
+
194
+ Copyright 2024 Alignmenter Contributors
195
+
196
+ Licensed under the Apache License, Version 2.0 (the "License");
197
+ you may not use this file except in compliance with the License.
198
+ You may obtain a copy of the License at
199
+
200
+ http://www.apache.org/licenses/LICENSE-2.0
201
+
202
+ Unless required by applicable law or agreed to in writing, software
203
+ distributed under the License is distributed on an "AS IS" BASIS,
204
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
205
+ See the License for the specific language governing permissions and
206
+ limitations under the License.
207
+
208
+ Project-URL: Homepage, https://alignmenter.com
209
+ Project-URL: Repository, https://github.com/justinGrosvenor/alignmenter
210
+ Project-URL: Documentation, https://github.com/justinGrosvenor/alignmenter
211
+ Project-URL: Bug Tracker, https://github.com/justinGrosvenor/alignmenter/issues
212
+ Keywords: llm,evaluation,alignment,persona,safety
213
+ Classifier: Development Status :: 3 - Alpha
214
+ Classifier: Intended Audience :: Developers
215
+ Classifier: Intended Audience :: Information Technology
216
+ Classifier: License :: OSI Approved :: Apache Software License
217
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
218
+ Classifier: Programming Language :: Python
219
+ Classifier: Programming Language :: Python :: 3
220
+ Classifier: Programming Language :: Python :: 3.10
221
+ Classifier: Programming Language :: Python :: 3.11
222
+ Requires-Python: >=3.10
223
+ Description-Content-Type: text/markdown
224
+ License-File: LICENSE
225
+ Requires-Dist: typer[all]
226
+ Requires-Dist: pydantic
227
+ Requires-Dist: pydantic-settings>=2.0
228
+ Requires-Dist: openai>=1.12.0
229
+ Requires-Dist: pyyaml>=6.0
230
+ Requires-Dist: sentence-transformers>=2.2.2
231
+ Requires-Dist: torch
232
+ Requires-Dist: tiktoken>=0.7.0
233
+ Requires-Dist: requests>=2.32.0
234
+ Provides-Extra: dev
235
+ Requires-Dist: pytest; extra == "dev"
236
+ Requires-Dist: ruff; extra == "dev"
237
+ Requires-Dist: build; extra == "dev"
238
+ Requires-Dist: twine; extra == "dev"
239
+ Provides-Extra: safety
240
+ Requires-Dist: transformers>=4.30.0; extra == "safety"
241
+ Dynamic: license-file
242
+
243
+ <p align="center">
244
+ <img src="../assets/alignmenter-banner.png" alt="Alignmenter" width="800">
245
+ </p>
246
+
247
+ <p align="center">
248
+ <strong>Persona-aligned evaluation for conversational AI</strong>
249
+ </p>
250
+
251
+ <p align="center">
252
+ <a href="#quickstart">Quickstart</a> •
253
+ <a href="#features">Features</a> •
254
+ <a href="#architecture">Architecture</a> •
255
+ <a href="#documentation">Documentation</a> •
256
+ <a href="#license">License</a>
257
+ </p>
258
+
259
+ ---
260
+
261
+ ## Overview
262
+
263
+ **Alignmenter** is a lightweight, production-ready evaluation toolkit for auditing conversational AI systems across three core dimensions:
264
+
265
+ - **🎨 Authenticity**: Does the assistant stay on-brand?
266
+ - **🛡️ Safety**: Does it avoid harmful or policy-violating outputs?
267
+ - **⚖️ Stability**: Are responses consistent across sessions?
268
+
269
+ Unlike generic LLM evaluation frameworks, Alignmenter is purpose-built for **persona alignment**—ensuring your AI assistant speaks with your unique voice while staying safe and stable.
270
+
271
+ ## Quickstart
272
+
273
+ ### Installation
274
+
275
+ ```bash
276
+ # Clone the repository
277
+ git clone https://github.com/yourusername/alignmenter.git
278
+ cd alignmenter
279
+
280
+ # Create virtual environment
281
+ python -m venv env
282
+ source env/bin/activate # On Windows: env\Scripts\activate
283
+
284
+ # Install with dev dependencies
285
+ pip install -e .[dev]
286
+
287
+ # Optional: Install with offline safety classifier
288
+ pip install -e .[dev,safety]
289
+ ```
290
+
291
+ ### Install from PyPI
292
+
293
+ ```bash
294
+ pip install alignmenter
295
+ alignmenter init
296
+ alignmenter run --config configs/run.yaml --no-generate
297
+ ```
298
+
299
+ > **Note**: The `safety` extra includes `transformers` for the offline safety classifier (ProtectAI/distilled-safety-roberta). Without it, Alignmenter falls back to a lightweight heuristic classifier. See [docs/offline_safety.md](../docs/offline_safety.md) for details.
300
+
301
+ ### Run Your First Evaluation
302
+
303
+ ```bash
304
+ # Set API key (for embedding and judge models)
305
+ export OPENAI_API_KEY="your-key-here"
306
+
307
+ # Run evaluation on demo dataset (regenerates transcripts via the provider)
308
+ alignmenter run \
309
+ --model openai:gpt-4o-mini \
310
+ --dataset datasets/demo_conversations.jsonl \
311
+ --persona configs/persona/default.yaml
312
+
313
+ # Reuse existing transcripts without hitting the provider
314
+ alignmenter run --config configs/run.yaml --no-generate
315
+
316
+ # View interactive HTML report
317
+ alignmenter report --last
318
+ ```
319
+
320
+ **Output:**
321
+ ```
322
+ Loading dataset: 60 turns across 10 sessions
323
+ ✓ Brand voice score: 0.82 (range: 0.78-0.86)
324
+ ✓ Safety score: 0.97
325
+ ✓ Consistency score: 0.94
326
+ Report written to: reports/demo/2025-11-03T00-14-01_alignmenter_run/index.html
327
+ ```
328
+
329
+ ## Features
330
+
331
+ ### 🎯 Three-Dimensional Scoring
332
+
333
+ #### Authenticity
334
+ - **Embedding similarity**: Measures semantic alignment with persona examples
335
+ - **Trait model**: Logistic regression on linguistic features (trained via calibration)
336
+ - **Lexicon matching**: Enforces preferred/avoided vocabulary
337
+ - **Bootstrap CI**: Statistical confidence intervals for reliability
338
+
339
+ #### Safety
340
+ - **Keyword classifier**: Fast pattern matching for common violations
341
+ - **LLM judge**: GPT-4 as a safety oracle with budget controls
342
+ - **Offline classifier**: ProtectAI's distilled-safety-roberta (no API calls)
343
+ - **Fused scoring**: Weighted ensemble of rule-based + model-based signals
344
+ - **Adversarial testing**: Built-in safety traps in demo datasets
345
+
346
+ #### Stability
347
+ - **Cosine variance**: Detects semantic drift across conversation turns
348
+ - **Session clustering**: Identifies divergent response patterns
349
+ - **Temporal analysis**: Tracks consistency over time
350
+
351
+ ### 📊 Rich Reporting
352
+
353
+ - **Interactive HTML**: Grade-based report cards with charts (Chart.js)
354
+ - **JSON export**: Machine-readable results for CI/CD pipelines
355
+ - **CSV downloads**: Per-metric exports for spreadsheet analysis
356
+ - **Turn-level explorer**: Drill down into individual responses
357
+
358
+ ### 🔧 Production-Ready
359
+
360
+ - **Multi-provider support**: OpenAI, Anthropic, local (vLLM, Ollama)
361
+ - **Budget guardrails**: Halt runs at 90% of judge API budget
362
+ - **Cost projection**: Estimate expenses before execution
363
+ - **Reproducibility**: Logs Python version, model, seed, timestamps
364
+ - **PII sanitization**: Built-in scrubbing for production data
365
+
366
+ ### 🚀 Developer Experience
367
+
368
+ - **CLI-first**: Simple commands for evaluation, calibration, reporting
369
+ - **YAML configuration**: Declarative persona packs and run configs
370
+ - **Python API**: Programmatic access for custom workflows
371
+ - **Comprehensive tests**: 69+ unit tests with pytest
372
+ - **Type safety**: Full type hints throughout
373
+
374
+ ## Architecture
375
+
376
+ ```
377
+ ┌─────────────────────────────────────────────────────────────────┐
378
+ │ Alignmenter CLI │
379
+ │ alignmenter run / report / calibrate / bootstrap / sanitize │
380
+ └─────────────────────────────────────────────────────────────────┘
381
+ │
382
+ ▼
383
+ ┌─────────────────────────────────────────────────────────────────┐
384
+ │ Runner │
385
+ │ Orchestrates evaluation: load data → score → report │
386
+ └─────────────────────────────────────────────────────────────────┘
387
+ │
388
+ ┌───────────────────┼───────────────────┐
389
+ ▼ ▼ ▼
390
+ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
391
+ │ Authenticity │ │ Safety │ │ Stability │
392
+ │ Scorer │ │ Scorer │ │ Scorer │
393
+ └──────────────┘ └──────────────┘ └──────────────┘
394
+ │ │ │
395
+ │ │ │
396
+ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
397
+ │ Embeddings │ │ LLM Judge │ │ Cosine │
398
+ │ Trait Model │ │ Keywords │ │ Variance │
399
+ │ Lexicon │ │ Fusion │ │ Clustering │
400
+ └──────────────┘ └──────────────┘ └──────────────┘
401
+ │
402
+ ▼
403
+ ┌───────────────────────────────────────┐
404
+ │ Reporting Layer │
405
+ │ HTML / JSON / CSV / Interactive UI │
406
+ └───────────────────────────────────────┘
407
+ ```
408
+
409
+ ### Key Components
410
+
411
+ | Component | Purpose | Key Files |
412
+ |-----------|---------|-----------|
413
+ | **CLI** | Command-line interface | `src/alignmenter/cli.py` |
414
+ | **Runner** | Orchestration engine | `src/alignmenter/runner.py` |
415
+ | **Scorers** | Metric computation | `src/alignmenter/scorers/` |
416
+ | **Providers** | LLM/embedding backends | `src/alignmenter/providers/` |
417
+ | **Reporters** | Output generation | `src/alignmenter/reporting/` |
418
+ | **Datasets** | JSONL conversation data | `datasets/` |
419
+ | **Personas** | Brand voice definitions | `configs/persona/` |
420
+
421
+ ## Documentation
422
+
423
+ - **[Persona Annotation Guide](../docs/persona_annotation.md)**: How to label data and calibrate trait models
424
+ - **[Offline Safety Classifier](../docs/offline_safety.md)**: Using distilled-safety-roberta without API calls
425
+ - **[Datasets README](datasets/README.md)**: Data provenance, licensing, and anonymization
426
+ - **[Requirements](../docs/alignmenter_requirements.md)**: Full product specification
427
+
428
+ ## Usage Examples
429
+
430
+ ### Evaluate Multiple Models
431
+
432
+ ```bash
433
+ # Compare GPT-4 vs Claude
434
+ alignmenter run \
435
+ --model openai:gpt-4 \
436
+ --compare anthropic:claude-3-5-sonnet-20241022 \
437
+ --dataset datasets/demo_conversations.jsonl \
438
+ --persona configs/persona/default.yaml
439
+ ```
440
+
441
+ ### Custom Judge and Embeddings
442
+
443
+ ```bash
444
+ # Use Claude as safety judge, local embeddings
445
+ alignmenter run \
446
+ --model openai:gpt-4o-mini \
447
+ --judge anthropic:claude-3-5-sonnet-20241022 \
448
+ --embedding sentence-transformer:all-MiniLM-L6-v2 \
449
+ --dataset datasets/demo_conversations.jsonl \
450
+ --persona configs/persona/default.yaml
451
+ ```
452
+
453
+ ### Bootstrap Synthetic Dataset
454
+
455
+ ```bash
456
+ # Generate 50 conversations with adversarial traps
457
+ alignmenter bootstrap-dataset \
458
+ --out datasets/my_test.jsonl \
459
+ --sessions 50 \
460
+ --safety-trap-ratio 0.15 \
461
+ --brand-trap-ratio 0.20 \
462
+ --seed 42
463
+ ```
464
+
465
+ ### Calibrate Persona Traits
466
+
467
+ ```bash
468
+ # Train trait model from labeled data
469
+ alignmenter calibrate-persona \
470
+ --persona-path configs/persona/mybot.yaml \
471
+ --dataset annotations.jsonl \
472
+ --out configs/persona/mybot.traits.json \
473
+ --epochs 300
474
+ ```
475
+
476
+ ### Sanitize Production Data
477
+
478
+ ```bash
479
+ # Remove PII before evaluation
480
+ alignmenter sanitize-dataset \
481
+ --input prod_logs.jsonl \
482
+ --out datasets/sanitized.jsonl \
483
+ --hash-session-ids \
484
+ --scrub-patterns "email|phone|ssn"
485
+ ```
486
+
487
+ ## Persona Configuration
488
+
489
+ Define your brand voice in YAML:
490
+
491
+ ```yaml
492
+ # configs/persona/mybot.yaml
493
+ id: mybot
494
+ name: "MyBot Assistant"
495
+ description: "Professional, evidence-driven, technical"
496
+
497
+ voice:
498
+ tone: ["professional", "precise", "measured"]
499
+ formality: "business_casual"
500
+
501
+ # Preferred vocabulary
502
+ lexicon:
503
+ preferred:
504
+ - "baseline"
505
+ - "signal"
506
+ - "alignment"
507
+ - "evidence-based"
508
+ avoided:
509
+ - "lol"
510
+ - "bro"
511
+ - "hype"
512
+ - "vibes"
513
+
514
+ # Example on-brand responses (for embedding similarity)
515
+ examples:
516
+ - "Our baseline analysis indicates a 15% improvement in alignment metrics."
517
+ - "The signal-to-noise ratio suggests this approach is viable."
518
+ - "Let's establish a clear baseline before proceeding."
519
+
520
+ # Trait model weights (generated by calibration)
521
+ traits:
522
+ weights: [0.12, -0.34, 0.08, ...] # Learned from annotations
523
+ vocabulary: ["baseline", "signal", ...]
524
+ ```
525
+
526
+ ## API Usage
527
+
528
+ ```python
529
+ from alignmenter.runner import Runner
530
+ from alignmenter.config import RunConfig
531
+
532
+ # Load configuration
533
+ config = RunConfig.from_yaml("configs/run/my_eval.yaml")
534
+
535
+ # Execute evaluation
536
+ runner = Runner(config)
537
+ results = runner.execute()
538
+
539
+ # Access scores
540
+ print(f"Authenticity: {results['scores']['authenticity']['mean']:.3f}")
541
+ print(f"Safety: {results['scores']['safety']['fused_judge']:.3f}")
542
+ print(f"Stability: {results['scores']['stability']['session_variance']:.3f}")
543
+
544
+ # Generate reports
545
+ from alignmenter.reporting import HTMLReporter, JSONReporter
546
+
547
+ html_reporter = HTMLReporter()
548
+ html_reporter.write(
549
+ run_dir=results["run_dir"],
550
+ summary=results["summary"],
551
+ scores=results["scores"],
552
+ sessions=results["sessions"],
553
+ )
554
+ ```
555
+
556
+ ## CI/CD Integration
557
+
558
+ ```yaml
559
+ # .github/workflows/eval.yml
560
+ name: Persona Evaluation
561
+
562
+ on: [push, pull_request]
563
+
564
+ jobs:
565
+ evaluate:
566
+ runs-on: ubuntu-latest
567
+ steps:
568
+ - uses: actions/checkout@v3
569
+ - uses: actions/setup-python@v4
570
+ with:
571
+ python-version: '3.11'
572
+
573
+ - name: Install Alignmenter
574
+ run: pip install -e .
575
+
576
+ - name: Run Evaluation
577
+ env:
578
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
579
+ run: |
580
+ alignmenter run \
581
+ --model openai:gpt-4o-mini \
582
+ --dataset datasets/ci_test.jsonl \
583
+ --persona configs/persona/default.yaml \
584
+ --judge-budget 100
585
+
586
+ - name: Upload Report
587
+ uses: actions/upload-artifact@v3
588
+ with:
589
+ name: evaluation-report
590
+ path: reports/
591
+ ```
592
+
593
+ ## Development
594
+
595
+ ### Running Tests
596
+
597
+ ```bash
598
+ # All tests
599
+ pytest
600
+
601
+ # With coverage
602
+ pytest --cov=src/alignmenter --cov-report=html
603
+
604
+ # Specific test file
605
+ pytest tests/test_scorers.py -v
606
+ ```
607
+
608
+ ### Code Quality
609
+
610
+ ```bash
611
+ # Type checking
612
+ mypy src/
613
+
614
+ # Linting
615
+ ruff check src/
616
+
617
+ # Formatting
618
+ black src/ tests/
619
+ ```
620
+
621
+ ### Local Development
622
+
623
+ ```bash
624
+ # Install in editable mode with dev dependencies
625
+ pip install -e .[dev]
626
+
627
+ # Run from source
628
+ python -m alignmenter.cli run --help
629
+
630
+ # Generate report from last run
631
+ make report-last
632
+ ```
633
+
634
+ ## Roadmap
635
+
636
+ - [ ] Web dashboard for team collaboration
637
+ - [ ] Hosted evaluation pipelines (CI/CD SaaS)
638
+ - [ ] Multi-language support (non-English personas)
639
+ - [ ] Offline safety model (no API required)
640
+ - [ ] Cost/latency tracking in scorers
641
+ - [ ] Competitive landscape analysis
642
+ - [ ] Metric cards and ablation studies
643
+
644
+ ## Contributing
645
+
646
+ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
647
+
648
+ **Areas we'd love help with:**
649
+ - Additional persona packs (different brand voices)
650
+ - Language support beyond English
651
+ - Integration with other LLM providers
652
+ - Performance optimizations for large datasets
653
+
654
+ ## License
655
+
656
+ Apache License 2.0 - see [LICENSE](LICENSE) for details.
657
+
658
+ ## Citation
659
+
660
+ If you use Alignmenter in research, please cite:
661
+
662
+ ```bibtex
663
+ @software{alignmenter2024,
664
+ title={Alignmenter: A Framework for Persona-Aligned Conversational AI Evaluation},
665
+ author={Alignmenter Contributors},
666
+ year={2024},
667
+ url={https://github.com/yourusername/alignmenter}
668
+ }
669
+ ```
670
+
671
+ ## Support
672
+
673
+ - **Documentation**: [docs/](docs/)
674
+ - **Issues**: [GitHub Issues](https://github.com/yourusername/alignmenter/issues)
675
+ - **Discussions**: [GitHub Discussions](https://github.com/yourusername/alignmenter/discussions)
676
+
677
+ ---
678
+
679
+ <p align="center">
680
+ Made with ❤️ by the Alignmenter team
681
+ </p>