Language Custom Embedder#

Source: examples/language_custom_embedder.py

Introduction#

Analyze one session’s discourse shift without external model dependencies by supplying a local deterministic embedding lookup.

Technical Implementation#

  1. Create three timestamped utterances in one session.

  2. Map each utterance to a fixed numeric vector with embedder=....

  3. Compute convergence trajectories and slope-based direction labels.

 1from __future__ import annotations
 2
 3import design_research_analysis as dran
 4
 5
 6def main() -> None:
 7    """Run language convergence analysis without optional embedding deps."""
 8    rows = [
 9        {
10            "timestamp": "2026-01-01T10:00:00Z",
11            "session_id": "team-b",
12            "text": "broad divergent framing",
13        },
14        {
15            "timestamp": "2026-01-01T10:01:00Z",
16            "session_id": "team-b",
17            "text": "constraint grounded framing",
18        },
19        {
20            "timestamp": "2026-01-01T10:02:00Z",
21            "session_id": "team-b",
22            "text": "shared actionable framing",
23        },
24    ]
25
26    lookup = {
27        "broad divergent framing": [0.0, 1.0],
28        "constraint grounded framing": [0.6, 0.6],
29        "shared actionable framing": [1.0, 0.0],
30    }
31    result = dran.compute_language_convergence(
32        rows,
33        window_size=1,
34        embedder=lambda texts: [lookup[text] for text in texts],
35    )
36    print(result.to_dict())
37
38
39if __name__ == "__main__":
40    main()

Expected Results#

Run Command

PYTHONPATH=src python examples/language_custom_embedder.py

Prints a serialized convergence result containing trajectories, per-group slopes, and direction labels for team-b.

References#

  • docs/analysis_recipes.rst