AI 또는 풀스택 개발에 어려움을 겪고 계신가요? 맞춤형 조언, 기술 통합 등 유니티 전문가가 도와드리겠습니다. 다음 연락처로 문의하세요. [email protected].

스탠포드 알파카의 데이터 세트를 사용한 GPT-J의 인스트럭트 버전

NLP Cloud에서는 소수 학습을 사용하지 않고도 자연어로 된 사람의 지시를 제대로 이해하기 위해 GPT-J를 인스트럭트 모델로 미세 조정할 수 있는지 알아보고 싶었습니다. Flan-T5, BloomZ, 스탠포드 알파카 등 오픈 소스 커뮤니티에서 흥미로운 결과를 얻은 다른 시도가 있었기 때문에 알파카의 데이터 세트를 사용해 GPT-J에서도 동일한 시도를 해보고 싶었습니다. 결과는 매우 좋았습니다!

스탠포드 알파카

단발성 학습 VS 자연어 지침

생성형 AI 모델은 기본적으로 사람의 요청을 잘 이해하지 못합니다.

이러한 텍스트 생성 모델이 원하는 내용을 이해하도록 하려면 가장 좋은 해결책은 소수 샷 학습을 사용하는 것입니다. 소수 샷 학습에 대한 특별 가이드를 만들었습니다. 여기에서 찾을 수 있습니다.. GPT-J는 소수의 샷 학습으로만 제대로 작동하는 매우 유능한 모델의 좋은 예입니다.

이러한 예제를 구축하는 데 일반적으로 많은 시간이 걸리지 않더라도 이러한 AI 모델을 올바르게 사용하려는 초보자에게는 여전히 매우 혼란스러울 수 있습니다. 사람처럼 자연스럽게 질문하는 것이 훨씬 쉽습니다.

예를 들어 GPT-J로 맞춤법 오류를 수정하고 싶다고 가정해 보겠습니다. 다음은 사용해야 하는 프롬프트의 예입니다:

I love goin to the beach.
Correction: I love going to the beach.
###
Let me hav it!
Correction: Let me have it!
###
It have too many drawbacks.
Correction: It has too many drawbacks.
###
I do not wan to go
Correction:

보시다시피 이것은 복잡하지는 않지만 간단하지도 않습니다. GPT-J를 적절히 미세 조정하면 '인스트럭트' 모델로 전환할 수 있으므로 이제 다음과 같은 질문을 할 수 있습니다:

Correct spelling and grammar from the following text.
I do not wan to go

그리고 다음을 반환합니다:

I do not want to go.

훨씬 낫지 않나요? 어떻게 하면 이를 달성할 수 있을까요?

스탠포드 알파카

며칠 전 스탠포드 알파카가 출시되었습니다. 이것은 Facebook에서 개발한 라마 모델의 미세 조정 버전입니다. 이 프로젝트에 대한 자세한 내용은 여기를 참조하세요.

기본적으로 스탠포드 알파카 팀은 사람의 명령어로 구성된 상당히 작은 데이터 세트(52,000개 예제)를 바탕으로 Llama를 미세 조정하여 최첨단 명령어 모델을 만들어냈습니다. 흥미로운 점은 더 큰 언어 모델(GPT-3)을 사용하여 프로그래밍 방식으로 이 데이터 세트를 생성했다는 점입니다. 데이터 세트는 여기에서 다운로드할 수 있습니다.

NLP Cloud에서는 이 데이터 세트를 사용하여 GPT-J를 미세 조정하려고 시도했고, 놀랍도록 좋은 결과를 얻었습니다!

GPT-J에 지시

이제 허깅 페이스 허브에 새로운 Instruct GPT-J 모델을 추가하여 쉽게 사용할 수 있습니다: 모델을 보려면 여기를 클릭하세요..

허깅 페이스 트랜스포머를 사용하여 모델을 사용하는 방법은 다음과 같습니다:

from transformers import pipeline
import torch

generator = pipeline(model="nlpcloud/instruct-gpt-j-fp16", torch_dtype=torch.float16, device=0)

prompt = "Correct spelling and grammar from the following text.\nI do not wan to go\n"

print(generator(prompt))

다음은 시도해 볼 수 있는 몇 가지 프롬프트입니다:

Write a short story about space.\n

Generate a C++ program that sorts a list of integers in ascending order.\n

Paraphrase the following text.\nAfter a war lasting 20 years, following the decision taken first by President Trump and then by President Biden to withdraw American troops, Kabul, the capital of Afghanistan, fell within a few hours to the Taliban, without resistance.\n

Summarize the following text.\nFor all its whizz-bang caper-gone-wrong energy, and for all its subsequent emotional troughs, this week’s Succession finale might have been the most important in its entire run. Because, unless I am very much wrong, Succession – a show about people trying to forcefully mount a succession – just had its succession. And now everything has to change. The episode ended with Logan Roy defying his children by selling Waystar Royco to idiosyncratic Swedish tech bro Lukas Matsson. It’s an unexpected twist, like if King Lear contained a weird new beat where Lear hands the British crown to Jack Dorsey for a laugh, but it sets up a bold new future for the show. What will happen in season four? Here are some theories. Season three of Succession picked up seconds after season two ended. It was a smart move, showing the immediate swirl of confusion that followed Kendall Roy’s decision to undo his father, and something similar could happen here. This week’s episode ended with three of the Roy siblings heartbroken and angry at their father’s grand betrayal. Perhaps season four could pick up at that precise moment, and show their efforts to reorganise their rebellion against him. This is something that Succession undoubtedly does very well – for the most part, its greatest moments have been those heart-thumping scenes where Kendall scraps for support to unseat his dad – and Jesse Armstrong has more than enough dramatic clout to centre the entire season around the battle to stop the Matsson deal dead in its tracks.\n

이 모델은 미세 조정된 방식이므로 지침 끝에 항상 새 줄을 사용해야 한다는 점에 유의하세요.

하드웨어 요구 사항

이 모델은 미세 조정된 모델의 fp16 버전으로, NVIDIA 테슬라 T4와 같은 16GB VRAM이 탑재된 GPU에서 매우 잘 작동합니다.

품질 측면에서 fp32 버전과 fp16 버전 간에 차이를 느끼지 못했습니다.

결론

GPT-J는 이미 매우 좋은 모델이었으며, 이제 인스트럭트 모델로 사용했을 때 더욱 좋아졌습니다.

이제 누구나 이 기술을 통해 자신의 AI 생성 모델을 인스트럭트 모델로 전환할 수 있습니다!

위 내용에 대해 궁금한 점이나 의견이 있으시면 언제든지 문의해 주세요!.

François
NLP 클라우드의 데이터 과학자