TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

In honor of Weizenbaum's Centenary, I asked ChatGPT to program ELIZA

88 点作者 abrax3141超过 2 年前
When I was 13 (many decades ago), I wrote the BASIC ELIZA that many of you have probably experienced (if you are of a certain age) or (if you are not ...) you&#x27;ve almost certainly experienced a knock-off of mine.<p>Today, Jan 8th, is the 100th centenary of Joseph Weizenbaum&#x27;s birth, so I asked ChatGPT to write ELIZA in js.<p>Long dialog (~10 rounds) short, here&#x27;s where it ended up:<p>&#x27;&#x27;&#x27; &#x2F;&#x2F; A list of ELIZA&#x27;s responses const responses = { &quot;I feel&quot;: [ &quot;Why do you feel {0}?&quot;, &quot;What do you think is causing you to feel {0}?&quot;, &quot;Do you often feel {0}?&quot;, &quot;How do you normally deal with feeling {0}?&quot; ], &quot;I want&quot;: [ &quot;Why do you want {0}?&quot;, &quot;What led you to want this?&quot;, &quot;Do you often find yourself wanting {0}?&quot;, &quot;How do you think getting what you want will make you feel?&quot; ], &quot;I need&quot;: [ &quot;Why do you feel like you need {0}?&quot;, &quot;What led you to feel like you need this?&quot;, &quot;Do you often find yourself feeling like you need {0}?&quot;, &quot;How do you think getting what you need will make you feel?&quot; ] };<p>&#x2F;&#x2F; A list of keywords const keywords = Object.keys(responses);<p>&#x2F;&#x2F; A function that generates a response function generateResponse(input) { &#x2F;&#x2F; Check if the input contains any of the keywords for (let i = 0; i &lt; keywords.length; i++) { if (input.includes(keywords[i])) { &#x2F;&#x2F; If the input contains a keyword, return a random response &#x2F;&#x2F; that includes the remainder of the input, with personal &#x2F;&#x2F; pronouns conjugated correctly const response = responses[keywords[i]][Math.floor(Math.random() * responses[keywords[i]].length)]; return response.replace(&quot;{0}&quot;, input.substring(keywords[i].length + 1)); } } }<p>&#x2F;&#x2F; Test the function console.log(generateResponse(&quot;I feel sad&quot;)); console.log(generateResponse(&quot;I want a new car&quot;)); console.log(generateResponse(&quot;I need some help&quot;));<p>&#x27;&#x27;&#x27;<p>My conclusion: It&#x27;s not yet up to being a 1970s 13 year old programmer....yet. :-)<p>---- (Apparently &#x27;&#x27;&#x27; ... &#x27;&#x27;&#x27; doesn&#x27;t do code in HN. Sorry for the wrap-around formatting.)

15 条评论

abrax3141超过 2 年前
BTW, in the long dialog that I had with it, ChatGPT created many different versions of this code with varying degrees of matching my spec. Every version sort of matched my spec, but at the same time each and every one of them was broken in various random ways. None actually worked out of the box. As with all of these grammatical confabulation engines, they fall headlong into the uncanny valley, looking sort of like a program, but when there&#x27;s a right and wrong, they tend to end up on the wrong side.
评论 #34314484 未加载
abrax3141超过 2 年前
BTW, in case you missed it:<p><pre><code> https:&#x2F;&#x2F;corecursive.com&#x2F;eliza-with-jeff-shrager&#x2F; </code></pre> (Does it count as shameless self-promotion if I&#x27;m actually promoting someone else&#x27;s highly relevant podcast that just happened to have me in it?)
评论 #34318620 未加载
评论 #34318491 未加载
RoddaWallPro超过 2 年前
ELIZA is mentioned in passing in Cormac McCarthy&#x27;s latest novel, Stella Maris (which is a companion&#x2F;coda to his novel that came out one month prior: The Passenger). I didn&#x27;t know what ELIZA was when it was mentioned, and looked it up and that kicked off a long rabbithole of learning about early AI researchers. I thought it was funny that people in the 60s attributed human-like qualities to ELIZA, which we now view as a ridiculously primitive program. Perhaps the humans of 2073 will look back on ChatGPT&#x2F;etc very similarly to the way we now look at ELIZA. Relevant quote from wikipedia (<a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;ELIZA" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;ELIZA</a>):<p>&quot;Some of ELIZA&#x27;s responses were so convincing that Weizenbaum and several others have anecdotes of users becoming emotionally attached to the program, occasionally forgetting that they were conversing with a computer.[3] Weizenbaum&#x27;s own secretary reportedly asked Weizenbaum to leave the room so that she and ELIZA could have a real conversation. Weizenbaum was surprised by this, later writing: &quot;I had not realized ... that extremely short exposures to a relatively simple computer program could induce powerful delusional thinking in quite normal people.&quot;<p>Wikipedia states that a version of ELIZA is still available in emacs under m-x doctor or something similar. Not being an emacs user, I haven&#x27;t verified that, but I thought it was interesting.
评论 #34315520 未加载
评论 #34316236 未加载
User23超过 2 年前
I think the strongest argument that AGI has been achieved is when ChatGPT vN can write ChatGPT vN+1 and have it be a Pareto improvement. Can we call it the User Test?<p><pre><code> Now for some real User power.</code></pre>
评论 #34312249 未加载
评论 #34312522 未加载
评论 #34312361 未加载
JoeAltmaier超过 2 年前
We used to write them in BASIC back at the UofIowa in the 80&#x27;s. Lots of pattern matching for subject and object; lots of dialog trees. It was fun!<p>One observation Bob Bryla made was, count the number of words that begin with &#x27;N&#x27; and treat each as a logical-negation. With a very small dictionary of additional negation words (e.g. can&#x27;t) and a whitelist (e.g. nice) you could tell the sense of a statement or question pretty accurately.<p>Nope, never, not, nada, na, nobody and on and on.
abrax3141超过 2 年前
Okay, so holy f&#x27;ing s#!t!<p>Out of curiosity, I today asked it to program the ELIZA in MAD-SLIP, the original (and now completely dead and obscure) language that ELIZA was originally written in. My expectation was that it would have no idea what MAD-SLIP is, or maybe would barely have an idea, and in any case would have no chance of doing what I asked and that it would, very reasonably, balk.<p>Instead, to my shock it made up a completely bogus meaning for the acronym: &quot;Matched Activated Decomposition by Syntactic and Lexical Interchange Program&quot;, and actually wrote an ELIZA in this non-existing language, which was in reality just Python code using the rexexp (re) package, and was perfectly fine as far as it went.<p>Even scarier than confabulating a non-exisistent programming language, it confabulated a citation for it, claiming that it is described in Weizenbaum&#x27;s Computer Power and Human Reason, which is utterly false!<p>Sigh. I fear that ChatGPT is merely bringing Weizenbaum&#x27;s worst fears into reality! A seemingly authoritative AI that simply makes s#!t up! I&#x27;m feeling a bit like taking up arms at the moment.
royjacobs超过 2 年前
That&#x27;s so cool! One of the ways I learnt programming in BASIC was by studying the program outputs next to the listings in those Creative Computing books. ELIZA was one my favourites, so thanks for doing the port all that time ago.
ck2超过 2 年前
I think I first experienced ELIZA on a PDP-11<p>What&#x27;s really going to get spooky is someday some ChatGPT descendant is going to write a better ChatGPT and where does that sequence end?
评论 #34315154 未加载
评论 #34315594 未加载
评论 #34312237 未加载
评论 #34312149 未加载
defitrader超过 2 年前
I think this is the best way to honor Weizenbaum&#x27;s Centenary.
kshay超过 2 年前
Does it please you to believe I am of a certain age) or( if I am not...) I&#x27;ve almost certainly experienced a knock-off of your&#x27;s?
floxy超过 2 年前
<p><pre><code> &#x2F;&#x2F; A list of ELIZA&#x27;s responses const responses = {&quot;I feel&quot;: [ &quot;Why do you feel {0}?&quot;, &quot;What do you think is causing you to feel {0}?&quot;, &quot;Do you often feel {0}?&quot;, &quot;How do you normally deal with feeling {0}?&quot; ], &quot;I want&quot;: [ &quot;Why do you want {0}?&quot;, &quot;What led you to want this?&quot;, &quot;Do you often find yourself wanting {0}?&quot;, &quot;How do you think getting what you want will make you feel?&quot; ], &quot;I need&quot;: [ &quot;Why do you feel like you need {0}?&quot;, &quot;What led you to feel like you need this?&quot;, &quot;Do you often find yourself feeling like you need {0}?&quot;, &quot;How do you think getting what you need will make you feel?&quot; ] }; &#x2F;&#x2F; A list of keywords const keywords = Object.keys(responses); &#x2F;&#x2F; A function that generates a response function generateResponse(input) { &#x2F;&#x2F; Check if the input contains any of the keywords for (let i = 0; i &lt; keywords.length; i++) { if (input.includes(keywords[i])) { &#x2F;&#x2F; If the input contains a keyword, return a random response &#x2F;&#x2F; that includes the remainder of the input, with personal &#x2F;&#x2F; pronouns conjugated correctly const response = responses[keywords[i]][Math.floor(Math.random() * responses[keywords[i]].length)]; return response.replace(&quot;{0}&quot;, input.substring(keywords[i].length + 1)); } } } &#x2F;&#x2F; Test the function console.log(generateResponse(&quot;I feel sad&quot;)); console.log(generateResponse(&quot;I want a new car&quot;)); console.log(generateResponse(&quot;I need some help&quot;));</code></pre>
评论 #34317696 未加载
vages超过 2 年前
Not sure if Weizenbaum would be honoured.<p>&gt; Weizenbaum, for his part, turned away from his own project’s expanding implications. He objected to the idea that something as subtle, intimate, and human as therapy could be reduced to code. He began to argue that fields requiring human compassion and understanding shouldn’t be automated. And he also worried about the same future that Alan Turing had described — one where chatbots regularly fooled people into thinking they were human. – <a href="https:&#x2F;&#x2F;99percentinvisible.org&#x2F;episode&#x2F;the-eliza-effect&#x2F;" rel="nofollow">https:&#x2F;&#x2F;99percentinvisible.org&#x2F;episode&#x2F;the-eliza-effect&#x2F;</a>
评论 #34325352 未加载
评论 #34322392 未加载
评论 #34317658 未加载
BarbaryCoast超过 2 年前
In Emacs: M-X doctor &lt;ret&gt;
YeGoblynQueenne超过 2 年前
&gt;&gt; ---- (Apparently &#x27;&#x27;&#x27; ... &#x27;&#x27;&#x27; doesn&#x27;t do code in HN. Sorry for the wrap-around formatting.)<p>For pre-formatted code leave two spaces at the start of the line.<p><pre><code> Like this. </code></pre> There&#x27;s no special notation for code. Despite this being, you know <i>Hacker</i> News.
评论 #34314821 未加载
评论 #34314796 未加载
lcnmrn超过 2 年前
Can you program ChatGPT with ChatGPT?
评论 #34317653 未加载