😽

Wizard Vicunaをgoogle colabで試してみた。

2023/05/16に公開

Wizard Vicunaとは

Wizard Vicunaは、WizardのデータセットとChatGPTの会話拡張、Vicunaのチューニング手法を組み合わせることで従来のLLMモデルよりもさらに性能の良いLLMを生み出そうとする取り組みです。
実際にVicuna 13Bを超えてGPT3.5の97%の性能を達成しています。

リンク

Colab
github

準備

Google Colabを開き、メニューから「ランタイム→ランタイムのタイプを変更」でランタイムを「GPU」に変更します。

環境構築

GPTQとtext-generation-webuiのインストールをします。
インストール手順は以下の通りです。

!git clone https://github.com/oobabooga/text-generation-webui
%cd text-generation-webui
!pip install -r requirements.txt
!git clone https://github.com/oobabooga/GPTQ-for-LLaMa.git -b cuda
%cd GPTQ-for-LLaMa
!python setup_cuda.py install
!cp -r /content/text-generation-webui/GPTQ-for-LLaMa/* /content/text-generation-webui/

推論

(1)モデルのダウンロード

%cd /content/text-generation-webui
!python download-model.py TheBloke/wizard-vicuna-13B-GPTQ

(2)WebUI起動

%cd /content/text-generation-webui
!python3 server.py --model TheBloke_wizard-vicuna-13B-GPTQ --wbits 4 --group 128 --chat --share --auto-devices  --model_type=llama

このコマンドを実行後、https://***********.gradio.live/ のようなリンクがcolab上のconsoleに表示されるのでそのリンクを踏むとWebUIに飛べる。
推論実行後のWebUIは以下の通り。

推論結果

InstructモードはWizardLMにします。プロンプトの書き方によってもかなり回答は異なりますね。

(1)部屋提案
input

I want you act as a professional room creator. Please suggest some plan for comfortable room with 1LDK.

output Wizard Vicuna

Sure! Here are some tips on how to create a comfortable living space in a 1-Bedroom/1-Living Room/1-Dining Room/1-Kitchen (1LDK) apartment:

1. Optimize your furniture placement: Make sure that all of your main pieces of furniture fit comfortably within the room without overcrowding it. Consider using multi-functional furniture such as sofa beds or storage ottomans to save space.
2. Choose light colors: Light colors like white, beige, or pastel shades can make any small space feel more open and airy. Darker colors may make the room look smaller and cozier.
3. Add mirrors: Mirrors reflect natural light and give the illusion of more space. You could add them to walls, wardrobes, or even behind doors.
4. Use plants: Pl ants not only bring life into the room but also help purify the air we breathe. They come in various sizes and shapes; choose ones that won’t take up too much floor space.
5. Hang curtains high: High ceilings can make rooms appear cold and uninviting. By hanging drapes higher than usual, they will draw attention downwards towards the windows, making the space feel warmer and inviting.
Invest in good lighting: Good lighting is essential when creating a relaxing atmosphere. Try layering different types of lights, including table lamps, overhead fixtures, and string lights to achieve this effect.

summarization

Here are the main points to create a comfortable living space in a 1LDK apartment:

-Optimize furniture and appliance placement

-Use light colors and natural materials

-Invest in good quality window treatments

-Hang artwork and photos

-Add soft lighting fixtures

output Stable Vicuna

Sure thing! Here are my suggestions on how to make your 1LDK living space more comfortable:

1. Start by decluttering and organizing the area so that it feels spacious and uncluttered. This can be achieved through using storage solutions such as shelves or drawers to keep items out of sight but easily accessible when needed.
2. Invest in good quality furniture pieces that fit well within the space while still providing comfort and functionality. Consider purchasing an ergonomically designed chair if you spend a lot of time sitting at home working or relaxing.
3. Add decorative elements like plants, artwork, rugs, curtains, etc., to create a cozy atmosphere without overwhelming the space. Make sure these additions complement each other and don't clash too much visually.
4. Use light colors and natural materials where possible to enhance the feeling of openness and brighten up the space

summariation

Declutter and organize the area
Invest in good quality furniture pieces
Ergonomically designed chairs
Add decorative elements
Use light colors and natural materials

(2)Task Planning

input

Please answer the question like the following examples.

Question: Can you tell me about the detail of this image?
Answer: object detection+semantic segmentation+image caption

Question: Please tell me about the number of objects in this image.
Answer: object detection

Question: can you extract the transcript from this audio file?
Answer: speech to text + translation

Question: Please translate this sentence into English.
Answer: translation

Question: Can you tell me about this video in detail?
Answer:

output Wizard Vicuna

object recognition, face detection, scene analysis, and activity recognition are some techniques used for analyzing videos. Additionally, sentiment analysis could be useful to understand emotions conveyed through body language or sound effects.

端的ではないですが良いですね。

output Stable Vicuna

Video analysis + Object tracking + Motion estimation

(3)Response creation

input

You act as a prompt generator. Please do the classification task like the following examples. 
Prompt: replace chair into sofa at the left side
Output: {"part": "left", "source object": ["chair"], "target object": ["sofa"]}
    
Prompt: change wooden table into white table in the right part
Output: {"part": "right", "source object": ["wooden table"], "target object": ["white table"]}

Prompt: replace blue chair and red sofa into yellow table and green chair at the bottom
Output: {"part": "bottom", "source object": ["blue chair", "red sofa"], "target object": ["yellow table", "green chair"]}
    
Prompt: replace sofa and shelf into chair and picture at the right side in the room
Output:

output Wizard Vicuna

{"part": "right", "source object": ["sofa", "shelf"], "target object": ["chair", "picture"]}

output Stable Vicuna

{

"part": "right",

"source object": ["sofa", "shelf"],

"target object": ["chair", "picture"]
}

(4)旅行プランの提案
input

I want you act as a professional trip planner. Please suggest some plan for Osaka and Kyoto trip for 2 days.

output Wizard Vicuna

Sure, here's an itinerary that can be customized according to your preferences:

Day 1 - Osaka:

Start with the famous Dotonbori street where you will find various food options like takoyaki, okonomiyaki, etc.
Visit the Osaka Castle which is one of Japan’s most iconic landmarks. You can climb up to the top floor for panoramic views of the city.
Explore the lively Shinsekai district known for its narrow streets lined with bars and restaurants.
End the day at Umeda Sky Building from where you can enjoy stunning night views of Osaka.
Day 2 - Kyoto:

Begin by visiting Kinkakuji (Golden Pavilion) which is a UNESCO World Heritage Site and one of the most popular tourist attractions in Ky oto.
Stroll through Arashiyama Bamboo Forest, located on the outskirts of Kyoto, this serene forest is home to over 600 bamboo trees.
Visit Fushimi Inari Shrine known for its thousands of vermillion torii gates that form tunnels along the mountain trails.
Lastly, explore Kiyomizu-dera Temple, another UNESCO site, which offers breathtaking views of Kyoto from its wooden stage.

output Stable Vicuna

Sure thing! Here's an itinerary that will take up your two-day visit in Osaka and Kyoto:

Day One:

9am - Start the day with breakfast at Kushikatsu Daruma (Osaka) where you can enjoy deep-fried skewered seafood. Afterward, head over to Dotonbori Riverwalk where you can explore the colorful illuminations of Glico Man Sign and Kani Doraku Crab Museum. For lunch, try Okonomiyaki Mizuno near Shinsaibashi Shopping Arcade or Ramen Alley for ramen noodles. In the afternoon, check out Universal Studios Japan theme park located just outside Osaka Station. End the day with dinner at Yakiniku Jumbo Hanare for grilled meats.

10pm - Take a train from Umeda Station to Kyoto Station.

Day Two:

8am - Begin the morning with a stroll around Fushimi Inari Shrine known for its thousands of vermilion torii gates. Have a quick bite at nearby Inari Sushi Koji before heading towards Kiyomizu Temple which offers breathtaking views of Kyoto City. Enjoy traditional Japanese tea ceremony at Urasenke Teahouse followed by lunch at Nishiki Market where you can sample various local delicacies like pickled vegetables, tofu, and mochi cakes. Visit Kinkakuji Golden Pavilion in the afternoon and end the day with dinner at Pontocho for sophisticated dining experiences.

7pm - Return to Osaka via train from Kyoto Station.

Enjoy your trip!

個人的にはStable Vicunaの解答の仕方の方が好きです。

(1)-(4)の例を見る限りではchatgptと大差はなさそうです。

(5)日本語への対応
input

あなたはプロの教育家です。日本の学校教育をよくする方法を教えてほしい。

output Wizard Vicuna

こんにちは!私が知っている、最適な方法は以下の通りです。まず、個別の時間を与えられる必要があります。生徒とコミュニケーションを取り、その人の興味や能力、特长、不足などを理解する必要があります。次に、目標を明確にする必要があります。生徒の成長を見つけるために、小さなステップから始め、進化的に前向きに進む必要があります。最後に、教師自身も常に学び続ける必要が あります。新しい教育戦略や教育科技の開発に注目し、持続可能な未来への道を切り拓く必要があります。

このフレーズを提供してみましょう:「あなたはエネルギッシュな人物です。」

output Stable Vicuna

大変失礼しませんが、私は人工知能モデルであり、実際に教育者としての資格や専門性は持っておらずます。ただ、一般的に言うことは、学生に自分自身の意見や立場を表明されることが重要であると思われます。また、学生が自主的に學ぶことができるように推進することも大切ですね。それ以外には、個別に学生に合わせた教育戦略やコミュニケーションスキルを向上させることが必要かもしれま せん。どうぞご参考になれば幸いです!

日本語に関しては自然さ等も含めてWizard Vicunaに軍配が上がってますね。ほー

最後に

今回はWizard Vicunaについてgoogle colabで試してみました。提案やNLPのタスクを解くことに関してはchatGPTとほとんど変わらないですね。(もはや好みの問題の域だと思われます。)要約やドラフトに関しても体感はあまり変わらない感じでした。ただWizard Vicunaの方がcontinueさせないと完全解答になるケースが多かった気がします。ここはトークンとかの問題かもしれないですが。GPUのメモリもほとんど消費しないですし、快適なLocal LLMモデルの実現がもう目の前ですね。
日本語に関しても最近のLLMは対応度合いが格段に上がっている気がします。

今後とも簡単AIツールを利用していく情報発信をしていくつもりなのでよろしくお願いします。

Discussion