AI在用 | 一個超級提示,用Claude 3生成神經網路架構動畫

机器之能發表於2024-03-20

機器之能報導

編輯:珠頸斑鳩

以大模型、AIGC為代表的人工智慧浪潮已經在悄然改變著我們生活及工作方式,但絕大部分人依然不知道該如何使用。

因此,我們推出了「AI在用」專欄,透過直觀、有趣且簡潔的人工智慧使用案例,來具體介紹AI使用方法,並激發大家思考。

我們也歡迎讀者投稿親自實踐的創新型用例。

由於 Claude 3 引入了對 Manim 動畫引擎的支援,廣大網友正在嘗試為任何抽象概念建立動畫,昨天的案例曾在網際網路上引起轟動。今天,我們再分享一個 X 使用者利用 Claude 3 和 Manim 建立神經網路架構動畫的用例。

AI在用 | 一個超級提示,用Claude 3生成神經網路架構動畫

AI在用 | 一個超級提示,用Claude 3生成神經網路架構動畫

影片連結:https://mp.weixin.qq.com/s/NlyKJP3H0fnDeFRpg7XZdg

  • 案例地址:https://twitter.com/minchoi/status/1770105075043647495

重申一下,完整實現動畫功能,使用者需要安裝 Manim 庫並建立適合執行的本地環境或 Google Colaboratory 平臺。

進入 Claude.ai ,在對話頁面輸入提示( Prompt )。這位作者輸入了一個超級提示:

圖片來自@minchoi

翻譯下來,大意是使用 Manim 創作一個解釋神經網路架構概念的動畫。為了確保動畫位於視口範圍,作者提出了 11 條細緻要求。視口是指動畫在螢幕上顯示的區域或視窗,它有著固定的大小和寬高比。

我們簡單解釋其中幾條的意思。

第 1 條是指,使用 Manim 的 VGroup 功能將相關元素(比如文字、影像)組合在一起,作為一個單元進行管理。也就是說,製作神經網路的動畫時,可以將每一層神經元節點組成一個 VGroup,無論是移動、縮放,都可以整體處理,非常方便。

第 2 條是指,當建立的物件(如圖形、文字等)太大或太小時,它們可能無法完全顯示在視口內,又或者佔據了過多的螢幕空間。這個時候,就可以使用" scale() "方法,對物件大小進行縮放調整。

再比如,第 5 條是指,動畫中通常會有一些敘述性文字,用來解釋動畫過程或提供背景資訊。如果將整段敘述一次性顯示在螢幕上,很可能會擋住動畫部分。所以,需要將這些敘述性文字拆分成較小的片段,每個片段對應動畫中的某一步驟或場景。為了將減少對動畫的干擾,通常會將這些文字定位在視口底部,同時方便閱讀。

第 11 條是指,Manim 提供了幾種常用的動畫效果,使用者可以根據不同場景選擇適合的效果。比如 Write ,可以模擬文字在螢幕上的書寫或逐漸出現的過程;Create,可以用它來呈現諸如一個圓形或方形在畫面中逐漸成型出現的過程。此外,還有大家熟悉的 FadeIn、FadeOut 的效果。

這是執行 Claude 3 生成程式碼後的結果:

AI在用 | 一個超級提示,用Claude 3生成神經網路架構動畫

來自@minchoi

影片連結:https://mp.weixin.qq.com/s/NlyKJP3H0fnDeFRpg7XZdg

如果對提示中任何細節問題有疑問,都可以要求 Claude 3 做解釋。根據我們的使用體驗,Claude 3 很擅長深入淺出地講解清楚。建立成功後,Claude 3 還會提示是否作出其他修改(比如增加網路的層數等), 你可以根據它的引導逐步完成動畫效果的改善。

慶幸的是,提供案例的使用者還公開分享了迭代幾次後的超級提示模板,用來生成任何概念的動畫演示(如下)。該使用者也強調,這個超級模板也仍然不完美,使用者可能仍然需要透過與 Claude 3 交談進行微調。

Using Manim, make an animation explaining the concept of [Desired Concept]. Ensure that the animation stays within the viewport by following these guidelines:

1. Use VGroup to group related objects together and manage them as a single unit.
2. Scale objects and groups using the scale() method to ensure they fit within the viewport.
3. Position objects and groups using methods like next_to(), shift(), and to_edge() to control their placement relative to other objects or the edges of the viewport.
4. Use appropriate buffering values when positioning objects to maintain sufficient spacing and avoid overlapping.
5. For text labels associated with specific objects or groups, position them relative to the corresponding object/group using next_to() with the desired direction (e.g., UP, DOWN, LEFT, RIGHT). Ensure that the labels are not overlapping the objects by adjusting the buffer values.
6. Ensure that text labels have a contrasting color and sufficient font size to be clearly visible against the background and other objects.
7. Break down the narration text into smaller segments that correspond to each animation step. Create separate Paragraph objects for each narration segment with a smaller font size and a specified width to ensure the text stays within the viewport. Position each text object at the bottom of the viewport using to_edge(DOWN, buff=0.5).
8. Use arrange() to layout multiple objects or groups horizontally or vertically with consistent spacing.
9. Adjust the camera settings, such as the frame_width and frame_height, to control the viewport size and aspect ratio if needed.
10. Test your animation at different resolutions and aspect ratios to ensure that objects remain within the viewport and are properly positioned across different devices.
11. Add a title for the concept using the Text class with a larger font size and different color. Position the title at the top of the viewport using to_edge(UP, buff=0.5).
12. Use the following animations for different purposes:
* `Write`: Animates the writing or appearance of text on the screen.
* `Create`: Animates the creation of a mobject on the screen.
* `FadeIn`: Animates the gradual appearance of a mobject on the screen.
* `FadeOut`: Animates the gradual disappearance of a mobject from the screen.
Think step by step and give me the full code without any errors

不過,人無完人,該功能也並非完美無缺。

一些網友讓 Claude 3 生成高階的數學概念動畫,結果發現這些動畫對於對使用者的理解基本上沒什麼幫助。要求生成的動畫越複雜,越有可能搞砸。

X 網友 @_dhruvvvvv_ 嘗試讓 Claude 3 生成球體定理、黎曼級數定理和距離公式動畫,效果都不理想。

圖片

球體定理動畫,來自@_dhruvvvvv_

圖片

黎曼級數定理動畫,來自@_dhruvvvvv_

圖片

距離公式的動畫,來自@_dhruvvvvv_

撇開動畫演示,在文字解釋上,Claude 3 仍然善於深入淺出。這是我們讓 Claude 3 解釋黎曼級數定理的效果。我們確實看懂了,你呢?

如果以後對任何抽象概念有疑問,也不妨請這位“老師”詳細解釋一下。
圖片我們的新專欄會帶來更多不同大模型的案例演示,歡迎大家留言評論並給出改進建議。

相關文章