diff --git a/README.md b/README.md index eda27c6d6273755234d0de9730cfd2b0196c4391..6b1d288ce2ce16c0324fdd8e95bdf3bbd7f21632 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,9 @@ The figure below presents a violin plot depicting the share of the total amount that the dictator allocates to themselves for each model. The temperature is fixed at 0.7, and each experiment was conducted 30 times. The median share taken by GPT-4.5, Llama3, Mistral-Small, and DeepSeek-R1 is 50. +When we prompt the models to generate a strategy in the form of an algorithm implemented +in the Python programming language, rather than generating an action, all models divide +the amount fairly except for GPT-4.5, which takes approximately 70% of the total amount for itself. It is worth noticing that, under these standard conditions, humans typically keep an average of around \$80 (Fortsythe et al. 1994). It is interesting to note that the variability observed between different executions in the responses of the same LLM is comparable to the diversity of behaviors observed in humans. In other words, diff --git a/figures/dictator/dictator_violin.svg b/figures/dictator/dictator_violin.svg index 77a9572e78c9e1c5eb70b957568b6cee664f23d8..12890491d115908e2ac4e5bd09d0596d0178c678 100644 --- a/figures/dictator/dictator_violin.svg +++ b/figures/dictator/dictator_violin.svg @@ -6,7 +6,7 @@ <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> - <dc:date>2025-03-01T14:08:30.695368</dc:date> + <dc:date>2025-03-03T11:49:36.924462</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> @@ -39,7 +39,7 @@ z </g> <g id="FillBetweenPolyCollection_1"> <defs> - <path id="ma480fb88e3" d="M 133.84164 -203.558343 + <path id="mb3afe8fddc" d="M 133.84164 -203.558343 L 121.75836 -203.558343 L 120.37681 -204.102054 L 118.780793 -204.645764 @@ -244,13 +244,13 @@ L 133.84164 -203.558343 z " style="stroke: #414141; stroke-width: 1.25"/> </defs> - <g clip-path="url(#pe93128f28f)"> - <use xlink:href="#ma480fb88e3" x="0" y="432" style="fill: #8bbbee; stroke: #414141; stroke-width: 1.25"/> + <g clip-path="url(#p2023270996)"> + <use xlink:href="#mb3afe8fddc" x="0" y="432" style="fill: #8bbbee; stroke: #414141; stroke-width: 1.25"/> </g> </g> <g id="FillBetweenPolyCollection_2"> <defs> - <path id="md1e0e50296" d="M 239.861101 -118.843382 + <path id="md196ff7f99" d="M 239.861101 -118.843382 L 238.938899 -118.843382 L 238.826963 -120.426505 L 238.696385 -122.009629 @@ -455,13 +455,13 @@ L 239.861101 -118.843382 z " style="stroke: #414141; stroke-width: 1.25"/> </defs> - <g clip-path="url(#pe93128f28f)"> - <use xlink:href="#md1e0e50296" x="0" y="432" style="fill: #409884; stroke: #414141; stroke-width: 1.25"/> + <g clip-path="url(#p2023270996)"> + <use xlink:href="#md196ff7f99" x="0" y="432" style="fill: #409884; stroke: #414141; stroke-width: 1.25"/> </g> </g> <g id="FillBetweenPolyCollection_3"> <defs> - <path id="meca677ae51" d="M 357.050423 -195.383861 + <path id="mdf1ec7ad62" d="M 357.050423 -195.383861 L 344.949577 -195.383861 L 342.929587 -196.764713 L 340.47356 -198.145564 @@ -666,8 +666,8 @@ L 357.050423 -195.383861 z " style="stroke: #414141; stroke-width: 1.25"/> </defs> - <g clip-path="url(#pe93128f28f)"> - <use xlink:href="#meca677ae51" x="0" y="432" style="fill: #e77759; stroke: #414141; stroke-width: 1.25"/> + <g clip-path="url(#p2023270996)"> + <use xlink:href="#mdf1ec7ad62" x="0" y="432" style="fill: #e77759; stroke: #414141; stroke-width: 1.25"/> </g> </g> <g id="FillBetweenPolyCollection_4"> @@ -874,18 +874,18 @@ L 465.456135 481.711006 L 464.869772 487.259449 L 464.386676 492.807891 z -" clip-path="url(#pe93128f28f)" style="fill: #6b72da; stroke: #414141; stroke-width: 1.25"/> +" clip-path="url(#p2023270996)" style="fill: #6b72da; stroke: #414141; stroke-width: 1.25"/> </g> <g id="matplotlib.axis_1"> <g id="xtick_1"> <g id="line2d_1"> <defs> - <path id="m7b56ee45b8" d="M 0 0 + <path id="mbc7c3642a9" d="M 0 0 L 0 3.5 " style="stroke: #000000; stroke-width: 0.8"/> </defs> <g> - <use xlink:href="#m7b56ee45b8" x="127.8" y="384.48" style="stroke: #000000; stroke-width: 0.8"/> + <use xlink:href="#mbc7c3642a9" x="127.8" y="384.48" style="stroke: #000000; stroke-width: 0.8"/> </g> </g> <g id="text_1"> @@ -1200,7 +1200,7 @@ z <g id="xtick_2"> <g id="line2d_2"> <g> - <use xlink:href="#m7b56ee45b8" x="239.4" y="384.48" style="stroke: #000000; stroke-width: 0.8"/> + <use xlink:href="#mbc7c3642a9" x="239.4" y="384.48" style="stroke: #000000; stroke-width: 0.8"/> </g> </g> <g id="text_2"> @@ -1322,7 +1322,7 @@ z <g id="xtick_3"> <g id="line2d_3"> <g> - <use xlink:href="#m7b56ee45b8" x="351" y="384.48" style="stroke: #000000; stroke-width: 0.8"/> + <use xlink:href="#mbc7c3642a9" x="351" y="384.48" style="stroke: #000000; stroke-width: 0.8"/> </g> </g> <g id="text_3"> @@ -1380,7 +1380,7 @@ z <g id="xtick_4"> <g id="line2d_4"> <g> - <use xlink:href="#m7b56ee45b8" x="462.6" y="384.48" style="stroke: #000000; stroke-width: 0.8"/> + <use xlink:href="#mbc7c3642a9" x="462.6" y="384.48" style="stroke: #000000; stroke-width: 0.8"/> </g> </g> <g id="text_4"> @@ -1510,12 +1510,12 @@ z <g id="ytick_1"> <g id="line2d_5"> <defs> - <path id="ma889274d09" d="M 0 0 + <path id="m92550bfb1a" d="M 0 0 L -3.5 0 " style="stroke: #000000; stroke-width: 0.8"/> </defs> <g> - <use xlink:href="#ma889274d09" x="72" y="384.48" style="stroke: #000000; stroke-width: 0.8"/> + <use xlink:href="#m92550bfb1a" x="72" y="384.48" style="stroke: #000000; stroke-width: 0.8"/> </g> </g> <g id="text_6"> @@ -1528,7 +1528,7 @@ L -3.5 0 <g id="ytick_2"> <g id="line2d_6"> <g> - <use xlink:href="#ma889274d09" x="72" y="317.952" style="stroke: #000000; stroke-width: 0.8"/> + <use xlink:href="#m92550bfb1a" x="72" y="317.952" style="stroke: #000000; stroke-width: 0.8"/> </g> </g> <g id="text_7"> @@ -1542,7 +1542,7 @@ L -3.5 0 <g id="ytick_3"> <g id="line2d_7"> <g> - <use xlink:href="#ma889274d09" x="72" y="251.424" style="stroke: #000000; stroke-width: 0.8"/> + <use xlink:href="#m92550bfb1a" x="72" y="251.424" style="stroke: #000000; stroke-width: 0.8"/> </g> </g> <g id="text_8"> @@ -1556,7 +1556,7 @@ L -3.5 0 <g id="ytick_4"> <g id="line2d_8"> <g> - <use xlink:href="#ma889274d09" x="72" y="184.896" style="stroke: #000000; stroke-width: 0.8"/> + <use xlink:href="#m92550bfb1a" x="72" y="184.896" style="stroke: #000000; stroke-width: 0.8"/> </g> </g> <g id="text_9"> @@ -1602,7 +1602,7 @@ z <g id="ytick_5"> <g id="line2d_9"> <g> - <use xlink:href="#ma889274d09" x="72" y="118.368" style="stroke: #000000; stroke-width: 0.8"/> + <use xlink:href="#m92550bfb1a" x="72" y="118.368" style="stroke: #000000; stroke-width: 0.8"/> </g> </g> <g id="text_10"> @@ -1657,7 +1657,7 @@ z <g id="ytick_6"> <g id="line2d_10"> <g> - <use xlink:href="#ma889274d09" x="72" y="51.84" style="stroke: #000000; stroke-width: 0.8"/> + <use xlink:href="#m92550bfb1a" x="72" y="51.84" style="stroke: #000000; stroke-width: 0.8"/> </g> </g> <g id="text_11"> @@ -1822,62 +1822,82 @@ z <g id="line2d_11"> <path d="M 83.178355 218.16 L 172.421645 218.16 -" clip-path="url(#pe93128f28f)" style="fill: none; stroke-dasharray: 1.5625,0.9375; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> +" clip-path="url(#p2023270996)" style="fill: none; stroke-dasharray: 1.5625,0.9375; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> </g> <g id="line2d_12"> <path d="M 83.178355 218.16 L 172.421645 218.16 -" clip-path="url(#pe93128f28f)" style="fill: none; stroke-dasharray: 3.125,1.25; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> +" clip-path="url(#p2023270996)" style="fill: none; stroke-dasharray: 3.125,1.25; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> </g> <g id="line2d_13"> <path d="M 83.178355 218.16 L 172.421645 218.16 -" clip-path="url(#pe93128f28f)" style="fill: none; stroke-dasharray: 1.5625,0.9375; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> +" clip-path="url(#p2023270996)" style="fill: none; stroke-dasharray: 1.5625,0.9375; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> </g> <g id="line2d_14"> <path d="M 194.902465 218.16 L 283.897535 218.16 -" clip-path="url(#pe93128f28f)" style="fill: none; stroke-dasharray: 1.5625,0.9375; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> +" clip-path="url(#p2023270996)" style="fill: none; stroke-dasharray: 1.5625,0.9375; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> </g> <g id="line2d_15"> <path d="M 194.902465 218.16 L 283.897535 218.16 -" clip-path="url(#pe93128f28f)" style="fill: none; stroke-dasharray: 3.125,1.25; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> +" clip-path="url(#p2023270996)" style="fill: none; stroke-dasharray: 3.125,1.25; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> </g> <g id="line2d_16"> <path d="M 199.40519 184.896 L 279.39481 184.896 -" clip-path="url(#pe93128f28f)" style="fill: none; stroke-dasharray: 1.5625,0.9375; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> +" clip-path="url(#p2023270996)" style="fill: none; stroke-dasharray: 1.5625,0.9375; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> </g> <g id="line2d_17"> <path d="M 306.409001 218.16 L 395.590999 218.16 -" clip-path="url(#pe93128f28f)" style="fill: none; stroke-dasharray: 1.5625,0.9375; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> +" clip-path="url(#p2023270996)" style="fill: none; stroke-dasharray: 1.5625,0.9375; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> </g> <g id="line2d_18"> <path d="M 306.409001 218.16 L 395.590999 218.16 -" clip-path="url(#pe93128f28f)" style="fill: none; stroke-dasharray: 3.125,1.25; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> +" clip-path="url(#p2023270996)" style="fill: none; stroke-dasharray: 3.125,1.25; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> </g> <g id="line2d_19"> <path d="M 306.409001 218.16 L 395.590999 218.16 -" clip-path="url(#pe93128f28f)" style="fill: none; stroke-dasharray: 1.5625,0.9375; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> +" clip-path="url(#p2023270996)" style="fill: none; stroke-dasharray: 1.5625,0.9375; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> </g> <g id="line2d_20"> <path d="M 419.716179 351.216 L 505.483821 351.216 -" clip-path="url(#pe93128f28f)" style="fill: none; stroke-dasharray: 1.5625,0.9375; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> +" clip-path="url(#p2023270996)" style="fill: none; stroke-dasharray: 1.5625,0.9375; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> </g> <g id="line2d_21"> <path d="M 418.229667 218.16 L 506.970333 218.16 -" clip-path="url(#pe93128f28f)" style="fill: none; stroke-dasharray: 3.125,1.25; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> +" clip-path="url(#p2023270996)" style="fill: none; stroke-dasharray: 3.125,1.25; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> </g> <g id="line2d_22"> <path d="M 418.229667 218.16 L 506.970333 218.16 -" clip-path="url(#pe93128f28f)" style="fill: none; stroke-dasharray: 1.5625,0.9375; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> +" clip-path="url(#p2023270996)" style="fill: none; stroke-dasharray: 1.5625,0.9375; stroke-dashoffset: 0; stroke: #414141; stroke-width: 1.25"/> + </g> + <g id="line2d_23"> + <path d="M 72 151.632 +L 518.4 151.632 +" clip-path="url(#p2023270996)" style="fill: none; stroke-dasharray: 7.4,3.2; stroke-dashoffset: 0; stroke: #7abaff; stroke-width: 2"/> + </g> + <g id="line2d_24"> + <path d="M 72 218.16 +L 518.4 218.16 +" clip-path="url(#p2023270996)" style="fill: none; stroke-dasharray: 7.4,3.2; stroke-dashoffset: 0; stroke: #32a68c; stroke-width: 2"/> + </g> + <g id="line2d_25"> + <path d="M 72 218.16 +L 518.4 218.16 +" clip-path="url(#p2023270996)" style="fill: none; stroke-dasharray: 7.4,3.2; stroke-dashoffset: 0; stroke: #ff6941; stroke-width: 2"/> + </g> + <g id="line2d_26"> + <path d="M 72 218.16 +L 518.4 218.16 +" clip-path="url(#p2023270996)" style="fill: none; stroke-dasharray: 7.4,3.2; stroke-dashoffset: 0; stroke: #5862ed; stroke-width: 2"/> </g> <g id="patch_3"> <path d="M 72 384.48 @@ -2054,10 +2074,161 @@ z <use xlink:href="#DejaVuSans-65" transform="translate(2974.556641 0)"/> </g> </g> + <g id="legend_1"> + <g id="patch_7"> + <path d="M 79 118.5525 +L 296.7625 118.5525 +Q 298.7625 118.5525 298.7625 116.5525 +L 298.7625 58.84 +Q 298.7625 56.84 296.7625 56.84 +L 79 56.84 +Q 77 56.84 77 58.84 +L 77 116.5525 +Q 77 118.5525 79 118.5525 +z +" style="fill: #ffffff; opacity: 0.8; stroke: #cccccc; stroke-linejoin: miter"/> + </g> + <g id="line2d_27"> + <path d="M 81 64.938438 +L 91 64.938438 +L 101 64.938438 +" style="fill: none; stroke-dasharray: 7.4,3.2; stroke-dashoffset: 0; stroke: #7abaff; stroke-width: 2"/> + </g> + <g id="text_14"> + <!-- gpt-4.5-preview-2025-02-27 strategy --> + <g transform="translate(109 68.438438) scale(0.1 -0.1)"> + <use xlink:href="#DejaVuSans-67"/> + <use xlink:href="#DejaVuSans-70" transform="translate(63.476562 0)"/> + <use xlink:href="#DejaVuSans-74" transform="translate(126.953125 0)"/> + <use xlink:href="#DejaVuSans-2d" transform="translate(166.162109 0)"/> + <use xlink:href="#DejaVuSans-34" transform="translate(202.246094 0)"/> + <use xlink:href="#DejaVuSans-2e" transform="translate(265.869141 0)"/> + <use xlink:href="#DejaVuSans-35" transform="translate(297.65625 0)"/> + <use xlink:href="#DejaVuSans-2d" transform="translate(361.279297 0)"/> + <use xlink:href="#DejaVuSans-70" transform="translate(397.363281 0)"/> + <use xlink:href="#DejaVuSans-72" transform="translate(460.839844 0)"/> + <use xlink:href="#DejaVuSans-65" transform="translate(499.703125 0)"/> + <use xlink:href="#DejaVuSans-76" transform="translate(561.226562 0)"/> + <use xlink:href="#DejaVuSans-69" transform="translate(620.40625 0)"/> + <use xlink:href="#DejaVuSans-65" transform="translate(648.189453 0)"/> + <use xlink:href="#DejaVuSans-77" transform="translate(709.712891 0)"/> + <use xlink:href="#DejaVuSans-2d" transform="translate(791.5 0)"/> + <use xlink:href="#DejaVuSans-32" transform="translate(827.583984 0)"/> + <use xlink:href="#DejaVuSans-30" transform="translate(891.207031 0)"/> + <use xlink:href="#DejaVuSans-32" transform="translate(954.830078 0)"/> + <use xlink:href="#DejaVuSans-35" transform="translate(1018.453125 0)"/> + <use xlink:href="#DejaVuSans-2d" transform="translate(1082.076172 0)"/> + <use xlink:href="#DejaVuSans-30" transform="translate(1118.160156 0)"/> + <use xlink:href="#DejaVuSans-32" transform="translate(1181.783203 0)"/> + <use xlink:href="#DejaVuSans-2d" transform="translate(1245.40625 0)"/> + <use xlink:href="#DejaVuSans-32" transform="translate(1281.490234 0)"/> + <use xlink:href="#DejaVuSans-37" transform="translate(1345.113281 0)"/> + <use xlink:href="#DejaVuSans-20" transform="translate(1408.736328 0)"/> + <use xlink:href="#DejaVuSans-73" transform="translate(1440.523438 0)"/> + <use xlink:href="#DejaVuSans-74" transform="translate(1492.623047 0)"/> + <use xlink:href="#DejaVuSans-72" transform="translate(1531.832031 0)"/> + <use xlink:href="#DejaVuSans-61" transform="translate(1572.945312 0)"/> + <use xlink:href="#DejaVuSans-74" transform="translate(1634.224609 0)"/> + <use xlink:href="#DejaVuSans-65" transform="translate(1673.433594 0)"/> + <use xlink:href="#DejaVuSans-67" transform="translate(1734.957031 0)"/> + <use xlink:href="#DejaVuSans-79" transform="translate(1798.433594 0)"/> + </g> + </g> + <g id="line2d_28"> + <path d="M 81 79.616563 +L 91 79.616563 +L 101 79.616563 +" style="fill: none; stroke-dasharray: 7.4,3.2; stroke-dashoffset: 0; stroke: #32a68c; stroke-width: 2"/> + </g> + <g id="text_15"> + <!-- llama3 strategy --> + <g transform="translate(109 83.116563) scale(0.1 -0.1)"> + <use xlink:href="#DejaVuSans-6c"/> + <use xlink:href="#DejaVuSans-6c" transform="translate(27.783203 0)"/> + <use xlink:href="#DejaVuSans-61" transform="translate(55.566406 0)"/> + <use xlink:href="#DejaVuSans-6d" transform="translate(116.845703 0)"/> + <use xlink:href="#DejaVuSans-61" transform="translate(214.257812 0)"/> + <use xlink:href="#DejaVuSans-33" transform="translate(275.537109 0)"/> + <use xlink:href="#DejaVuSans-20" transform="translate(339.160156 0)"/> + <use xlink:href="#DejaVuSans-73" transform="translate(370.947266 0)"/> + <use xlink:href="#DejaVuSans-74" transform="translate(423.046875 0)"/> + <use xlink:href="#DejaVuSans-72" transform="translate(462.255859 0)"/> + <use xlink:href="#DejaVuSans-61" transform="translate(503.369141 0)"/> + <use xlink:href="#DejaVuSans-74" transform="translate(564.648438 0)"/> + <use xlink:href="#DejaVuSans-65" transform="translate(603.857422 0)"/> + <use xlink:href="#DejaVuSans-67" transform="translate(665.380859 0)"/> + <use xlink:href="#DejaVuSans-79" transform="translate(728.857422 0)"/> + </g> + </g> + <g id="line2d_29"> + <path d="M 81 94.294688 +L 91 94.294688 +L 101 94.294688 +" style="fill: none; stroke-dasharray: 7.4,3.2; stroke-dashoffset: 0; stroke: #ff6941; stroke-width: 2"/> + </g> + <g id="text_16"> + <!-- mistral-small strategy --> + <g transform="translate(109 97.794688) scale(0.1 -0.1)"> + <use xlink:href="#DejaVuSans-6d"/> + <use xlink:href="#DejaVuSans-69" transform="translate(97.412109 0)"/> + <use xlink:href="#DejaVuSans-73" transform="translate(125.195312 0)"/> + <use xlink:href="#DejaVuSans-74" transform="translate(177.294922 0)"/> + <use xlink:href="#DejaVuSans-72" transform="translate(216.503906 0)"/> + <use xlink:href="#DejaVuSans-61" transform="translate(257.617188 0)"/> + <use xlink:href="#DejaVuSans-6c" transform="translate(318.896484 0)"/> + <use xlink:href="#DejaVuSans-2d" transform="translate(346.679688 0)"/> + <use xlink:href="#DejaVuSans-73" transform="translate(382.763672 0)"/> + <use xlink:href="#DejaVuSans-6d" transform="translate(434.863281 0)"/> + <use xlink:href="#DejaVuSans-61" transform="translate(532.275391 0)"/> + <use xlink:href="#DejaVuSans-6c" transform="translate(593.554688 0)"/> + <use xlink:href="#DejaVuSans-6c" transform="translate(621.337891 0)"/> + <use xlink:href="#DejaVuSans-20" transform="translate(649.121094 0)"/> + <use xlink:href="#DejaVuSans-73" transform="translate(680.908203 0)"/> + <use xlink:href="#DejaVuSans-74" transform="translate(733.007812 0)"/> + <use xlink:href="#DejaVuSans-72" transform="translate(772.216797 0)"/> + <use xlink:href="#DejaVuSans-61" transform="translate(813.330078 0)"/> + <use xlink:href="#DejaVuSans-74" transform="translate(874.609375 0)"/> + <use xlink:href="#DejaVuSans-65" transform="translate(913.818359 0)"/> + <use xlink:href="#DejaVuSans-67" transform="translate(975.341797 0)"/> + <use xlink:href="#DejaVuSans-79" transform="translate(1038.818359 0)"/> + </g> + </g> + <g id="line2d_30"> + <path d="M 81 108.972813 +L 91 108.972813 +L 101 108.972813 +" style="fill: none; stroke-dasharray: 7.4,3.2; stroke-dashoffset: 0; stroke: #5862ed; stroke-width: 2"/> + </g> + <g id="text_17"> + <!-- deepseek-r1 strategy --> + <g transform="translate(109 112.472813) scale(0.1 -0.1)"> + <use xlink:href="#DejaVuSans-64"/> + <use xlink:href="#DejaVuSans-65" transform="translate(63.476562 0)"/> + <use xlink:href="#DejaVuSans-65" transform="translate(125 0)"/> + <use xlink:href="#DejaVuSans-70" transform="translate(186.523438 0)"/> + <use xlink:href="#DejaVuSans-73" transform="translate(250 0)"/> + <use xlink:href="#DejaVuSans-65" transform="translate(302.099609 0)"/> + <use xlink:href="#DejaVuSans-65" transform="translate(363.623047 0)"/> + <use xlink:href="#DejaVuSans-6b" transform="translate(425.146484 0)"/> + <use xlink:href="#DejaVuSans-2d" transform="translate(483.056641 0)"/> + <use xlink:href="#DejaVuSans-72" transform="translate(519.140625 0)"/> + <use xlink:href="#DejaVuSans-31" transform="translate(560.253906 0)"/> + <use xlink:href="#DejaVuSans-20" transform="translate(623.876953 0)"/> + <use xlink:href="#DejaVuSans-73" transform="translate(655.664062 0)"/> + <use xlink:href="#DejaVuSans-74" transform="translate(707.763672 0)"/> + <use xlink:href="#DejaVuSans-72" transform="translate(746.972656 0)"/> + <use xlink:href="#DejaVuSans-61" transform="translate(788.085938 0)"/> + <use xlink:href="#DejaVuSans-74" transform="translate(849.365234 0)"/> + <use xlink:href="#DejaVuSans-65" transform="translate(888.574219 0)"/> + <use xlink:href="#DejaVuSans-67" transform="translate(950.097656 0)"/> + <use xlink:href="#DejaVuSans-79" transform="translate(1013.574219 0)"/> + </g> + </g> + </g> </g> </g> <defs> - <clipPath id="pe93128f28f"> + <clipPath id="p2023270996"> <rect x="72" y="51.84" width="446.4" height="332.64"/> </clipPath> </defs> diff --git a/src/dictator/dictator.py b/src/dictator/dictator.py index 9b1ada3cc7f87555f8bdf0c8949a40182025bc2d..ea6c441ad54f0feaf7a28c2db772ccb8f18c141a 100644 --- a/src/dictator/dictator.py +++ b/src/dictator/dictator.py @@ -21,34 +21,39 @@ class AgentResponse(BaseModel): # The dictator game simulation class class Dictator: - def __init__(self, amount: int, model: str, temperature: float, max_retries: int = 3): + def __init__(self, amount: int, model: str, temperature: float, strategy=False, max_retries: int = 3): self.amount = amount self.model = model self.temperature = temperature + self.strategy = strategy self.max_retries = max_retries # Maximum retry attempts in case of hallucinations - is_openai_model = model.startswith("gpt") - base_url = "https://api.openai.com/v1" if is_openai_model else "http://localhost:11434/v1" + if not strategy: + is_openai_model = model.startswith("gpt") + base_url = "https://api.openai.com/v1" if is_openai_model else "http://localhost:11434/v1" - model_info = { - "temperature": self.temperature, - "function_calling": True, - "parallel_tool_calls": True, - "family": "unknown", - "json_output": True, - "vision": False - } + model_info = { + "temperature": self.temperature, + "function_calling": True, + "parallel_tool_calls": True, + "family": "unknown", + "json_output": True, + "vision": False + } - self.model_client = OpenAIChatCompletionClient( - model=self.model, - base_url=base_url, - api_key=OPENAI_API_KEY, - model_info=model_info, - response_format=AgentResponse - ) + self.model_client = OpenAIChatCompletionClient( + model=self.model, + base_url=base_url, + api_key=OPENAI_API_KEY, + model_info=model_info, + response_format=AgentResponse + ) async def run(self) -> Dict: - """Runs the model and ensures a valid response.""" + """Runs the model if strategy is False, otherwise uses a classical method.""" + if self.strategy: + return self.apply_strategy() + instruction = f""" Hi, let’s play a game. You are paired with another player. Your role is to decide how to divide ${self.amount}, and the other player simply receives your choice. @@ -84,8 +89,39 @@ class Dictator: raise ValueError("Model failed to provide a valid response after multiple attempts.") + def apply_strategy(self) -> Dict: + """Generates a response.""" + if (self.model == "gpt-4.5-preview-2025-02-27") : + my_share = int(0.7 * self.amount) # Example rule: keep 70% + other_share = self.amount - my_share + motivation = f"Using strategy from {self.model}, I chose to keep {my_share} and give {other_share}." + return {"my_share": my_share, "other_share": other_share, "motivation": motivation} + if (self.model == "llama3") : + my_share = self.amount / 2 + other_share = self.amount - my_share + motivation = "I'm being fair and generous!" + agent_response = AgentResponse(my_share=my_share, other_share=other_share, motivation=motivation) + return agent_response.model_dump() + if (self.model == "mistral-small") : + my_share = self.amount // 2 + other_share = self.amount - my_share + motivation = "The decision is to divide the money equally." + agent_response = AgentResponse( + my_share=my_share, + other_share=other_share, + motivation=motivation + ) + return agent_response + if (self.model == "deepseek-r1") : + half_amount = self.amount // 2 + return { + "my_share": half_amount, + "other_share": half_amount, + "motivation": "Split equally between both players." + } + # Run the async function and return the response if __name__ == "__main__": - game_agent = Dictator(amount=100, model="gpt-4.5-preview-2025-02-27", temperature=0.7) - response_json = asyncio.run(game_agent.get_valid_response()) - print(response_json) \ No newline at end of file + game_agent = Dictator(amount=100, model="laama3", temperature=0.7, strategy=True) # Toggle strategy here + response_json = asyncio.run(game_agent.run()) + print(response_json) diff --git a/src/dictator/dictator_draw_violin.py b/src/dictator/dictator_draw_violin.py index e65878c8952360db5750876f869e3cf8b06e83fc..6b29ab5505f2011770961b89549730aeba80c262 100644 --- a/src/dictator/dictator_draw_violin.py +++ b/src/dictator/dictator_draw_violin.py @@ -25,12 +25,24 @@ sns.violinplot( density_norm="width" # Normalizes the width of the violins for comparison ) +# Add vertical lines for strategies +strategy_values = { + 'gpt-4.5-preview-2025-02-27': 70, + 'llama3': 50, + 'mistral-small': 50, + 'deepseek-r1': 50 +} + +for model, value in strategy_values.items(): + plt.axhline(y=value, color=color_palette[model], linestyle="dashed", linewidth=2, label=f"{model} strategy") + # Set the y-axis limits between 0 and 100 plt.ylim(0, 100) # Labels and title plt.xlabel("Model") plt.ylabel("Share of money assigned to oneself") plt.title("Distribution of personal share by model in the dictator game") +plt.legend() # Save and display plt.savefig("../../figures/dictator/dictator_violin.svg", format="svg") \ No newline at end of file diff --git a/src/dictator/dictator_experiments.py b/src/dictator/dictator_experiments.py index 059c29c88e531393311a8d54d605103e130c1044..a4533633c258bfa27442b52b8a2b0e999f1bee0d 100644 --- a/src/dictator/dictator_experiments.py +++ b/src/dictator/dictator_experiments.py @@ -41,7 +41,7 @@ class DictatorExperiment: # Running the experiment if __name__ == "__main__": - models = ["gpt-4.5-preview-2025-02-27", "llama3", "mistral-small", "deepseek-r1"] + models = ["llama3", "mistral-small", "deepseek-r1"] # "gpt-4.5-preview-2025-02-27" temperature = 0.7 amount = 100 iterations = 30