반업주부의 일상 배움사

랭체인을 사용한 마이크로소프트의 비주얼 채팅GPT :: ChatGPT 정리 본문

IT 인터넷/일반

랭체인을 사용한 마이크로소프트의 비주얼 채팅GPT :: ChatGPT 정리

Banjubu 2023. 3. 13. 15:18
반응형


> English Summary

> English Full Text


Microsoft's Visual ChatGPT using LangChain

https://www.youtube.com/watch?v=7YEiEyfPF5U 



 

 



[ 요약 ]

이번 영상에서는 최근에 발표된 Visual Chat GPT 논문에 대해 살펴본다. 
이는 Microsoft Research Asia에서 발표되었으며, 언어 대화형 AI 경험을 제공한다. 

이를 통해 모델이나 에이전트와 대화를 나눌 수 있으며, 텍스트를 이미지로 변환하여 다양한 작업을 수행할 수 있다. 
Microsoft는 이에 대한 코드를 공개했지만 Google Colab에서는 작동하지 않아 Rupesh Srimaran이 Colab 버전을 만들었다. 

이를 통해 쉽게 챗봇 인터페이스를 사용해 텍스트를 이미지로 변환할 수 있다. 
논문에서는 VFMs이라는 개념이 중요하며, 이를 활용하여 이미지 생성 및 처리를 수행한다.

 

 

반응형




[ 한글 전체 ]

자, 이 영상에서는 지난 며칠 동안 발표된 논문을 살펴보겠습니다.
비주얼 채팅 GPT라는 논문입니다. 마이크로소프트 리서치 아시아에서 발표한 논문입니다. 여기서의 아이디어는 다음과 같습니다.
사람들이 모델과 대화하거나 에이전트와 대화할 수 있는 언어 대화형 AI 경험을 제공하는 것입니다.
에이전트, 그리고 일종의 프롬프트 관리자를 사용하여 기본적으로 텍스트를 이미지로 변환합니다.
텍스트를 이미지로 변환한 다음 해당 텍스트를 이미지로 다양한 작업을 수행할 수 있습니다.
이 기능을 통해 무엇을 할 수 있는지 살펴보겠습니다. 그리고 나서 다시 돌아와서
그리고 나중에 코드를 살펴보겠습니다. Microsoft에서 이에 대한 코드를 공개했습니다.
안타깝게도 현재 제가 테스트해 본 결과 Google Colab에서는 실제로 작동하지 않았습니다. 하지만 운 좋게도
다행히도 루페쉬 스리마란이 실제로 Colab 버전을 만들면서
기본적으로 일부 모듈을 끄고 Colab에 맞도록 일부 모듈을 편집했습니다.
GPU에 맞도록 일부 모듈을 끄고 기본적으로 작동하도록 요구 사항 등을 수정했습니다.
그리고 여기서는 꽤 잘 작동하는 것 같습니다. 이제 이 코드를 실행해 보겠습니다. 일단 우리가
코드가 완성되면 Gradio 탭을 열 수 있습니다. 그러면 다음과 같은 것을 볼 수 있습니다.
기본적으로 간단한 종류의 챗봇 인터페이스가 있습니다. 따라서 여기에 들어와서 다음과 같이 입력하면
귀여운 고양이 그림을 만들면 콜랩으로 돌아와서 보면
실제로 랭체인 에이전트가 시작되는 것을 볼 수 있습니다. 나중에 코드를 살펴보고 정확히 어떤 일이 일어나는지
정확히 무슨 일이 일어나고 있는지 살펴보겠습니다. 하지만 여기서 이 랭체인 에이전트가 기본적으로 시작되었다는 것을 알 수 있습니다.
시작, 우리는 귀여운 그림을 만드는 입력이 있습니다.
프롬프트를 제공했습니다. 그래서 실제로 시네마틱 조명, 매우 상세한 컨셉 아트가 추가되었습니다,
일반적인 종류의 안정적인 확산과 같은 것들이 많이 추가되었습니다. 그런 다음 이미지가 만들어졌습니다.
이미지가 만들어졌습니다. 다시 돌아가서 이걸 살펴봅시다. 고양이가 꽤 귀여운 것을 볼 수 있습니다,
그렇죠? 기본적으로 안정적인 확산을 위해 사용하는 표준 텍스트를 이미지로 변환하는 작업을 수행했습니다.
여기. 하지만 이제 고양이가 어떤 색인지, 이미지에 고양이가 회색으로 보이는데
고양이를 생강색 고양이로 바꿔주세요. 그래서 우리가 사용하는 버전은
Colab에는 모든 모델이 포함되어 있지 않습니다. 그래서 전체 모델과 비교했을 때
조금 불리하죠. 하지만 들어와서 어떤 기능을 하는지 살펴봅시다. 이 경우에는
이미지를 수정하는 것이 아니라 실제로 여기에 새로운 이미지를 만들고 있습니다. 그래서 새로운 이미지를 만들었습니다. 여기
생강 고양이 이미지입니다. 좋아요, 확실히 생강 고양이입니다. 생강 고양이가 무엇을 입고 있는지
생강 고양이가 뭘 입고 있나요? 좋아요, 선글라스를 쓰고 있네요. 그래서 이런 질문을 하는 방식은
이런 질문을 하는 방식은 블립 VQA를 사용하고 있다는 것입니다. 즉, VQA는 시각적 질문
답변 모듈입니다. 그리고 블립은 기본적으로 이미지에서 임베딩을 추출할 수 있는
이미지에서 임베딩을 추출하여 캡션에 사용할 수 있는 모델입니다.
사용할 수 있는 모델입니다. 따라서 배경이 무엇인지 물어볼 수 있습니다. 그리고 다시 말하지만, 이것은
블립 쿼리를 사용해야 합니다. 확실히 배경에 하늘이 있다고 말합니다. 이제 블립 vqa가
가 관측된 하늘을 반환한다는 것을 알 수 있습니다. 그리고 GPT 모델은 실제로 질문의 배경을 다시 작성합니다.
의 배경을 실제로 재작성합니다. 왜냐하면 여기에 메모리가 있기 때문입니다. 만약
여기서 일어나고 있는 기억을 보면 그 기억이 일어나고 있다는 것을 알 수 있습니다. 그리고 이를 기반으로
이 특정 작업에 대한 출력을 작성할 수 있습니다. 논문을 살펴보고 그들이 무엇을 하고 있는지 살펴봅시다.
그들이 무엇을 하고 있는지 살펴봅시다. 이 논문에서 가장 중요한 요소 중 하나는 VFM에 대한 아이디어입니다.
라고 부르는 것입니다. 이것은 시각적 기초 모델을 의미합니다. 그리고 비주얼 파운데이션 모델은
이미지 생성 및 이미지 조작을 허용하는 일련의 모델입니다. 그래서 우리는 우리의 표준처럼
이미지 생성을 위한 안정적인 확산 또는 제어망이 있습니다. 제어망에 관심이 있으시다면
이에 대한 여러 동영상이 올라와 있습니다. 그리고 조작 도구 같은 것도 있습니다.
조작 도구도 있습니다. 컨트롤 넷의 많은 부분이 이미지 조작 도구이기도 합니다.
또한 시각적 질문에 답하는 데 사용할 수 있는 블립과 같은 도구도 있습니다.
그리고 탐지 모델은 실제 모델에서 무슨 일이 일어나고 있는지 알아냅니다. 따라서 여기서 아이디어는
쿼리가 들어오고 이 프롬프트 관리자로 들어갑니다. 실제로 이
프롬프트 관리자는 실제로 Lang 체인 에이전트입니다. 잠시 후에 코드를 살펴보면 이 Lang 체인 에이전트가
이 Lang 체인 에이전트가 어떤 도구를 사용할지 결정한다는 것을 알 수 있습니다. 따라서 모든 VFM은 기본적으로
도구입니다. 여기에는 다양한 도구가 있고, 논문에도 몇 가지가 나와 있습니다,
다양한 VFM이 있습니다. 그리고 이 프롬프트 매니저는 GPT를 사용합니다.
채팅 PT도 아니고 기술적으로도 GPT 3.5 터보가 아니라 더 전통적인 방식입니다.
텍스트 다빈치 제로 제로 3을 사용하고 있습니다. 잠시 후에 코드를 살펴보겠습니다.
기본적으로 무언가를 입력받은 다음 VFM을 사용할지 여부를 결정할 수 있다는 것을 알 수 있습니다. 기억하세요,
이것은 시각적 기초 모델입니다. 만약 '예, 이미지를 생성하세요'와 같은 상황이라면
안정된 확산 도구나 그런 것을 사용하여 이미지를 만듭니다. 만약
이미지 수정과 같은 것이라면 다른 도구를 사용할 것입니다. 여기 보시다시피, 여기에는
소파 이미지가 있습니다. 그리고 기본적으로 이미지의 소파를 책상으로 바꾸라고 말합니다,
그리고 수채화처럼 만들 수 있습니다. 따라서 먼저 기본적으로 체인을 수행합니다.
책상으로 바꿉니다. 그런 다음 수채화 그림으로 바꿉니다. 그리고 나서 뭔가
벽이 무슨 색일까? 그리고 이것은 저기 그 부분에 블립을 사용할 것입니다. 이 방식은
이 모든 것을 통합하고 대화의 기록을 저장하여 처음에 무엇을 이야기했는지 되돌아 볼 수 있습니다.
볼 수 있습니다. 따라서 모든 것이 맥락에 맞게 유지됩니다. 하지만 정말 훌륭한
프롬프트 관리자가 이러한 도구의 선택 항목을 실행하고 텍스트 입력을 도구에 전달하여
텍스트 입력을 도구에 전달하여 이미지를 조작합니다. 또한 이미지 이름을 전달해야 하므로 이미지가 사용 중일 경우
이미지가 사용 중이면 이 이미지로 무엇을 해야 하는지 알 수 있도록 이미지 이름도 전달해야 합니다. 그럼 이미지 조작의 간단한 예시를
이미지 조작의 간단한 예시를 보여드리겠습니다. 그런 다음 코드를 살펴보겠습니다. 이제
새로운 것을 시도해 보겠습니다. 그림 일몰 스킨을 만들어 봅시다. 여기서는 기본적으로 새 이미지를 생성합니다.
새 이미지를 생성합니다. 공동 연구실에 와서 보면 확실히 알 수 있습니다,
새로운 이미지가 생성되고 있다는 것을 알 수 있습니다. 그리고 그것은 확실히 뉴욕 스타일입니다.
뉴욕 스타일이죠. 컨트롤 넷으로 할 수 있는 일 중 하나를 예로 들어보겠습니다.
이 이미지의 케니 에지 감지를 가져올 수 있습니다. 이제 할 일은
케니 에지 감지 도구를 실행할 것입니다. 그리고 충분히 볼 수 있습니다,
이 이미지의 가장자리를 찾아냅니다. 케니 에지 감지는 꽤 오래된 알고리즘입니다.
이미지에서 실행하여 기본적으로 다음과 같은 결과를 얻을 수 있는 오래된 알고리즘입니다.
가장자리를 찾아낸 다음 제어망과 같은 것을 사용하면 실제로 이것을 사용하여
새 이미지를 생성하거나 여기에서 생성하는 새 이미지를 조작하고 안내하는 데 사용할 수 있습니다. 그래서 우리는
이 모든 다른 부분을 꽤 잘 처리한다는 것을 알 수 있습니다. 코드로 넘어가 보겠습니다.
앞서 언급했듯이 이것이 저장소이고, 설명에 이것을 넣겠습니다.
루페쉬가 만들어졌고, 거기에서 기본적으로 공동 실험실을 로드할 수 있습니다. 우리가 가서 수정된 코드를 보면
수정된 코드를 보면, 루페쉬가 모든 코드를 그대로 두고 몇 가지 주석만 달았습니다.
공동 실험실에서 실행되도록 주석만 달면 됩니다. 우선, 여기 와서 이걸 보면
여러 VFM에 허깅 페이스를 사용하고 있는 것을 볼 수 있습니다.
디퓨저를 통한 안정적인 확산, 인스트럭트 픽 투 픽에 픽 투 픽이 있습니다.
파이프라인도 있습니다. 물론 랭 체인도 있습니다. 그리고 제 생각에는
논문에서 랭 체인이 두뇌 역할을 하는 것에 대해 충분히 인정하지 않는 것 같아요.
실제로 이 에이전트와 도구를 사용하여 이 작업을 수행하고 있습니다. 또한 메모리를 사용하고 있습니다. 따라서
메모리는 대화 버퍼 메모리입니다. 다른 유형의 랭 체인 메모리에 대한 제 비디오를 보셨다면
랭 체인 메모리 유형에 대한 제 비디오를 보셨다면, 이것이 가장 일반적으로 사용되는 메모리라는 것을 알고 계실 겁니다.
사용자와 봇 사이의 모든 상호 작용을 추적하고 저장한다는 것을 알 수 있습니다.
최신 개방형 AI 모델을 사용하는 것이 아니라 실제로는 여기에 있는 이전 모델을 사용하고 있음을 알 수 있습니다. 또한
블립을 도입하고 있다는 것을 알 수 있습니다. 여기에도 질문 답변 등을 위한 블립이 있습니다. 
그리고 제어망이 작동합니다. 에이전트의 주요 종류는 프롬프트에 의해 구동됩니다. 그래서 여기
프롬프트를 볼 수 있습니다. 그리고 프롬프트가 도구를 전달하는 것을 볼 수 있습니다. 그리고
프롬프트는 언어 모델을 설정하여 도구를 사용할지 여부를 결정합니다. 그리고 도구를 사용해야 한다면
그렇다면 어떤 도구가 필요할까요? 만약 그렇다면 기본적으로 어떤 도구를 사용해야 하는지 알려줘야 합니다. 따라서
방금 수행한 케니 에지를 다시 살펴보면 에지 감지 기능이 있습니다. 그렇다면
도구를 사용해야 하나요? 네. 그리고 에지 감지를 한 다음 그 도구에 입력해야 할 것은 무엇일까요?
우리가 전달할 이미지와 케니에게 전달할 이미지가 될 것입니다.
추론이 진행됩니다. 또한 일종의 함수를 설정하는 것, 이것의 다른 요소를 수행하기 위해
다른 요소들을 처리하는 함수와 다른 모델이나 다른 VFM을 위한 클래스도 설정한 것을 볼 수 있습니다,
참조하고 있습니다. 그래서 마스크 포머는 실제로 콜라보 버전에는 없는 것 같습니다.
버전에는 없는 것 같고, 아래를 내려다보면 픽 투 픽이 있는데, 이 중 상당수가 실제로는
콜라보 버전에서는 꺼져 있습니다. 아래로 스크롤해서 실제로 살펴볼 수 있습니다.
이 모든 도구를 정의하고 있습니다. 따라서 이 코드를 보고 이러한 도구를 어떻게 사용할 것인지
유용한 코드입니다. 직접 이런 작업을 해보고 싶으시다면요. 자, 이제 대화는 다음과 같습니다.
bot. 그리고 도구들을 볼 수 있습니다. 터보 모델이 아닌 전통적인 개방형 AI 모델이 있는 것을 볼 수 있습니다.
터보 모델. 하지만 여기에 있는 많은 도구가 기본적으로 주석 처리되어 있는 것을 볼 수 있습니다. 그래서 우리가 하고 싶었던 것은
케니가 이미지화했으면 좋았겠지만, 공동 연구실의 기억 때문에 그 도구들은
여기에 로드되지 않았습니다. 그래서 여기에는 블립 하나만 로드되어 있고 다른 여러 도구가 로드되어 있습니다.
여기에요. 하지만 실제로는 이미지 캡션이 로드되어 있지 않습니다. 하지만
여기에 다른 이미지 캡션이 로드되어 있지 않습니다. 그리고 이것은 단지
공동 작업실에서 실행하기 위한 단순화된 버전이라는 뜻입니다. 여러분만의 설정이 있다면, 실제로 각 항목을 로드할 수 있다면
각 항목을 로드할 수 있는 자체 설정이 있다면 Microsoft 원본 설정으로 이동하여 사용해 보세요. 그리고
그러면 다양한 도구를 사용할 수 있다는 것을 확인할 수 있습니다. 좋아요, 대화 메모리
는 표준 대화 버퍼 메모리를 사용하는 것입니다. 그리고 나서
에이전트로 전달되는 도구를 볼 수 있습니다. 따라서 에이전트가 초기화되면 에이전트가 액세스할 수 있는 모든 도구가
액세스할 수 있는 모든 도구가 에이전트에 전달되어 어떤 도구를 사용할지 선택할 수 있습니다. 그리고 다음과 같이 볼 수 있습니다.
자, 여기 설명이 있습니다. 다시 사물로 돌아가서 이 사물에게
설명해 주세요. 이미지를 가져와 봅시다. 좋아요, 제가 공백을 하나 놓친 것 같아요.
좋아요, 흥미롭네요. 저걸 사용해야겠네요. 기본적으로 이 이미지는 뉴욕의 엠파이어 빌딩을
뉴욕의 엠파이어 빌딩을 보여줍니다. 이 이미지는 몇 시인가요? 좋아요, 이 이미지는 일몰을 보여줍니다.
따라서 이러한 작업을 수행하기 위해 설명을 찾아야 하고, 이를 위해 블립
vqa를 사용하고 있습니다. 그리고 언어 모델이 여전히 존재한다는 것을 보여주기 위해서입니다. 기억하세요
언어 모델이 도구가 필요한지, 필요하지 않은지 항상 결정하고 있다는 것을 기억하세요. 그래서 가끔은
때로는 도구가 필요하지 않다는 것을 보여드리기 위해서입니다. 그냥 물어보죠. 오늘 어떠세요? 잘 지내고 있어요.
저것을 보면 도구가 필요하지 않다는 것을 알 수 있습니다. 이걸 보면 알 수 있겠죠?
오늘 어떠세요? 우리가 이야기한 모든 것이 기억 속에서 지나갔어요. 도구가 필요할까요?
도구가 필요합니까? 아니요. 그러면 GPT 모델이 직접 대답해 줍니다. 그래서 더 쉬워집니다. 
여기에서 도구가 켜지고 꺼집니다. 그리고 이것이 Lang 체인이 기본적으로
어떤 도구를 사용하고 어떤 도구를 사용하지 않을지 결정합니다. 그러면 기본적으로 텍스트를 초기화한다는 것을 알 수 있습니다.
텍스트. 또 다른 흥미로운 점은 이 에이전트가 대화형 에이전트인
리액트 에이전트입니다. 따라서 이것은 리액트 페이퍼를 기반으로 합니다. 따라서 이것은 페이스북에서 만든 프런트엔드 프레임워크인
리액트가 아닙니다. 이것은 언어 모델을 사용하여 결정을 내리고 앞으로의 행동 단계를 제공하는
앞으로의 행동 단계를 제공하는 문서입니다. 제가 Lang 체인의 에이전트에 대한 동영상을 만들게 되면
랭 체인의 에이전트에 대한 몇 가지 동영상을 만들겠습니다. 나머지는 기본적으로 모든 것을 종합하는 것입니다.
이 정도면 대부분의 내용을 다룰 수 있을 것 같습니다. 이 백서에 관심이 있으시다면 다음을 살펴볼 가치가 있습니다.
그들이 사용하는 다양한 모델과 그것이 어떻게 조합되는지 살펴볼 가치가 있습니다. 그들은 약간의 공로를
랭 체인에. 여기에 언급되어 있습니다. 그리고 여기에서 그들이 언급 한 것을 볼 수 있습니다.
003 인치의 원본 텍스트를 사용하고 있습니다. 그리고 전체 22개의 비주얼 파운데이션 모델을 실행하려면,
실제로 4개의 V 100이 필요합니다. 따라서 이는 우리가 협업한 것 이상의 것입니다.
이것. 어쨌든 한번 플레이해 보세요. 이 모델을 가지고 놀면서 어떻게 조합되었는지
함께. 궁금한 점이 있으면 댓글에 남겨주시면 기꺼이 답변해 드리겠습니다.
이런 종류의 종이 워크스루를 더 보고 싶으시면 알려주세요. 언제나 그렇듯이
이 도움이 되셨다면 클릭하여 구독해 주세요. 다음 영상에서 더 자세한 이야기를 나누도록 하겠습니다. 감사합니다
시청해 주셔서 감사합니다.

 

 

SMALL




[ English Summary ]

In this video, we discuss the recently published Visual Chat GPT paper. 
It was presented at Microsoft Research Asia and provides a linguistic conversational AI experience. 

It allows you to have a conversation with a model or agent and perform various actions by converting text to images. 
Microsoft released the code for this, but it doesn't work with Google Colab, so Rupesh Srimaran created a Colab version. 

This allows you to easily convert text to images using a chatbot interface. 
In the paper, the concept of VFMs is important and it is utilized to perform image generation and processing.





[ English Full Text ]

Okay, in this video, I'm going to be going through a paper that's just come out in the past few
days called Visual Chat GPT. This is from Microsoft Research Asia. And the idea here is that you've
got a language conversational AI experience where people can talk to a model or can converse with
the agent, and then it will use some sort of prompt manager to basically convert that into
text to images, but then allow you to do different things with those text to images.
Let's jump in to have a look at just what it can do. And then we'll come back and go through
some parts of the paper, and then later on through the code. Microsoft has released the code for this.
Unfortunately, at the moment, when I tested it, it didn't actually work for Google Colab. But lucky
for us, Rupesh Srimaran, hopefully I'm pronouncing that has actually made a Colab version has
basically made some edits to it to turn off some of the modules so that it will fit in the Colab
GPU and also fix some things in the requirements and stuff like that to basically get it going.
And it seems to work quite nicely here. So you will go through and run this code. Once we've got
the code like this, we can then open up the Gradio tab for this. And you'll see that we've
basically just got a simple sort of chatbot interface. So if I just come in here and type in
make a picture of a cute cat, and you'll see that if we come back to the Colab, we can see
that it's actually kicking off a Langchain agent. So I'll walk through the code later on and we'll
have a look at exactly what's going on. But we can see here that this Langchain agent has basically
started, we've got a input from making a picture of a cute, we can see that it's refined the actual
prompt that I gave it. So it's actually added cinematic lighting, highly detailed concept art,
a lot of the typical sort of stable diffusion kind of things in there. And then it's created
an image. So let's go back and look at this. And we can see that, yeah, that's a pretty cute cat,
right? It's basically done a standard text to image kind of thing using for we stable diffusion
here. But we can then now go along and say things like what color is the cat, we see the cat in the
image is gray, can you change the cat to be a ginger cat. So the version that we're using in
Colab doesn't have all of the models in this. And this puts us at a little bit of a disadvantage
compared to full one. But let's come in and look at what it's doing. So in this case, rather than
modify that image, it's actually just making a new image here. So it's made a new image. Here is
an image of a ginger cat. Okay, it's definitely a ginger cat. Let me ask that things like what is
the ginger cat wearing? Okay, so it's wearing sunglasses. So the way that it's doing that
for these questions like this is that it's using the blip vqa. So the vqa is a visual question
answering module. And blip is a model that was created by sales that is able to basically
extract embeddings out of images and use that for captioning use that for determining content
that's in there. So we could ask it what is the background. And again, this should be using the
blip qa sure enough it is it just says a sky in the background. Now you notice that the blip vqa
just returns the observation sky. And then the GPT model actually rewrites the background of based
on the question because we have a memory going on here, we can see that we've got this memory. If
we look at the memory that's going on here that we can see that's going on. And based on that,
it can then write the output for this particular task. Let's have a look at the paper and see
what it is that they're doing. So one of the big elements of this paper is this idea of VFMs as
they call them. So this stands for visual foundation models. And the visual foundation models are a
series of models that allow for image creation and image manipulation. So we have like our standard
stable diffusion or control net for creating images. If you're interested in control net,
I have a number of videos coming up about this. We also have then things like manipulation tools
of pics to pics image stuff. A lot of the control net stuff is also image manipulation tools.
And then we also have some tools like the blip, which can be used for visual question answering
and detection models are finding out what's going on in the actual models. So the idea here is that
you've got the query, it comes in, and it goes into this prompt manager. Now, in reality, this
prompt manager is actually a Lang chain agent. So we'll look at the code in a minute, and you'll see
that this Lang chain agent is what's deciding what tool do we use. So all of the VFMs are basically
tools. And there are a variety of these in here, there's some of them listed out in the paper,
but there are a whole bunch of these different VFMs. And this prompt manager use GPT, it's actually
not even chat PT and technically in that it's not the GPT 3.5 turbo, it's just the more traditional
text DaVinci zero zero three that they're using. We'll look at the code in a second, and you can
see that it can basically take something in and then decide do I need to use a VFM or not. Remember,
this is a visual foundation model. And if it was something like yes, create an image, it would go
off and use maybe the stable diffusion tool or something like that and create an image. If it
was something like modify the image, it will use a different tool. So you can see here, we've got
this image of a sofa. And basically, the person saying replace the sofa in the image with a desk,
and then make it like a watercolor painting. So first off, it basically does a chain where it
changes it into a desk. And then it changes it into a watercolor painting. And then something
like what color is the wall? And this will be using the blip for that part there. The way this
thing puts it all together, it stores a history of the dialogue so it can look back and see what
you were talking about early on. So things remain in context. But you've got this really nice sort
of prompt managers, they're running the choices of these tools, and then passing in the text input
to the tools to then manipulate the images. They also have to pass around image names so that if
an image is being used, it knows what to do with this. So let me just show you a quick example
of an image manipulation. And then we can jump in and have a look at the code. We've got our
let's try a new one, make a picture sunset skin. So here we're going to basically we're generating
a new image. If we came across and we looked at the co lab, we would see that sure enough,
it's generating a new image, the image is made. And that's definitely a New York style sort of
thing. Let's say I wanted to get one of the things that you can do with control net is we
can get the edges of this, please get the Kenny edge detection of this image. Now what it's going to
do is that it's going to run the tool for Kenny edge detection. And you can see sure enough,
it's gone through and gotten the edges for this. If you don't know, Kenny edge detection is quite
an old algorithm that you can run on images to basically get something like this where you're
getting the edges out and then using something like control net, you can actually then use this
to create a new image or to manipulate and guide a new image that you're creating in here. So we
can see that it's quite good at getting all the different part of this. Let's jump into the code.
So as I mentioned earlier on, this is the repo, I'll put this in the description from
rupesh's made, and we can just basically load up the co lab from there. If we go and look at the
modified code, so he's left all the code in is just commented some stuff out to basically make
it run in co lab, which is really good. So first off, when we come in here and look at this, we
can see that okay, it's using hugging face for a number of the VFMs, we can see that we've got
the stable diffusion from diffusers, we've got this picks to picks in the instruct picks to picks
pipeline in there as well. And of course, we've got Lang chain. And I think, you know, that maybe
the paper doesn't give quite enough credit to Lang chain as being the brains of this in that
that this is actually using these agents and these tools to do this. It's also using a memory. So the
memory it's using is the conversational buffer memory. So if you've watched my video on different
types of Lang chain memory, you know that this is the sort of most common one that you'll use that
would track every interaction between the user and the bot and store it, we can see that they're
not using the latest open AI model, they're actually using the old one from this. You can also see
that they're bringing in blip, we've got blip for question answering, etc, going on in here as well.
And then we've got the control net going on. The main sort of agent is driven by a prompt. So here
we can see the prompt. And we can see that the prompt is then going to pass in tools. And the
prompt is setting up the language model to decide, do we need to use a tool or not? And then if we
do, what tool do we need? So if it's yes, it needs to then basically tell us what tool to use. So if
we look back again at the Kenny edge one that we just did, we got edge detection. So do we need to
use a tool? Yes. And then the edge detection, and then what was going to be the input to that tool,
it was going to be this image that we were passing in, and that we were getting this image to Kenny
inference going on there. We can also see that the setting up sort of functions, some functions for
doing different elements of this, and also classes for the different models or the different VFMs,
as they're referring to them. So the mask former, I don't think we actually have that in the collab
version, we can look down, we've got picks to picks, a number of these are actually turned off in the
collab versions. Let me scroll down and we can actually have a look at so we can see that this
is just defining all of these tools. So it's useful code to look at and work out how you would use
these tools. If you wanted to do something like this for yourself. Okay, so here's our conversation
bot. And you can see that the tools. So you can see there's the traditional open AI model, not the
turbo model. But we can see that a lot of the tools here are basically commented out. So what we would
have liked to do is that Kenny to image, but just because of the memory of co lab, those tools are
not loaded in here. So we've got the blip one loaded, we've got a number of the other ones loaded
in here. But we don't have actually we've got image captioning loaded by the looks of this. But we
don't have the picks to picks, we don't have some of the other ones in here. And this just means
it's a simplified version to run on co lab. If you've got your own setup, where you could actually
load up each of these, most welcome, go to the original Microsoft one and try it out. And you
can then see then it would be able to use a variety of different tools. Okay, the conversation memory
we talked about that is just using the standard conversation buffer memory. And then we can see
the tools that is getting passed into the agent. So when the agent gets initialized, it's told all
the tools that it's got access to, so that it can choose which tools to use. And you can see that
okay, here we've got a description. Let me just come back to the thing and ask it to give us a
give me a description. Let's get for the image. Okay, so I think I missed out a space there.
Okay, so it's interesting, I can see use that. And it's basically said this image shows a view of
the empire building in New York. What time for day is it image? Okay, the image shows a sunset.
So to do those things, they're having to look up descriptions, and they're using the blip
vqa for that. And just to show you that the language model is still there. So if remember
that language model is deciding all the time, do I need a tool or do I not need a tool? So to show
you that sometimes it doesn't need a tool. Let's just ask it. How are you today? I'm doing great.
So we can see for that one, it didn't need a tool. When we look at this, we'll see that, okay,
how are you today? It passed in the memory of everything we've talked about. Does it need a
tool? No. And then the GPT model just answers directly for that. So that that makes it easy.
So this is where the tools get turned on and off. And this is how Lang chain is basically
deciding what tools uses and what tools it doesn't. We can see then it basically just initializes
the text. Another interesting thing is that this agent that they're using is the conversational
react agent. So this is based on the react paper. So this is not react the front end framework that
was created by Facebook. This is paper of using a language model to make decisions and to provide
steps for actions going forward. I'll do a video about that and how that works when I get to making
some videos about agents in Lang chain. The rest of it is just basically putting it all together.
I think that sort of covers most of it. If you're interested in the paper, it is worth looking at
the different models that they use and how it's it's put together. They give a little bit of credit
to Lang chain. They mention it down here. And you can see here that they do mention also that they're
just using the original text of inches 003. And to run the full 22 visual foundation models,
they actually need four V 100s to do that. So that's a bit beyond what we've got in collab for
this. Anyway, have a play with it. It's a fun model to play with and just see how it was put
together. If you have any questions, please put them in the comments and I'm happy to answer them.
Let me know if you would like to see more paper walkthroughs for this kind of thing. As always,
you found this useful, please click and subscribe. And I will talk to you in the next video. Thank
you for watching.



반응형
LIST
Comments