A jury deliberation simulation system that uses Large Language Models (LLMs) to simulate realistic jury discussions and verdict decisions. The system is built using LangGraph, supporting multiple LLM providers.
This project simulates jury deliberations by creating AI-powered jury members with distinct backgrounds and personalities. Each juror analyzes case evidence, participates in multi-round discussions, and ultimately votes on a verdict.
- Multi-round deliberations: Configure the number of discussion rounds before final verdict
- Diverse jury personas: Load jury members from YAML files with detailed backgrounds
- Multiple case scenarios: Support for various cases (including scenarios based of "My Cousin Vinny")
- LLM flexibility: Works with OpenAI GPT-4 or Google Gemini models
- Structured output: Saves deliberations as formatted markdown files with speaker colors
- Configurable jury size: Simulate deliberations with 2-12 jury members
- Intermediate verdict tracking: Each juror declares their current stance (GUILTY/NOT GUILTY) at the end of each deliberation round, allowing tracking of opinion evolution
- Install required packages:
pip install -r requirements.txtThe system supports two LLM providers:
Option 1: OpenAI
os.environ["OPENAI_API_KEY"] = "your-openai-api-key"
llm = ChatOpenAI(model="gpt-4", temperature=0.7)Option 2: Google Gemini (Free tier available)
api_key = "your-google-api-key"
llm = ChatGoogleGenerativeAI(
model="gemini-2.0-flash-001",
temperature=0.3,
google_api_key=api_key
).
├── langgraph_jury_deliberation.ipynb # Main code
├── jurors/
│ ├── jurors.yaml # Detailed jury member profiles
│ ├── old_and_young.yaml # Age-diverse jury pool
│ ├── religious_and_secular.yaml # Religion-diverse jury pool
│ ├── republican_and_democratic.yaml # Political-diverse jury pool
├── cases/
└── ├── Scenario 1.txt # Case scenarios (3 variations)
# Run a complete deliberation with one line
run_deliberation(
jury_file='jurors/republican_and_democratic.yaml',
case_file="cases/Scenario 1.txt",
scenario_number=1,
total_rounds=3,
save_to_file=True
)- Load jury members:
initialize_with_yaml("jurors.yaml", total_rounds=3)- Load a case:
initialize_with_case("Scenario 1.txt", scenario_number=1)- Run deliberation:
main(interactive=False, save_to_file=True)Run the system in interactive mode for manual control:
main(interactive=True)Available commands:
load <yaml_file>- Load jury members from YAML fileload <yaml_file> <rounds>- Load jury and set deliberation roundsrounds <number>- Set number of deliberation roundscase <case_file>- Load case from text filecase <case_file> <scenario_number>- Load specific scenarioscenarios <case_file>- List available scenariosdeliberate- Start deliberation with loaded casedeliberate nosave- Run without saving to filequit- Exit
Jury members can be defined in YAML with two structures:
jury_member_1:
first_name: Casey
last_name: Brown
age: 35 to 39 years
gender: Male
race: White alone
education: Bachelor's degree
occupation: Maintenance and repair workers
income: $100,000 to $124,999
religion: Catholic
state: Pennsylvania
biography: Casey Brown is a 37-year-old maintenance worker...
role: Juror that is forced to participate
goal: Have the case closed as soon as possiblejury_member_1:
role: Juror in the case of {topic}
goal: Listen impartially to the evidence...
backstory: Carla is a retired high school civics teacher...Cases are text files that can contain multiple scenarios:
Scenario 1:
Background: Tomer and Stan are accused of murder...
Presenting the Decisive Evidence: The trial is underway...
Deliberations are saved as markdown files with:
- Timestamp and configuration details
- Full case description
- Round-by-round discussions
- Final verdicts from each juror
- Overall jury decision (Guilty/Not Guilty/Hung Jury)
- Color-coded speakers for easy reading
Each juror's response in the deliberation rounds includes their current stance declaration in the format [Current stance: GUILTY/NOT GUILTY].
This allows tracking of how individual juror opinions evolve throughout the multi-round deliberation process.
Example filename: deliberation_republican_and_democratic_Scenario_1_scenario1_20250611_150544.md
The markdown files include HTML color styling for different speakers, which won't be visible in standard markdown viewers. To see the colored deliberation output:
-
Convert the markdown file to HTML using a web tool such as https://markdowntohtml.com/
-
Copy the contents of your deliberation .md file
-
Paste into the converter
-
View or save the resulting HTML to see speakers in their assigned colors
The system uses LangGraph to create a state machine with:
- Moderator node: Manages rounds and transitions
- Jury member nodes: Individual AI agents with personas
- Final verdict node: Collects votes and determines outcome
- State management: Tracks rounds, speakers, and discussion history
Create a new YAML file following the structure examples above.
Create text files with case details. Use "Scenario X:" headers for multiple scenarios.
Modify the should_continue() function to change flow control, or update jury member prompts in create_jury_node().
- API Key Issues: Ensure your API key is correctly set and has sufficient credits
- Memory Issues: For large juries or many rounds, consider using a more powerful model
- File Not Found: Check that all YAML and case files are in the correct directory
- Slow Performance: Gemini free tier has rate limits; consider upgrading or using OpenAI
If you use this system in research, please cite:
[Your citation information here]
[Your license information here]