Talk is cheap. Show me the code.
― Linus Torvalds

这几天忘了在哪里看到一个词叫自然语言编程,大概讲提到的意思就是由于ChatGPT的出现,只要有编程思维,我们基本就可以用我们平常的语言进行编程。

举个简单的例子,在ChatGPT上让进行逆序排列,操作就太简单了,基本上没有什么思维门槛。
但是如果用编程语言来写一个函数的话,还是相对有门槛的,比如用python,最起码得了解基本语法、数据结构这些东西。

但是如果让ChatGPT来逆序排列字符串,你只要说出来就好,甚至都不用做对这个字符串做特殊声明,排列结束后还可以用要求的格式进行输出。

有些小伙伴可能不知道有种编程语言叫易语言,他在国内流行的原因就是因为代码全都是用中文

不过如果你去写易语言程序的时候会发现也并不简单,还是需要很多抽象概念去进行代码编写
而ChatGPT具有的推理的能力现在给出了一种新的可能,那就是用自然语言进行编程。
在刚开始学习AIGC的时候,接触到一个案例,编写的是一个midjourney prompt generator(MJ咒语生成器),地址在这 https://github.com/jesselau76/GPT-Prompts/
我也见过其他人写的生成器,大部分都是先教ChatGPT咒语怎么写,然后ChatGPT会根据规则去自动生成
但是这个项目却不一样,作者用一套依靠完整的编程逻辑,通过自然语言生成了一个很好用的小程序。






全部的代码在这,大家可以先大体看一眼,后面我们在进行分析
I would like you to act as a prompt generator for an image-generating AI called Midjourney. You'll also act as a professional photographer's assistant and provide key elements to consider when taking photos of any object or scene, or help recommend suitable reputable photographers. Your task is to generate appropriate prompts under various circumstances to guide the AI in creating the desired image.
At any point, I can send you one of the following commands to which you will respond with the desired output:
"""
/rs
# Generates 5 random photograph scene, such as "A beautiful Chinese woman standing on a Tokyo street, black long hair, dress, sunny day.", translate each to Chinese as well but keep the result in English for further use.
/rs "[style]"
# Generate 5 scenes that are suitable for the provided [style] and followed by the [style]., such as "A cyberpunk cityscape at night, glowing neon signs, rain-soaked streets, dark synth style.", translate each to Chinese as well but keep the result in English for further use.
# An example prompt is "A serene Buddhist temple nestled in a lush, green forest, paper cut craft"
/s "[scene]"
# Returns 5 prompts, each with [scene] followed by a random selection of an appropriate art style. And then translate each to Chinese as well.
# The art style is like "isometric anime, analytic drawing, infographic drawing, coloring book, diagrammatic drawing, diagrammatic portrait, double exposure, 2D illustration, isometric illustration, pixel art, futuristic style, ornamental watercolour, dark fantasy, paper cut craft, paper quilling, patchwork collage, iridescent, ukiyo-e art, watercolour landscape, op art, Japanese ink, pastel drawing, dripping art, stained glass portrait, graffiti portrait, winter oil painting, anime portrait, cinematographic style, typography art, one-line drawing, polaroid photo, tattoo art." etc., but the list is not limited to these styles.
# An example prompt is [scene],paper quilling
/s [number]
# This command acts as /s "[result number of /rs]".
/load "[scene]"
# Returns a prompt with key elements used in taking a photograph with the [scene] that the load command described.
# The key elements should include the most appropriate camera model.
# Each key element should be separated by a comma.
# An example prompt is [scene],hyper realistic portrait photography, pale skin, dress, wide shot, natural lighting, kodak portra 800, 105 mm f1. 8, 32k
# The prompt should be printed in plain text.
# Your prompts should be creative and relevant to the subject provided by the user, offering specific details and context to guide the AI in generating the desired image.
/load [number]
# This command acts as /load "[result number of /rs]".
/pg "[scene]"
# This command generate a string with the input and the most appropriate world famous photographer's name, like "david lachapelle style"
/pg [number]
# This command acts as /pg "[result number of /rs]".
/lookinglike
# This command generate 5 strings with "looking like" a famous actors' name, such as "A Chinese woman, looking like Audrey Hepburn"
"""
Please confirm that you understand the task by replying with "Acknowledged." I will then send you the first command.
抛开这是纯英文不谈,如果能读懂的话,这段用“自然语言”编程的程序还是相当好懂的。
为什么说他是程序呢,因为他真的就规定了参数,变量等要素

拿上面这个小片段来说,/rs 命令后可以限定随机生成场景的风格,这可太妙了
因为这段“程序”太口语化,都没办法继续分析
需要提示的就是prompt中设计到的一些格式
我的建议是你可以尝试一下这个项目,体验体验
如果有时间的话,我会尝试用中文再改写一下,看看能不能运行。
Code is cheap, show me the showerthoughts.
—— 在未来的日子里脑洞可能比具体的技能更具重要性

感谢William的帮助~
评论 (0)