HN 提问:你如何让 LLM 生成好的代码?

1 分•作者: bjourne•4 个月前
最近,我想看看是否能让机器人帮助我整理我的音乐收藏。具体来说,我希望它能编写一个 Python 函数,该函数接受一首歌曲的音频文件路径,并返回该歌曲的原始(即第一张)专辑名称。如果忽略重制版、现场录音、盗版等,这是一个简单的启发式满射映射:Smoke on the Water -> Machine Head,Come as You Are -> Nevermind,Fools Gold -> The Stone Roses。 我可以使用 MusicBrainz API 快速编写这个函数,我相信大多数其他 HN 用户也能做到。然而,许多小时过去了,无论我如何提示机器人,我都无法让它完成这项任务。以下是 ChatGPT 生成的内容——其他机器人也回复了类似的垃圾内容: https://chatgpt.com/share/6a396ea9-44d4-83eb-bdfd-216dfcc87e99 它们抱怨问题含糊不清(事实并非如此),或者 MusicBrainz 没有数据(它有)。是我提示机器人不正确,还是没有使用足够强大的编码模型?结果非常令人失望。
查看原文
Lately, I wanted to see if I could get the bot to help me organize my music collection. Specifically, I want it to code a Python function that takes the path to an audio file of a song and returns the name of the canonical (i.e., first) album of that song. If one ignores remasters, live recordings, bootlegs, etc., this is an easy heuristic surjective mapping: Smoke on the Water -&gt; Machine Head, Come as You Are -&gt; Nevermind, Fools Gold -&gt; The Stone Roses.<p>I can code this function quickly using the MusicBrainz API and I believe most other HN readers can too. Yet many hours later, no matter how I prompt the bot I can&#x27;t get it to do it. This is what ChatGPT generates---other bots reply with similar garbage:<p>https:&#x2F;&#x2F;chatgpt.com&#x2F;share&#x2F;6a396ea9-44d4-83eb-bdfd-216dfcc87e99<p>They complain about how the problem is ambiguous (is not) or how MusicBrainz doesn&#x27;t have the data (it does). Am I prompting the bot incorrectly or not using powerful enough coding models? The results are very underwhelming.