Ever watched 12 Angry Men and wondered what really happens in that jury room? 🤔 How do strangers wrestle with facts, biases, and pressure to reach a unanimous verdict?
This project is an interactive jury deliberation simulator built using Python and Google Gemini AI. It's not just another chatbot—it's an exploration into whether Generative AI can realistically capture the messy, complex dynamics of human jury deliberation.
The primary goal is to simulate an interactive jury deliberation process where a human player interacts with AI-driven jurors. We aim to explore the capabilities of Large Language Models (LLMs) like Google Gemini in modeling nuanced human behavior, biases, and group dynamics within the specific context of a jury trial.
- This diagram illustrates the courtroom simulation system flow.
- Human Player In the Flow
- Speaking Order System
- Interactive Simulation: Play the role of Juror #4 in a murder trial.
- AI-Powered Jurors: Engage with 5 AI jurors powered by Google Gemini 1.5 Flash via LangChain.
- Ambiguous Case: Deliberate on a challenging case with conflicting evidence and reasonable doubt.
- Two Simulation Modes:
- Scripted Mode: Interact with jurors who have predefined, fixed personas and backstories.
- Generated Mode: Experience unpredictable dynamics with AI jurors whose personas are dynamically generated by the LLM for each run.
- Dynamic Deliberation: AI jurors react to each other and the player based on their personas and the conversation history.
- Player Actions: Influence the discussion, call for votes, or even choose to exit the deliberation (under certain conditions).
- Performance Evaluation: Receive AI-generated feedback on your participation, reasoning, and influence, along with an overall score.
You are Juror #4 in a murder trial. The key details are:
- Defendant: Jack Miller, 18, accused of killing his classmate Leo Briggs, 18.
- Victim: Leo Briggs, found with a single stab wound.
- Murder Weapon: Jack's heirloom knife was found at the scene, but only the victim's fingerprints were on it.
- Rival: Kai Sato, Jack's rival, was seen with the knife weeks prior and had a motive. Bloody shoeprints at the scene match Kai's shoe size and brand. Traces of Kai's cologne were found in the knife sheath.
- Alibi: Jack has a digital alibi (cell tower/router logs) placing him at home, but no eyewitness confirmation.
- Witness: A neighbor heard shouting around the estimated time of death and saw a figure matching Jack's build/jacket leaving.
- Context: The evidence is deliberately ambiguous and packed with reasonable doubt.
You can choose how your AI jury colleagues are created at the start:
-
Scripted Mode:
- Uses predefined juror profiles stored in
SCRIPTED_JURORS_DATA. - Each AI juror (Jurors 1, 2, 3, 5, 6) has a fixed, detailed persona, background, and initial leaning.
- Ideal for controlled testing or experiencing specific predefined dynamics.
- Uses predefined juror profiles stored in
-
Generated Mode:
- Uses the LLM (
generate_jurors()function) to create unique juror personas dynamically at the start of each simulation. - Provides high replayability and explores unpredictable group interactions.
- Ideal for observing emergent behaviors.
- Uses the LLM (
Note: All jurors, whether scripted or generated, operate based on a shared behavioral framework (JUROR_TEMPLATE) to ensure consistent instruction format.
- AI Jurors are implemented as semi-autonomous agents using LangChain and Google Gemini 1.5 Flash.
- Each juror makes decisions and formulates responses based on:
- Their defined persona and personality traits (scripted or generated).
- The complete deliberation history (conversation transcript).
- Context-aware LLM prompting guiding behavior and response format.
- Their own internal state (current vote leaning, internal thoughts generated by the LLM).
The simulation proceeds turn by turn, alternating between AI actions and player prompts:
- AI Turn: An AI juror is selected (based on scoring or randomness) to either respond to the previous statement or initiate a new point. Their response is generated by the LLM based on their persona and the context.
- Player Check: After a set number of AI turns (e.g., 5), the game checks if the player needs to be prompted.
- Player Turn: If prompted, the player receives hints and can choose an action:
- Speak: Enter text to contribute to the deliberation.
- Vote: Initiate a formal voting round.
- Reject/Skip: Pass the turn.
- Exit: Leave the deliberation (available after 2 voting rounds).
- Voting Phase (if initiated):
- Each AI juror is prompted by the LLM to state and briefly justify their vote (Guilty/Not Guilty).
- The player is prompted to enter their vote.
- Votes are tallied.
- End Conditions: The game concludes if:
- A unanimous verdict (all Guilty or all Not Guilty) is reached after at least one round of discussion post-first vote.
- The player chooses to exit (after the 2nd voting round).
- A hung jury state persists after multiple voting rounds (logic can be adjusted).
- The
JUROR_TEMPLATEprovides the core instructions to the LLM for how to act as a juror. - Each juror's specific
personaandpersonality(fromSCRIPTED_JURORS_DATAor generated) are injected into this template. - The LLM is prompted to generate internal thoughts (
<thinking>) before generating the spoken response, allowing for more nuanced behavior. - Speaking and responding scores are dynamically adjusted to create a more natural turn-taking flow.
- After the deliberation ends, the entire conversation transcript and the
PERFORMANCE_RUBRICare sent to the Gemini AI. - The AI analyzes the player's (Juror #4) participation based on the rubric.
- The player receives:
- Five performance insights (strengths/weaknesses).
- An overall score out of 100.
- (Optional) Recommendations for improvement.
- Environment: Ensure you have Python installed. This project is developed in a Jupyter Notebook environment.
- Dependencies: Install the required Python packages. Open the notebook and run the first code cell which includes:
(Note: The first cell also attempts to uninstall potentially conflicting packages in certain environments like Kaggle).
pip install -qU 'langgraph==0.3.21' 'langchain-google-genai==2.1.2' 'langgraph-prebuilt==0.1.7'
- API Key:
- You need a Google API key enabled for the Gemini API.
- Store your API key securely. In the provided notebook, it uses Kaggle Secrets:
from kaggle_secrets import UserSecretsClient GOOGLE_API_KEY = UserSecretsClient().get_secret("GOOGLE_API_KEY") os.environ["GOOGLE_API_KEY"] = GOOGLE_API_KEY
- Alternatively, you can set the
GOOGLE_API_KEYenvironment variable directly or pass it during LLM initialization if running locally.
- Open the
capstone-jury-deliberation-simulator.ipynbnotebook. - Run the initial setup cells (package installation, API key configuration, LLM initialization).
- When the
JuryGameclass is initialized (usually near the end of the notebook), you will be prompted in the output to choose the AI juror type:Type your choice (Choose AI juror companions: type 'generated' or 'scripted':generatedorscripted) and press Enter. - The simulation will initialize, print the case facts and juror summaries.
- Follow the prompts to participate as Juror #4. Enter your statements, or use commands like
VOTE,REJECT, orEXITwhen prompted. - The deliberation continues until an end condition is met.
- A final summary and performance evaluation will be printed.
- Integrate visual evidence (e.g., crime scene photos) into the deliberation context.
- Allow players to take on the role of lawyers presenting evidence to AI jurors.
- Develop more sophisticated AI jurors with emotional intelligence, capable of forming alliances or rivalries.
- Create a web-based user interface or an open API for broader educational and research use.


