服务器开启ssk key登录

ls -al ~/.ssh

检查ssh key 是否已经存在

ssh-keygen -t rsa -C

默认生成一个,一路回车3次就OK了

生成后,会在/root目录下,也就是当前用户的目录下,生成一个.ssh隐藏目录,目录中会有【id_rsa】和【id_rsa.pub】两个文件,一个是私钥,一个是公钥

撰写 Text Prompt 注意事项

Midjourney 跟 ChatGPT 在 prompt 的使用上有很多不一样的地方,本章会详细介绍下 Midjourney 的 text prompt 区别。

语法
首先 Midjourney 基本上是不懂语法的,所以即使你语法错了,只要词对了,也能生成图片。。

另外,不懂语法也导致了另一个问题:prompt 不是越长越好。特别是各种定语从句,它根本就不懂,还不如把指令用逗号隔开,一个个输入。以下是官方推荐的语法建议:

使用形容词+名词的词序来替换介词短语。
hair flowing in the wind 应该改为 flowing hair
a carrot for a nose 应该改为 carrot nose
使用非常具体的动词来替换介词短语。
a girl with a flashlight 应该改为 a girl using a flashlight
a girl with a big smile on her face 应该改为 smiling girl
最后, Midjourney 是不会区分大小写的。

单词
在单词的部分,Midjourney 跟 ChatGPT 有点类似,它对同义词的理解也不是很好。比如举两个例子:

big (大)这个词,到底指多大?越具象的大,对于 Midjourney 来说,效果越好,比如用 gigantic 就比用通用的 big 好。
cats(猫)这个词是个复数,但到底是多少只?对于 Midjourney 来说,two cats(两只猫)比 cats 更明确。
另外,Midjourney 还能用 emoji 代替单词(我觉得本质上 emoji 也是单词),算是一个比较有意思的特性。

与其说不要什么,不如说要什么
这个跟 ChatGPT 类似,你应该将你想要的东西说清楚,而不是告诉 Midjourney 不要什么,如果你想让 Midjourney 不生成某样东西,就需要用到 参数 — no。

你不说,模型就会随机给你
因为图像信息的信息量远超过文字,所以很多时候,Midjourney 会随机填充一些内容给你,它既是缺陷,也是亮点功能。因为当你不在 prompt 里说明这些词时,你就能获得发散的结果。

如果你想减少这些随机性,就需要用到一些 prompt 框架(或者所谓的模板),本教程会由浅入深地将这个框架教给你。

参数
Midjourney 还有一点跟 ChatGPT 有较大差异,它允许你在 prompt 里加入参数,而且这些参数相对来说一致性都比较好,所以如果你想实现的功能,参数里支持,那优先使用参数,而不是在主体里描述。你会在后续的教程中学到如何善用参数。

Midjourney测试

IMG_8957.JPG
Prompt:
A conceptual visualization of the skin-fascia interface, illustrating the molecular layers and their arrangement in a stylized manner, with geometric shapes and patterns representing the different components of the tissues, and subtle gradients and textures to convey depth and dimension, creating a visually intriguing and abstract depiction of the intricate molecular structure within the skin-fascia gap, Artwork, digital artwork with a minimalist and contemporary aesthetic, using vector graphics software and digital painting techniques --ar 1:1 --q 2 --s 750 --v 5.1

IMG_8958.JPG
Prompt:
night, annihilation movie style, hiny white female robot full-body Porcelain and hammered matt silver showing cracked inner working, light from within, ,fireflies around , firefly , swamp, cinematic lighting, amazing composition , 3d octane render, unreal engine, hyper realistic, soft illumination, trending artstation, environmental concept art, all in grey, 8k trending on ArtStation --ar 1:2 --q 2 --s 250

IMG_8959.JPG
Prompt:
realistic cinematic photo of supergirl as demon, neon red, wallpaper, agfa vista 400, --ar 10:16 --v 5.1

IMG_8960.JPG
Prompt:
realistic full-body photo of a Ironman/Devil hybrid, armored devil wings, epic background --ar 10:16 --v 5.1

Midjourney Prompt 基本结构

在 Midjourney 的官方介绍文档里,介绍了最简单的 Prompt 结构是这样的:
1.png

但我觉得上面那个 Prompt 过于简单了,反而 Advanced Prompt 更适合学习:

2.png

Image Prompts(选填)
Prompt 分成三个部分。第一个是 Image,这个属于选填,可以填也可以不填。

先说下这个 Image URL 是干什么用的,有很多玩法,比如将两张图合并为一张,大家可以看看下面这个例子,我就是将一个大理石雕像和花朵的图片上传到 Discord:

3.png

然后让 Midjourney blend (混合)一下(后续 blend 章节会介绍更多用法)后,就能生成下面这种图片:

4.png
需要注意的是:

你输入的是图片的 URL 地址,而且必须是公开可访问的地址。
图片格式仅支持 png、gif 和 jpg。
你最多只能放两张图的 URL,或者一张图的 URL + 一段话。
如果你不想将图片上传到一些图床服务器,也可以使用 Discord 的图床,你可以私聊 Midjourney Bot 然后通过上传图片的方式,将图片先发到 Discord 上,然后右键复制图片链接,像这样:

Text Prompt
这个就是你希望 AI 生成的图片的描述。这个有非常多的技巧,后续会详细介绍。这里我想说下,Midjourney 跟 ChatGPT 有点不一样:

无法理解句子结构和语法:Midjourney 没法像 ChatGPT 那样懂你说的话。类比的话,Midjourney 更像是命令式编程,ChatGPT 更像是声明式编程,你需要给 Midjourney 完整的指令,它才有可能生成你满意的结果。
Midjourney 有违禁词的设计:有些词语无法输入

GPT信息提取

化繁为简——信息提取
场景介绍
介绍完信息总结,再聊聊信息提取,我认为这个场景是继场景 3 推理以外,第二个值得深挖的场景。这个场景有非常多的有意思的场景,比如:

将一大段文字,甚至网页里的内容,按要求转为一个表格。按照这个思路你可以尝试做一个更智能的,更易懂的爬虫插件。
按照特定格式对文章内容进行信息归类。
第二个可能比较难理解,举个 OpenAI 里的例子,它的 prompt 是这样的(为了有足够空间显示内容,我仅节选了 text 里的部分内容,完整内容,可以点击这里查看):

Extract the important entities mentioned in the article below. First extract all company names, then extract all people names, then extract specific topics which fit the content and finally extract general overarching themes
Desired format:
Company names: <comma_separated_list_of_company_names>
People names: -||-
Specific topics: -||-
General themes: -||-

Text: """Powering Next Generation
Applications with OpenAI Codex
Codex is now powering 70 different applications across a variety of use cases through the OpenAI API.

May 24, 2022
4 minute read
OpenAI Codex, a natural language-to-code system based on GPT-3, helps turn simple English instructions into over a dozen popular coding languages. Codex was released last August through our API and is the principal building block of GitHub Copilot.

Warp is a Rust-based terminal, reimagined from the ground up to help both individuals and teams be more productive in the command-line.

Terminal commands are typically difficult to remember, find and construct. Users often have to leave the terminal and search the web for answers and even then the results might not give them the right command to execute. Warp uses Codex to allow users to run a natural language command to search directly from within the terminal and get a result they can immediately use.

“Codex allows Warp to make the terminal more accessible and powerful. Developers search for entire commands using natural language rather than trying to remember them or assemble them piecemeal. Codex-powered command search has become one of our game changing features.”

—Zach Lloyd, Founder, Warp

Machinet helps professional Java developers write quality code by using Codex to generate intelligent unit test templates.

Machinet was able to accelerate their development several-fold by switching from building their own machine learning systems to using Codex. The flexibility of Codex allows for the ability to easily add new features and capabilities saving their users time and helping them be more productive.

“Codex is an amazing tool in our arsenal. Not only does it allow us to generate more meaningful code, but it has also helped us find a new design of product architecture and got us out of a local maximum.”

—Vladislav Yanchenko, Founder, Machinet"""

Prompt 有点长,我解释下,它是让 AI 将文章里的重点内容进行抽离,并将其根据特定格式进行输出。要求将文章里提到的公司、人名、主题都按照 comma separated list(按逗号空格分开)的方式罗列出来。

最后的 output 是这样的:

Company names: OpenAI, Microsoft, GitHub, Pygma, Replit, Warp, Machinet
People names: Emile Paffard-Wray, Amjad Masad, Zach Lloyd, Vladislav Yanchenko
Specific topics: GPT-3, OpenAI API, Azure OpenAI Service, GitHub Copilot, Pygma, Replit, Warp, Machinet
General themes: Natural language-to-code, Productivity, Problem solving, Creativity, Learning