# Psychology Lesson for LLMs & Humans #### by Hobson Lane #### April 24, 2025 #### San Diego Python User Group --- ## Medens [clueo.net](https://indica.clueo.net/) #### Job Crowder and #### Alicia Chen
## Engineers - Taylor Kirk - Jason O'Dell - Hobson Lane --- ## REIT (NSF Grant) Teaching AI to SD teachers #### Gary Cottrell #### UCSD CS Dept --- ## Agenda 1. Your assignment 2. Planning a program/dialog 3. Implement the plan 4. Decision trees and forests 5. Getting serious about reliability 6. Hybrid architecture 7. Convomeld and Indica 8. iPython aliases --- ## Your assignment - keywords: `if`, `print()`, `input()`, `=` - bonus keywords: `def`, `in`, `str.*()` --- ## Text adventures and decision trees GenX got their coding start with text adventures: - _DnD_ - Character sheets - Die rollers - Dungeon Masters - _Oregon Trail_ - _Colossal Cave Adventure_ - _Rogue_ --- ## Dialog plan #### Student design
--- ## Hard coded text adventure ```python print('You are a student at Mesa and you want to go swimming!') resp = input("You're in SD, which way do you go (N/S)?") if resp[0] == 'N': resp = input("You're in LA, Which way now (E/W)?") if resp[0] == 'E': resp = input("You're in Vegas. You lose ;(") elif resp[0] == 'W': resp = input("You're at the beach! You win! :-)") print('Invalid direction in LA. You lose!') elif resp[0] == 'S': resp = input("You're in the TJ. Which way now (E/W)?") if resp[0] == 'E': resp = input("You're in the desert. You lose ;(") elif resp[0] == 'W': resp = input("You're at the coast! You win! :-)") print('Invalid direction in TJ. You lose!') print('Game Over') ``` --- ## More natural text adventure - `.lower()` - `.strip()` - `.replace(' ', '').replace('-', '')...` --- ## Automation - **Pylint** code quality score - Open loop integration test ```bash $ python -c 'print('N') ; print('W') ; | python game.py $ cat player_input.txt | python game.py ``` --- ## Close the loop with `pexpect` ```python import pexpect child = pexpect.spawn('python game.py') while child: child.expect('.*: ') command = select_action(text) # 'north' child.sendline(command) ``` --- ## Thoughtful feedback ###
R
###
E
###
P
###
L
--- ## Thoughtful feedback
R ead
### **E** ### **P** ### **L** --- ## Thoughtful feedback ### **R** ead
E val
### **P** ### **L** --- ## Thoughtful feedback ### **R** ead ### **E** val
P rint
### **L** --- ## Thoughtful feedback ### **R** ead ### **E** val ### **P** rint
L oop
--- ## Mindful grading ### **R** ead ### **E** val
**P** lay
--- ## Get serious - Phone tree - Autocomplete - Therapy - e.g. ELIZA, Wobot - Chat ops - Search - RAG - LLM search - Full monty - naked LLM - e.g. _Grok_, ChatGPT_ - CLI assistant (shy) - Vibe coding assistant - e.g. _Copilot_, _Cursor_, _Aider_ - Massive homework crib sheet - e.g. _ClaudeCode_, _Gemma_ --- ## Therapist training
--- ## Artificial Intelligence? There's only one problem with AI... --- ## Artificial Intelligence? There's only one problem with AI... It's trained to not be dumb: - Only knows about tokens NOT: - Numbers - Math - Logic - Counting - Physical objects - Common sense logic - Geometry - Rules --- ## Why? - Must give it a crib sheet - Takes structured data and makes it unstructured and fuzzy - Ambiguity - Basically a fuzzy database --- #### FDA classification of milk nutrition
--- ## Bayesean network for medicine #### Expert system for diagnosing cancer
--- ## Learned decision trees - Random forest - Neuromorphic programming (deep learning) - Decision root ball - Bayesean belief networks, the book of why --- ## Hybrid Code Networks
--- ## NLPiA Hybrid Networks with Feedback
--- ## Convomeld - Merge conversation logs to create a dialog tree - Plot the dialog plan network (graph) - Load dialog plan to `networkx` - Create drawio dialog plan diagrams w/ drawpy - Execute the dialog plan #### [gitlab.com/tangibleai/community/convomeld](https://gitlab.com/tangibleai/community/convomeld) --- ## [indica.clueo.net](https://indica.clueo.net/) - Django admin wrapper - Conversation logs - Exercises - LLM prompts ### TODO: - API for ConvoMeld --- ## Reflect-a-bot
--- ## ipython aliases #### `~/.ipython/profile_default/startup/my_aliases.ipy` ```python %alias meld meld %alias subl subl %alias which which %alias wc wc %alias find find %alias curl curl %alias grep grep ``` --- ### Links 1. ["PAIR: ... Counselor Reflection Scoring in Motivational Interviewing", Min et. al.](https://aclanthology.org/2022.emnlp-main.11.pdf) 2. ["Building a Motivational Interviewing Dataset.pdf", Pérez-Rosas et. al.](https://aclanthology.org/W16-0305.pdf) 3. ["Explaining Bayesian Networks in Natural Language using Factor Arguments." Oct 2024, by Jaime Sevilla et al](https://www.researchgate.net/publication/385176693_Explaining_Bayesian_Networks_in_Natural_Language_using_Factor_Arguments_Evaluation_in_the_medical_domain/fulltext/6719c020edbc012ea138df93/Explaining-Bayesian-Networks-in-Natural-Language-using-Factor-Arguments-Evaluation-in-the-medical-domain.pdf) 4. [Decision-trees-for-the-Start-up-milk-classification](https://www.researchgate.net/profile/Daniel-Lefebvre-2/publication/238725014/figure/fig3/AS:669294299971611@1536583604771/Decision-trees-for-the-Start-up-milk-classification-task-with-a-low-A-medium-B.png) 5. [Indica Django App by Job Crowder & Jason](https://indica.clueo.net/) 6. [On the Biology of LLMs by Anthropic](https://transformer-circuits.pub/2025/attribution-graphs/biology.html) ---