Primer
  • Factored Cognition Primer
  • Intro
    • Factored Cognition
    • Before We Start
  • Chapters
    • Hello World
    • Question Answering
      • Q&A without context
      • Q&A about short texts
    • Debate
      • Representing debates
      • From debates to prompts
      • The debate recipe
    • Long Texts
      • Loading paper text
      • Finding relevant paragraphs
      • Answering given paragraphs
    • Amplification
      • Asking subquestions
      • Answering subquestions
      • One-step amplification
      • Recursive amplification
    • Verifiers
      • Checking answers
      • Checking reasoning steps
    • Tool Use
      • Web search
      • Interpreters
    • Deduction
      • Chain of Thought
    • Action Selection
      • One-shot action selection
      • Iterative action selection
    • Amplification Revisited
  • Appendix
    • What’s next?
  • Links
    • We’re Hiring
    • Our Slack Community
    • ICE on Github
Powered by GitBook
On this page
Edit on GitHub
  1. Chapters
  2. Debate

Representing debates

Debates have turns, turns have authors and messages

We’ll represent debates as lists of turns. Each turn has the name of an agent and a message from that agent. For example, including some types:

debate/types.py
Name = str
Message = str
Turn = tuple[Name, Message]
Debate = list[Turn]

my_debate: Debate = [
    ("Alice", "I think we should legalize all drugs."),
    ("Bob", "I'm against."),
    ("Alice", "The war on drugs has been a failure. It's time to try something new."),
]

Here’s how we’ll initialize and render debates:

debate/utils.py
from typing import Optional

from fvalues import F

from ice.recipes.primer.debate.types import *


def initialize_debate(question: Message) -> Debate:
    return [
        ("Question", question),
        ("Alice", "I'm in favor."),
        ("Bob", "I'm against."),
    ]


def render_debate(debate: Debate, self_name: Optional[Name] = None) -> str:
    debate_text = ""
    for speaker, text in debate:
        if speaker == self_name:
            speaker = "You"
        debate_text += F(f'{speaker}: "{text}"\n')
    return debate_text.strip()

When we render debates, we also provide the option to replace an agent name with “You”, like this:

>>> print(render_debate(my_debate, self_name="Alice"))
You: "I think we should legalize all drugs."
Bob: "I'm against."
You: "The war on drugs has been a failure. It's time to try something new."

This will help us with prompts!

PreviousDebateNextFrom debates to prompts

Last updated 2 years ago