ArgMap

On this page

  • Import Modules and Setup Environment
  • Load Dataset
  • Initialize Language Model
  • Generate Arguments
    • Prompt Guidance for Argument Generation
  • Determine precise relationships between statements and arguments
    • Prompt Guidance to determine relationship
  • View source

Generate Arguments

Turn each set of statements into actionable insights
Author

Sonny Bhatia

Published

March 16, 2024

Import Modules and Setup Environment

Code
import os
from tqdm.notebook import tqdm

import polars as pl
from argmap.dataModel import Summary, Comments, Topics, HierarchicalTopics, Arguments, ArgumentCommentMap, DataModel

from dotenv import load_dotenv
load_dotenv()

# this allows categorical data from various sources to be combined and handled gracefully; performance cost is acceptable
pl.enable_string_cache()

EMBED_MODEL_ID = os.getenv("EMBED_MODEL_ID")
Code
import guidance
from guidance import select, instruction, user, assistant

from argmap.guidance import generate_line, generate_phrase

Load Dataset

Code
from IPython.display import display_markdown

DATASET = "american-assembly.bowling-green"
# "scoop-hivemind.biodiversity"
# "scoop-hivemind.freshwater"
# "scoop-hivemind.taxes"
# "scoop-hivemind.ubi"
# "scoop-hivemind.affordable-housing"
# "london.youth.policing"
# "canadian-electoral-reform"
# "brexit-consensus"
# "ssis.land-bank-farmland.2rumnecbeh.2021-08-01"

summary = Summary(DATASET)
comments = Comments(DATASET).load_from_parquet()
topics = Topics(DATASET).load_from_parquet()
hierarchicalTopics = HierarchicalTopics(DATASET).load_from_parquet()

display_markdown(f"""
### Dataset: {DATASET}
### {summary.topic}
### {summary.get('conversation-description')}
### Full Report: [{summary.url}]({summary.url})
""", raw=True)

Dataset: american-assembly.bowling-green

Improving Bowling Green / Warren County

What do you believe should change in Bowling Green/Warren County in order to make it a better place to live, work and spend time?

Full Report: https://pol.is/9wtchdmmun

Initialize Language Model

Code
import os
from argmap.helpers import getTorchDeviceVersion, loadLanguageModel

CUDA_MINIMUM_MEMORY_GB = os.getenv("CUDA_MINIMUM_MEMORY_GB")
MODEL_ID = os.getenv("MODEL_ID")
MODEL_REVISION = os.getenv("MODEL_REVISION")

if MODEL_ID is None:
    raise Exception("MODEL_ID environment variable is required.")

print(getTorchDeviceVersion())

languageModel = loadLanguageModel(MODEL_ID, MODEL_REVISION, CUDA_MINIMUM_MEMORY_GB)
Device: NVIDIA H100 PCIe
Python: 3.11.7 | packaged by conda-forge | (main, Dec 23 2023, 14:43:09) [GCC 12.3.0]
PyTorch: 2.2.1
CUDA: 12.1
CUDNN: 8902

Initializing language model: TheBloke/Mixtral-8x7B-Instruct-v0.1-GPTQ gptq-4bit-32g-actorder_True...
Language model initialized.
CUDA Memory: 52.0 GB free, 26.2 GB allocated, 79.1 GB total

Generate Arguments

Prompt Guidance for Argument Generation

Here, we only feed “agreeable comments” to the language model context to aid generation. Agreeable comments are based on an agreeability factor defined as:

\[ agreeability = \frac{likes}{likes + dislikes} \]

We only consider comments above an agreeability threshold of 0.5 as agreeable comments. These comments have more agree votes than disagree votes.

Code
@guidance
def generate_topic_arguments(lm, summary, topic, agreeableComments, argumentCount, arguments, temperature=0, progress_bar=None):

    if progress_bar:
        lm.echo = False

    with instruction():
        lm += f"""\
        First, identify unique areas of improvement from the statements.
        Then for each area, list the associated problems and the requested action from the statements. If no ACTIONABLE SOLUTIONS are present, output None.
        Using the problem, proposed action, and the statements, create unique, short, and convincing one-sentence arguments that urges the leaders for change or improvement.
        Avoid repetitive phrases.

        DISCUSSION QUESTION: {summary.get('conversation-description')}

        """

        lm += f"""\
        TOPIC: {topic['Title']}
        KEYWORDS: {', '.join(topic['Representation'])}

        STATEMENTS:
        """

        for commentId, commentText, agrees, disagrees in agreeableComments.select('commentId', 'commentText', 'agrees', 'disagrees').iter_rows():
            lm += f"{commentId}. {commentText} ({int(agrees * 100 / (agrees + disagrees))}% voters agree)\n"

        lm += f"""
        ---
        PROBLEMS IDENTIFIED: <comma-separated list of problems from the statements>
        ACTIONABLE SOLUTIONS: <comma-separated list of actionable solution from the statements, if any>
        ARGUMENT: <make a compelling argument in one sentence that urges the need for action>
        ARGUMENT LABEL: <short three word label that describes the argument>
        """

    with user():
        lm += f"List the {argumentCount} most important areas of improvements from these statements, each on a new line.\n"

    areasOfImprovement = []
    with assistant():
        for i in range(argumentCount):
            lm += "- " + generate_line('areaOfImprovement', temperature) + "\n"
            areasOfImprovement.append(lm['areaOfImprovement'])

    # for each keyword, generate an argument
    for argumentId, area in enumerate(areasOfImprovement):
        with user():
            lm += f"""\
            AREA OF IMPROVEMENT: {area}
            """

    # for i in range(argumentCount):
        with assistant():
            lm += f"""\
            PROBLEMS IDENTIFIED: {generate_phrase('problem', temperature, 100)}
            ACTIONABLE SOLUTIONS: {generate_phrase('solution', temperature, 100)}
            ARGUMENT: {generate_line('argument', temperature, 100)}
            ARGUMENT LABEL: {generate_phrase('argumentTitle', temperature, 20)}
            """

            arguments.addRow({
                'topicId': topic['Topic'],
                'argumentId': argumentId,
                'argumentTitle': lm['argumentTitle'],
                'argumentContent': lm['argument'],
                'thoughts': [[
                    f"AREA: {area}",
                    f"PROBLEMS: {lm['problem']}",
                    f"SOLUTIONS: {lm['solution']}"
                ]]
            })

            if progress_bar:
                progress_bar.update()

    return lm
Code
import math

agreeabilityThreshold = 0

topicId = 7

arguments = Arguments(DATASET).initialize()

agreeableComments = comments.df.filter(pl.col('topicId') == topicId, pl.col('agreeability') > agreeabilityThreshold).sort('agreeability', descending=True)

args = {
    'summary': summary,
    'topic': topics.get(topicId),
    'agreeableComments': agreeableComments,
    'argumentCount': 0,
    'arguments': arguments,
}

args['argumentCount'] = math.ceil(math.log(len(args['agreeableComments'])) * 2)

lm = languageModel + generate_topic_arguments(**args)
instruction
First, identify unique areas of improvement from the statements. Then for each area, list the associated problems and the requested action from the statements. If no ACTIONABLE SOLUTIONS are present, output None. Using the problem, proposed action, and the statements, create unique, short, and convincing one-sentence arguments that urges the leaders for change or improvement. Avoid repetitive phrases. DISCUSSION QUESTION: What do you believe should change in Bowling Green/Warren County in order to make it a better place to live, work and spend time? TOPIC: Bowling Green Community Enrichment Center: A Multi-Purpose Hub for Sports, Arts, and Learning KEYWORDS: museum, complex, community, university, sports, concerts, youth, programs, art, activities STATEMENTS: 748. There should be more cooperation between WKU and Bowling Green, especially for things like internships and community involvement. (93% voters agree) 181. The university and city should develop stronger mutually beneficial partnerships. (88% voters agree) 693. Bowling Green needs more accessible programs for mentorships of young adults and teenagers. (87% voters agree) 315. Local food and small farms are one of BG best attractions. (86% voters agree) 891. After school activity centers for youth with later hours of operation. (86% voters agree) 70. More concerts should be held in Bowling Green (86% voters agree) 187. Better incorporation of university resources in community, including Kentucky Museum. (85% voters agree) 410. There are no public adult swim facilities in Bowling Green for year around physical use. The Lovers Lane Complex should be made available (85% voters agree) 180. Bowling Green needs Community Enrichment Classes that include woodworking, welding, gardening and general home beautification for hobbyist. (85% voters agree) 285. Bowling Green should try to emulate Owensboro's Friday night programs downtown. (84% voters agree) 138. Publicizing more cultural activities other than the Bowling Green International Festival. (83% voters agree) 158. SKYPAC needs to bring in younger, more entertaining acts. It will fall apart if they keep only catering to 50+. Could be a great venue. (83% voters agree) 542. Indoor swimming pools for public use and therapy year around without time restrictions due to special swim leagues. Encourage healthier life (83% voters agree) 256. BG needs more Summer weekend festivals/activities (82% voters agree) 190. Institute a business development grant that encourages WKU grads to stay in Bowling Green by starting local businesses. (81% voters agree) 56. We need more things to do for ages 1-6. A children’s museum or a small science museum would be wonderful. (81% voters agree) 857. BG's Kummer Little gym is open limited hours for indoor track. On other hand, County has new gyms that are open lots of hrs. Inequitable. (80% voters agree) 744. We need more activities/places to go for teenagers; basically all there is are places to eat, the mall, and the bowling alley (79% voters agree) 226. The WKU Nursing Program should be expanded so we have more nurses (79% voters agree) 15. WKU and local community colleges should continue to offer courses that interest those seeking an education, whether or not the courses aid in job placement. (78% voters agree) 37. More youth programs are needed to bring the community together: volunteer organizations, community service, innovative creations labs (78% voters agree) 745. In order to combat teen pregnancy and STD rates, high schools in Bowling Green should offer comprehensive, medically accurate sex education. (77% voters agree) 43. I would like to see the WKU psych and Medical programs collaborate on mental health research, which is so sadly lacking in today's society. (77% voters agree) 314. BG can link/support hotel/food, recreational/cultural venues in a Tourism Passport, giving discounts when at least 3 are purchased together. (76% voters agree) 608. Bowling Green needs more cultural and educational establishments, like sciemce, history and art museums. (75% voters agree) 347. Take advantage of the wonderful summers in KY and have more outdoor public swimming spaces (75% voters agree) 469. The Kentucky Career Center on Chestnut is a great resource to locate employment. (75% voters agree) 63. WKU should upgrade their CIT program to keep up with the times (72% voters agree) 639. Need engaging art installations throughout the city. People will be able to experience art, have fun, and share on social media. (71% voters agree) 221. Bowling Green's refugee, immigrant, and international student population improves the university and the community. (68% voters agree) 72. We need more activities for families, such as a large-scale all-in-one kids play arena like All About Kids. (65% voters agree) 635. Concerts and performing arts activities must reflect the diverse racial/ethnic demographic of the city/county. (65% voters agree) 514. BG can’t compete with Nashville or Louisville for young professionals (64% voters agree) 287. parks and rec should promote and support pickleball for older citizens (60% voters agree) 231. Bowling Green has many excellent non-public schools; more should be done to make these options available to diverse and low-income families. (55% voters agree) 400. Bowling Green needs an indoor / outdoor sports event complex/ (54% voters agree) 28. Cutting a major sports program would be the best way for WKU to deal with budget cuts without harming academics. (52% voters agree) 319. Bowling Green is in need of an ice rink for recreation and sport. (52% voters agree) 428. Bowling Green needs more indoor sports facilities, particularly a large complex with multiple indoor soccer fields, for youth. (51% voters agree) --- PROBLEMS IDENTIFIED: <comma-separated list of problems from the statements> ACTIONABLE SOLUTIONS: <comma-separated list of actionable solution from the statements, if any> ARGUMENT: <make a compelling argument in one sentence that urges the need for action> ARGUMENT LABEL: <short three word label that describes the argument>
user
List the 8 most important areas of improvements from these statements, each on a new line.
assistant
- Cooperation between WKU and Bowling Green for community involvement and internships - Accessible mentorship programs for young adults and teenagers - Community enrichment classes and activities, including woodworking, welding, gardening, and home beautification - More after-school activity centers for youth with extended hours of operation - Increased number of concerts held in Bowling Green - Better incorporation of university resources in community, including Kentucky Museum - Public adult swim facilities for year-round physical use - More activities and places to go for teenagers
user
AREA OF IMPROVEMENT: Cooperation between WKU and Bowling Green for community involvement and internships
assistant
PROBLEMS IDENTIFIED: Lack of cooperation and partnership between WKU and Bowling Green, limited opportunities for community involvement and internships for students ACTIONABLE SOLUTIONS: Strengthening mutually beneficial partnerships between WKU and Bowling Green, increasing cooperation for community involvement and internships ARGUMENT: Strengthening WKU-Bowling Green partnerships will create more community involvement and internship opportunities, benefiting both students and the local community. ARGUMENT LABEL: Boosting student opportunities and community involvement
user
AREA OF IMPROVEMENT: Accessible mentorship programs for young adults and teenagers
assistant
PROBLEMS IDENTIFIED: Limited accessible mentorship programs for young adults and teenagers in Bowling Green ACTIONABLE SOLUTIONS: Developing and promoting mentorship programs targeting young adults and teenagers ARGUMENT: Implementing accessible mentorship programs for young adults and teenagers will foster personal growth and skill development, addressing a critical need in Bowling Green. ARGUMENT LABEL: Nurturing young talent
user
AREA OF IMPROVEMENT: Community enrichment classes and activities, including woodworking, welding, gardening, and home beautification
assistant
PROBLEMS IDENTIFIED: Limited community enrichment classes and activities in Bowling Green, particularly in woodworking, welding, gardening, and home beautification ACTIONABLE SOLUTIONS: Establishing and promoting community enrichment classes and activities that cater to various interests and hobbies ARGUMENT: Introducing diverse community enrichment classes and activities will cater to various interests, enhancing the overall quality of life in Bowling Green. ARGUMENT LABEL: Diversifying community enrichment
user
AREA OF IMPROVEMENT: More after-school activity centers for youth with extended hours of operation
assistant
PROBLEMS IDENTIFIED: Insufficient after-school activity centers for youth with limited hours of operation in Bowling Green ACTIONABLE SOLUTIONS: Developing and expanding after-school activity centers with extended hours of operation ARGUMENT: Providing more after-school activity centers with extended hours will offer youth safe, engaging, and educational spaces beyond traditional school hours. ARGUMENT LABEL: Expanding youth opportunities
user
AREA OF IMPROVEMENT: Increased number of concerts held in Bowling Green
assistant
PROBLEMS IDENTIFIED: Limited concert offerings in Bowling Green ACTIONABLE SOLUTIONS: Organizing and promoting a wider variety of concerts appealing to diverse tastes ARGUMENT: Increasing concert offerings in Bowling Green will cater to various musical preferences, fostering a more vibrant local arts scene. ARGUMENT LABEL: Cultivating a vibrant arts scene
user
AREA OF IMPROVEMENT: Better incorporation of university resources in community, including Kentucky Museum
assistant
PROBLEMS IDENTIFIED: Limited utilization of WKU resources in the Bowling Green community, particularly the Kentucky Museum ACTIONABLE SOLUTIONS: Enhancing collaboration between WKU and Bowling Green to better incorporate university resources, including the Kentucky Museum, into community life ARGUMENT: Leveraging WKU resources, such as the Kentucky Museum, will enrich Bowling Green's cultural landscape and strengthen community-university ties. ARGUMENT LABEL: Bridging community and campus
user
AREA OF IMPROVEMENT: Public adult swim facilities for year-round physical use
assistant
PROBLEMS IDENTIFIED: Limited public adult swim facilities available year-round for physical use in Bowling Green ACTIONABLE SOLUTIONS: Establishing and promoting public adult swim facilities with year-round access ARGUMENT: Introducing public adult swim facilities with year-round access will encourage healthier lifestyles and enhance overall well-being in Bowling Green. ARGUMENT LABEL: Promoting healthier lifestyles
user
AREA OF IMPROVEMENT: More activities and places to go for teenagers
assistant
PROBLEMS IDENTIFIED: Insufficient activities and places for teenagers in Bowling Green ACTIONABLE SOLUTIONS: Developing and promoting engaging activities and spaces tailored to teenagers ARGUMENT: Providing more activities and places for teenagers will offer safe, enjoyable, and enriching experiences, addressing a critical need in Bowling Green. ARGUMENT LABEL: Engaging teenagers

Determine precise relationships between statements and arguments

Code
# TODO: use different prompts to experimentally calculate the usefulness of these relationships
# embeddings provide a baseline for similarity
# how to determine what relationships are useful? diversity?
# most relationships indicate support. Is that because the comments are generally supportive?
# what would change if the options are listed in a different order?

# The support / refute / undercut relationships in the previous run do not appear to be reflected accurately in some cases. In the following attempt, we ask the language model to visit each argument, explain which comment it supports and why. We run this indiviudally in a fresh context to limit any bias from unrelated text.

# In the following generation, the initial content and arguments are placed in the overall context. Then each comment is evaluated in its own context that includes a copy of the initial text. This context is reset after evaluating each comment and not carried over to the next comment.

Prompt Guidance to determine relationship

Code
# @guidance
# def generate_argument_relation(lm, discussionTitle, discussionQuestion, topicId, topic, comments, topicArguments, argumentCommentMap, context_reset=False, temperature=0, echo=True, progress_bar=None):
#     lm.echo = echo

#     with instruction():
#         lm += f"""\
#         The following set of statements is from an online discussion about {discussionTitle} conducted on a discussion platform Polis.
#         There are total of {len(topicArguments)} arguments and {len(comments)} statements in this dataset.
#         For each of the following statements, select an argument that is most relevant to the comment.
#         Then express your thoughts about which relationships might apply: SUPPORT, REFUTE, UNRELATED. If a relationship does not apply, simply state that.
#         Then finally pick the most likely relationship between the statement and the argument: "SUPPORT" or "REFUTE".
#         If the statement and argument are not related, state "UNRELATED".
#         """
#         # For each given statement, identify the most relevant argument. Then identify the relationship between the argument and the statement.

#     with user():
#         lm += f"""\
#         Discussion Subject: {discussionQuestion}
#         Topic: {topic['CustomName']}
#         Topic Keywords: {', '.join(topic['Representation'])}

#         ARGUMENTS:
#         """

#         for argument, title, content in topicArguments.select('argumentId', 'argumentTitle', 'argumentContent').iter_rows():
#             lm += f"""
#             Argument {argument}: {title}
#             {content}
#             """

#     for commentRow in comments.select('commentId', 'commentText', 'agrees', 'disagrees').iter_rows(named=True):
#         if context_reset:
#             lm + generate_argument_relation_reasoning(commentRow, topicId, topicArguments, argumentCommentMap, temperature=temperature, echo=echo)
#         else:
#             lm = lm + generate_argument_relation_reasoning(commentRow, topicId, topicArguments, argumentCommentMap, temperature=temperature, echo=echo)
#         if progress_bar:
#             progress_bar.update(1)

#     return lm
Code
# commentCount = comments.df.filter(pl.col('moderated') == 1).get_column('topicId').value_counts().sort('topicId').get_column('count').to_numpy()
# argCount = arguments.df.get_column('topicId').value_counts().sort('topicId').get_column('count').to_numpy()
# np.dot(commentCount, argCount)

arguments = Arguments(DATASET).load_from_parquet()
arguments.glimpse()
Rows: 102
Columns: 5
$ topicId               <u16> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
$ argumentId            <u16> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
$ argumentTitle         <str> 'Occupational Tax for Homeless Support', 'Affordable Housing and Property Ownership', 'Strong Landlord-Tenant Laws', 'Term Limits for Fair Representation', 'Police Presence in County Areas', 'Grocery Store Competition', 'Tenant Support in Downtown District', 'Diversity in City/County Government', 'Poverty Reduction and Elderly Support', 'Rental Assistance and Affordability'
$ argumentContent       <str> 'Implement a small occupational tax on businesses to fund temporary housing and support services for the homeless, creating a safer and more prosperous community for all.', 'Increase affordable housing options and enforce stronger landlord/tenant laws to preserve neighborhoods and promote responsible property ownership.', 'Establish stronger tenant and renter rights, enforce leash laws, and encourage property maintenance to preserve neighborhoods and ensure quality housing.', 'Implement term limits for local elected officials to promote fair representation, prevent misuse of power, and encourage fresh perspectives.', 'Increase police presence and resources in county areas to ensure public safety and address domestic violence disputes effectively.', 'Introduce new grocery stores to increase competition, lower prices, and improve quality for consumers.', 'Offer resources, training, and support for downtown tenants to enhance their business skills, promote success, and reduce turnover.', 'Promote racial and ethnic diversity in city/county government to enhance representation, recruitment, and growth.', 'Establish affordable support programs and job training initiatives to reduce poverty and support the elderly and low-income residents.', 'Introduce rent control laws, create quality affordable rental units, and offer rental assistance programs to address high rental prices and limited options.'
$ thoughts        <list[str]> ['AREA: Implementing Occupational Taxes to Address Homelessness', 'PROBLEMS: Homelessness is becoming an issue in Bowling Green/Warren County, affecting the community and local businesses', 'SOLUTIONS: Building a homeless park with tiny homes, providing temporary housing connected to aid agencies, and implementing a tax on businesses to fund these initiatives'], ['AREA: Affordable housing options', 'PROBLEMS: Limited affordable housing options, older neighborhoods changing from owner-occupied to rental, and deterioration of properties', 'SOLUTIONS: Creating more affordable home ownership options, enforcing stricter landlord/tenant laws, and encouraging property maintenance'], ['AREA: Stronger landlord/tenant laws', 'PROBLEMS: Deterioration of older neighborhoods, lack of landlord accountability, and overpriced dilapidated rentals', 'SOLUTIONS: Implementing stronger tenant and renter rights, enforcing leash laws, and promoting better property maintenance'], ['AREA: Term limits for local elected officials', 'PROBLEMS: Concerns about local elected officials holding onto power and influence', 'SOLUTIONS: Implementing term limits for local elected officials to ensure fair representation and prevent misuse of power'], ['AREA: Increased police presence in county areas', 'PROBLEMS: Insufficient police presence in county areas, particularly for domestic violence disputes', 'SOLUTIONS: Increasing police presence and resources in county areas to ensure public safety'], ['AREA: Grocery store competition', 'PROBLEMS: Lack of competition among grocery stores, leading to higher prices and lower quality', 'SOLUTIONS: Encouraging new grocery stores, such as Publix, to enter the market and promote competition'], ['AREA: Better tenant support in downtown district', 'PROBLEMS: High turnover of tenants in the downtown district due to lack of business skills', 'SOLUTIONS: Providing resources, training, and support for tenants in the downtown district to improve their business skills and increase success'], ['AREA: Racial/ethnic diversity in city/county government', 'PROBLEMS: Lack of racial and ethnic diversity in city/county government, affecting representation and growth', 'SOLUTIONS: Encouraging diversity in city/county government through recruitment and outreach efforts'], ['AREA: Reducing poverty and supporting the elderly', 'PROBLEMS: High poverty levels, insufficient support for the elderly and aging population', 'SOLUTIONS: Implementing affordable support programs for the elderly and low-income residents, and creating job training programs'], ['AREA: Rental assistance programs', 'PROBLEMS: High rental prices, lack of affordable rental options, and insufficient rental assistance programs', 'SOLUTIONS: Implementing rent control laws, creating more quality affordable rental units, and offering rental assistance programs']
Code
@guidance
def guidance_topic_correlate(lm, topicId, topicComments, topicArguments, argumentCommentMap, thought=False, reason=False, context_reset=True, temperature=0, progress_bar=None):

    if progress_bar is not None:
        lm.echo = False

    with instruction():
        lm += f"""\
        You will be presented a statement and an argument. Statement is a user-generated comment from a discussion. Argument is an actionable solution.

        TASK: Determine whether the statement supports, refutes, or is unrelated to the argument.
        SUPPORT: The argument is consistent with the statement. A person who agrees with the statement will definitely support the argument.
        REFUTE: The argument goes against the statement. A person who agrees with the statement will definitely with the argument.
        UNRELATED: The statement and argument are not directly related. Implementing the argument will not directly address the underlying issue.

        ---
        OUTPUT FORMAT
        THOUGHT: Deliberate on how strongly a person who agrees with the statement will support the argument.
        RELATIONSHIP: One of the following: SUPPORT, REFUTE, UNRELATED
        REASON: Provide a reason for your choice.
        """

    # iterate over each argument
    for argumentId, argumentTitle, argumentContent in topicArguments.select('argumentId', 'argumentTitle', 'argumentContent').iter_rows():
        args = {
            'topicId': topicId,
            'argumentId': argumentId,
            'argumentTitle': argumentTitle,
            'argumentContent': argumentContent,
            'topicComments': topicComments,
            'argumentCommentMap': argumentCommentMap,
            'thought': thought,
            'reason': reason,
            'temperature': temperature,
            'context_reset': context_reset,
            'progress_bar': progress_bar,
        }
        if context_reset:
            lm + guidance_argument_correlate(**args)
        else:
            lm += guidance_argument_correlate(**args)

    return lm


@guidance
def guidance_argument_correlate(lm, topicId, argumentId, argumentTitle, argumentContent, topicComments, argumentCommentMap, thought=False, reason=False, temperature=0, context_reset=True, progress_bar=None):
    with user():
        lm = lm + f"""\
        ARGUMENT {argumentId}: {argumentTitle}
        {argumentContent}
        """

    # iterate over each comment
    for commentId, commentText, in topicComments.select('commentId', 'commentText').iter_rows():
        args = {
            'topicId': topicId,
            'argumentId': argumentId,
            'commentId': commentId,
            'commentText': commentText,
            'argumentCommentMap': argumentCommentMap,
            'thought': thought,
            'reason': reason,
            'temperature': temperature,
        }
        if context_reset:
            lm + guidance_comment_correlate(**args)
        else:
            lm += guidance_comment_correlate(**args)

        if progress_bar is not None:
            progress_bar.update()

    return lm


@guidance
def guidance_comment_correlate(lm, topicId, argumentId, commentId, commentText, argumentCommentMap, thought=False, reason=False, temperature=0):
    with user():
        lm += f"""\
        STATEMENT {commentId}: {commentText}
        """

    with assistant():

        reasoning = []
        if thought:
            lm += f"THOUGHT: {generate_line('thought', temperature, 100)}\n"
            reasoning.append(f"THOUGHT: {lm['thought']}")

        lm += f"RELATIONSHIP: {select(['SUPPORT', 'REFUTE', 'UNRELATED'], name='relationship')}\n"
        relationship = lm['relationship']

        if reason and not relationship == 'UNRELATED':
            lm += f"REASON: {generate_line('reasoning', temperature, 100)}"
            reasoning.append(f"REASON: {lm['reasoning']}")

        argumentCommentMap.addRow({
            'commentId': commentId,
            'topicId': topicId,
            'argumentId': argumentId,
            'relationship': lm['relationship'],
            'reasoning': [reasoning],
        })

    return lm
Code
argumentCommentMap = ArgumentCommentMap(DATASET).initialize()

topicId = 7

topicComments = comments.df.filter(pl.col('topicId') == topicId)
topicArguments = arguments.df.filter((pl.col('topicId') == topicId) & (pl.col('argumentId') == 6))

args = {
    'topicId': topicId,
    'topicComments': topicComments,
    'topicArguments': topicArguments,
    'argumentCommentMap': argumentCommentMap,
    'context_reset': False,
    'thought': True,
    'reason': True,
}

languageModel + guidance_topic_correlate(**args)
instruction
You will be presented a statement and an argument. Statement is a user-generated comment from a discussion. Argument is an actionable solution. TASK: Determine whether the statement supports, refutes, or is unrelated to the argument. SUPPORT: The argument is consistent with the statement. A person who agrees with the statement will definitely support the argument. REFUTE: The argument goes against the statement. A person who agrees with the statement will definitely with the argument. UNRELATED: The statement and argument are not directly related. Implementing the argument will not directly address the underlying issue. --- OUTPUT FORMAT THOUGHT: Deliberate on how strongly a person who agrees with the statement will support the argument. RELATIONSHIP: One of the following: SUPPORT, REFUTE, UNRELATED REASON: Provide a reason for your choice.
user
ARGUMENT 6: Active Community Enhancing indoor sports facilities would encourage physical activity, promote teamwork, and cater to diverse athletic interests.
user
STATEMENT 891: After school activity centers for youth with later hours of operation.
assistant
THOUGHT: A person who agrees with the statement would likely support the argument, as later hours of operation for activity centers would provide more opportunities for youth to engage in physical activity and potentially participate in indoor sports. RELATIONSHIP: SUPPORT REASON: Later hours of operation for activity centers align with the argument's goal of enhancing indoor sports facilities and promoting physical activity.
user
STATEMENT 857: BG's Kummer Little gym is open limited hours for indoor track. On other hand, County has new gyms that are open lots of hrs. Inequitable.
assistant
THOUGHT: A person who agrees with the statement may refute the argument, as they might perceive the unequal access to indoor sports facilities as an issue that needs to be addressed before enhancing existing facilities. RELATIONSHIP: REFUTE REASON: The argument focuses on improving existing facilities, while the statement highlights the inequity between different facilities, which might be seen as a more pressing concern.
user
STATEMENT 693: Bowling Green needs more accessible programs for mentorships of young adults and teenagers.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need for mentorship programs for young adults and teenagers. RELATIONSHIP: UNRELATED
user
STATEMENT 639: Need engaging art installations throughout the city. People will be able to experience art, have fun, and share on social media.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need for engaging art installations throughout the city. RELATIONSHIP: UNRELATED
user
STATEMENT 635: Concerts and performing arts activities must reflect the diverse racial/ethnic demographic of the city/county.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need for diverse racial/ethnic representation in concerts and performing arts activities. RELATIONSHIP: UNRELATED
user
STATEMENT 608: Bowling Green needs more cultural and educational establishments, like sciemce, history and art museums.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need for more cultural and educational establishments, such as science, history, and art museums. RELATIONSHIP: UNRELATED
user
STATEMENT 542: Indoor swimming pools for public use and therapy year around without time restrictions due to special swim leagues. Encourage healthier life
assistant
THOUGHT: A person who agrees with the statement would likely support the argument, as the enhancement of indoor sports facilities, including swimming pools, aligns with the goal of promoting physical activity and healthier lifestyles. RELATIONSHIP: SUPPORT REASON: Indoor swimming pools address the need for year-round physical activity opportunities, which is consistent with the argument's objective of enhancing indoor sports facilities.
user
STATEMENT 514: BG can’t compete with Nashville or Louisville for young professionals
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the competitiveness of Bowling Green in attracting young professionals compared to larger cities like Nashville or Louisville. RELATIONSHIP: UNRELATED
user
STATEMENT 428: Bowling Green needs more indoor sports facilities, particularly a large complex with multiple indoor soccer fields, for youth.
assistant
THOUGHT: A person who agrees with the statement would likely support the argument, as the enhancement of indoor sports facilities, including indoor soccer fields, aligns with their desire for more indoor sports facilities catering to youth. RELATIONSHIP: SUPPORT REASON: The argument's focus on enhancing indoor sports facilities is consistent with the statement's desire for more indoor soccer fields for youth.
user
STATEMENT 410: There are no public adult swim facilities in Bowling Green for year around physical use. The Lovers Lane Complex should be made available
assistant
THOUGHT: A person who agrees with the statement would likely support the argument, as the enhancement of indoor sports facilities, including adult swim facilities, aligns with their desire for year-round physical activity opportunities. RELATIONSHIP: SUPPORT REASON: The argument's focus on enhancing indoor sports facilities is consistent with the statement's desire for public adult swim facilities in Bowling Green.
user
STATEMENT 408: BG needs an indoor tennis option
assistant
THOUGHT: A person who agrees with the statement would likely support the argument, as the enhancement of indoor sports facilities, including indoor tennis options, aligns with their desire for more indoor sports facilities. RELATIONSHIP: SUPPORT REASON: The argument's focus on enhancing indoor sports facilities is consistent with the statement's desire for an indoor tennis option in Bowling Green.
user
STATEMENT 400: Bowling Green needs an indoor / outdoor sports event complex/
assistant
THOUGHT: A person who agrees with the statement would likely support the argument, as the enhancement of indoor sports facilities, including an indoor/outdoor sports event complex, aligns with their desire for more indoor sports facilities. RELATIONSHIP: SUPPORT REASON: The argument's focus on enhancing indoor sports facilities is consistent with the statement's desire for an indoor/outdoor sports event complex in Bowling Green.
user
STATEMENT 748: There should be more cooperation between WKU and Bowling Green, especially for things like internships and community involvement.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need for more cooperation between WKU and Bowling Green, especially for things like internships and community involvement. RELATIONSHIP: UNRELATED
user
STATEMENT 745: In order to combat teen pregnancy and STD rates, high schools in Bowling Green should offer comprehensive, medically accurate sex education.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need for comprehensive, medically accurate sex education in high schools to combat teen pregnancy and STD rates. RELATIONSHIP: UNRELATED
user
STATEMENT 744: We need more activities/places to go for teenagers; basically all there is are places to eat, the mall, and the bowling alley
assistant
THOUGHT: A person who agrees with the statement would likely support the argument, as the enhancement of indoor sports facilities provides more activities and places for teenagers to go, addressing their desire for more options beyond eating, shopping, and bowling. RELATIONSHIP: SUPPORT REASON: The argument's focus on enhancing indoor sports facilities is consistent with the statement's desire for more activities and places for teenagers in Bowling Green.
user
STATEMENT 347: Take advantage of the wonderful summers in KY and have more outdoor public swimming spaces
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need for more outdoor public swimming spaces during the wonderful summers in Kentucky. RELATIONSHIP: UNRELATED
user
STATEMENT 319: Bowling Green is in need of an ice rink for recreation and sport.
assistant
THOUGHT: A person who agrees with the statement would likely support the argument, as the enhancement of indoor sports facilities, including an ice rink, aligns with their desire for more indoor sports facilities. RELATIONSHIP: SUPPORT REASON: The argument's focus on enhancing indoor sports facilities is consistent with the statement's desire for an ice rink in Bowling Green.
user
STATEMENT 315: Local food and small farms are one of BG best attractions.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need to support local food and small farms, which are considered one of Bowling Green's best attractions. RELATIONSHIP: UNRELATED
user
STATEMENT 314: BG can link/support hotel/food, recreational/cultural venues in a Tourism Passport, giving discounts when at least 3 are purchased together.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need to link and support hotels, food, recreational, and cultural venues through a Tourism Passport, offering discounts when at least three are purchased together. RELATIONSHIP: UNRELATED
user
STATEMENT 287: parks and rec should promote and support pickleball for older citizens
assistant
THOUGHT: A person who agrees with the statement would likely support the argument, as the enhancement of indoor sports facilities, including those catering to older citizens, aligns with their desire for more sports facilities and activities. RELATIONSHIP: SUPPORT REASON: The argument's focus on enhancing indoor sports facilities is consistent with the statement's desire for parks and recreation to promote and support pickleball for older citizens.
user
STATEMENT 285: Bowling Green should try to emulate Owensboro's Friday night programs downtown.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need to emulate Owensboro's Friday night programs downtown. RELATIONSHIP: UNRELATED
user
STATEMENT 256: BG needs more Summer weekend festivals/activities
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need for more Summer weekend festivals and activities in Bowling Green. RELATIONSHIP: UNRELATED
user
STATEMENT 231: Bowling Green has many excellent non-public schools; more should be done to make these options available to diverse and low-income families.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need to make excellent non-public school options more accessible to diverse and low-income families in Bowling Green. RELATIONSHIP: UNRELATED
user
STATEMENT 226: The WKU Nursing Program should be expanded so we have more nurses
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need to expand the WKU Nursing Program to have more nurses in Bowling Green. RELATIONSHIP: UNRELATED
user
STATEMENT 221: Bowling Green's refugee, immigrant, and international student population improves the university and the community.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need to support and appreciate Bowling Green's refugee, immigrant, and international student population. RELATIONSHIP: UNRELATED
user
STATEMENT 190: Institute a business development grant that encourages WKU grads to stay in Bowling Green by starting local businesses.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need to institute a business development grant that encourages WKU grads to stay in Bowling Green by starting local businesses. RELATIONSHIP: UNRELATED
user
STATEMENT 187: Better incorporation of university resources in community, including Kentucky Museum.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need to better incorporate university resources, including the Kentucky Museum, in the community. RELATIONSHIP: UNRELATED
user
STATEMENT 181: The university and city should develop stronger mutually beneficial partnerships.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need to develop stronger mutually beneficial partnerships between the university and the city. RELATIONSHIP: UNRELATED
user
STATEMENT 180: Bowling Green needs Community Enrichment Classes that include woodworking, welding, gardening and general home beautification for hobbyist.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need for community enrichment classes that include woodworking, welding, gardening, and general home beautification for hobbyists in Bowling Green. RELATIONSHIP: UNRELATED
user
STATEMENT 469: The Kentucky Career Center on Chestnut is a great resource to locate employment.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need to utilize the Kentucky Career Center on Chestnut as a resource to locate employment in Bowling Green. RELATIONSHIP: UNRELATED
user
STATEMENT 158: SKYPAC needs to bring in younger, more entertaining acts. It will fall apart if they keep only catering to 50+. Could be a great venue.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need for SKYPAC to bring in younger, more entertaining acts to cater to a wider audience. RELATIONSHIP: UNRELATED
user
STATEMENT 138: Publicizing more cultural activities other than the Bowling Green International Festival.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need to publicize more cultural activities other than the Bowling Green International Festival. RELATIONSHIP: UNRELATED
user
STATEMENT 74: More advertising should be done along I-65 to promote tourism into Bowling Green.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need for more advertising along I-65 to promote tourism into Bowling Green. RELATIONSHIP: UNRELATED
user
STATEMENT 72: We need more activities for families, such as a large-scale all-in-one kids play arena like All About Kids.
assistant
THOUGHT: A person who agrees with the statement would likely support the argument, as the enhancement of indoor sports facilities provides more activities for families, including a large-scale all-in-one kids play arena like All About Kids. RELATIONSHIP: SUPPORT REASON: The argument's focus on enhancing indoor sports facilities is consistent with the statement's desire for more activities for families, such as a large-scale all-in-one kids play arena like All About Kids in Bowling Green.
user
STATEMENT 70: More concerts should be held in Bowling Green
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need for more concerts in Bowling Green. RELATIONSHIP: UNRELATED
user
STATEMENT 63: WKU should upgrade their CIT program to keep up with the times
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need for WKU to upgrade their CIT program to keep up with the times. RELATIONSHIP: UNRELATED
user
STATEMENT 56: We need more things to do for ages 1-6. A children’s museum or a small science museum would be wonderful.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need for more things to do for ages 1-6, such as a children's museum or a small science museum in Bowling Green. RELATIONSHIP: UNRELATED
user
STATEMENT 43: I would like to see the WKU psych and Medical programs collaborate on mental health research, which is so sadly lacking in today's society.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need for WKU psych and Medical programs to collaborate on mental health research. RELATIONSHIP: UNRELATED
user
STATEMENT 37: More youth programs are needed to bring the community together: volunteer organizations, community service, innovative creations labs
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need for more youth programs, such as volunteer organizations, community service, and innovative creations labs in Bowling Green. RELATIONSHIP: UNRELATED
user
STATEMENT 28: Cutting a major sports program would be the best way for WKU to deal with budget cuts without harming academics.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need to cut a major sports program at WKU to deal with budget cuts without harming academics. RELATIONSHIP: UNRELATED
user
STATEMENT 15: WKU and local community colleges should continue to offer courses that interest those seeking an education, whether or not the courses aid in job placement.
assistant
THOUGHT: A person who agrees with the statement might find the argument unrelated, as the enhancement of indoor sports facilities does not directly address the need for WKU and local community colleges to offer courses that interest those seeking an education, whether or not the courses aid in job placement. RELATIONSHIP: UNRELATED
 

© 2024 Aaditya Bhatia

  • View source