반업주부의 일상 배움사

(한국어) ChatGPT보다 성능이 더 뛰어나다? _ 메타의 언어모델, LLaMA 코드분석 :: ChatGPT 정리 본문

IT 인터넷/일반

(한국어) ChatGPT보다 성능이 더 뛰어나다? _ 메타의 언어모델, LLaMA 코드분석 :: ChatGPT 정리

Banjubu 2023. 3. 13. 12:41
반응형


> English Summary

> English Full Text


Does it perform better than ChatGPT? _ Meta's language model, LLaMA code analysis

https://www.youtube.com/watch?v=jvYpv9VJBOA 



 

 



[ 요약 ]

Facebook은 최근 GPT 모델의 크기를 줄여 650억 개의 파라미터로만 구성된 LLaMA라는 새로운 모델을 출시했습니다. 
크기는 작아졌지만 더 많은 데이터와 시간으로 학습한 LLaMA는 더 큰 규모의 GPT3 모델보다 더 나은 성능을 발휘합니다.

이 모델의 학습 파라미터도 공개되었으며 연구 목적으로 사용할 수 있습니다.
최근 LLaMA가 유출되어 오픈 소스로 다운로드할 수 있게 되었지만, 여전히 연구 목적으로만 사용할 것을 권장합니다.

이 모델은 24GB 메모리가 있는 GPU에서 실행할 수 있으며, 학습 데이터는 최대 650억 개의 파라미터까지 사용할 수 있습니다.
LLaMA는 Facebook Research의 오픈소스 프로젝트이며, 코드를 다운로드하여 사용할 수 있습니다.

하지만 코드가 복잡하기 때문에 맥락에 따라 코드를 검토하고 관련 부분에 집중하는 것이 좋습니다.
전반적으로 LLaMA는 AI 분야에서 흥미로운 발전이며, 연구 목적으로 사용할 수 있게 됨에 따라 이 분야가 더욱 발전할 것으로 기대됩니다.

 

반응형




[ 한글 전체 ]

페이스북이 라마라고 하는 또 모델도 또 추가로 공개를 했어요
얘는 특징이 뭐냐면 똑같은 GPT인데 사이즈를 65 빌리엄으로 좀 줄인 상태에서
더 많은 시간과 더 많은 데이터로 학습을 했더니 GPT3에 175 빌리엄보다 성능이 좋더라 라고 해서 공개한 거에요
모델도 공개했구요 학습파라미터도 공개는 여기서 공개했다고 하는데
여기도 신청을 해야만 연구 목적으로 제공을 하고 있는데요 이게 또 요즘에 약간 풀렸어요 인터넷상에서
좀 이따 한번 보여드릴 건데요 그래서 요거를 저희가 한번 보고 저희도 연구 목적으로는 공부해 볼 수 있잖아요
일단 사이즈는 65 빌리엄 정도 인데 요거 링크는 나중에 가보시면 되구요 페이스북은 후발주자답게 대부분 이제 오픈형으로 나가고 있어요
오픈 AI가 지금 계속 API 형태로 유료 모델로 갈 수 있는 것이구요 페이스북은 사실은 자기네 검색엔진도 아니겠다
그럴 이유도 없기 때문에 이제 오픈으로 가고 있습니다 이번 시간에는 라마 모델을 나온 지 얼마 안됐기 때문에
얼마 자세히 알겠냐만 GPT 코드를 베이스로 한번 봐봤으니 이번에 프로덕션 레벨에 GPT3보다 더 성능이 좋다라고 하는
그리고 학습도 충분히 했던 그 모델을 우리가 한번 살펴보는 시간을 가질 것이구요 요런게 있어요 라마 오리진이라고 하는 코드가 페이스북에서 공개한
라마라고 하는 오픈 소스 모델의 링크인데요 얘가 나온 뒤로 바로 얼마 되지 않아서 사실 라마 모델의 학습
파라미터가 다 뚫려버렸어요 이게 토렌트에 누가 올려버렸어 그리고 또 어떤 사람은 허깅 페이스에다가 올려버렸어요
보시면 13빌리온 30빌리온 스몰 인트 하프 16비트 플러트형 다 올라가 있어요 거기다가 65빌리온 하프 플러트형 인트 4
이게 뭐냐면 경량한 모델까지 다 올려놨다는 거거든요 그 다음에 여기 가면은 실제 모델을 다운도 받을 수 있어요
토렌트 올린 걸 기점으로 아예 풀렸다고 보시면 되요 사실은 막을 것도 없는게 연구 목적으로 풀어야죠 사실은 다른 사람 다 풀고 있는데
누구만 푼다는 것도 웃긴데 어쨌든 그래서 지금은 특징을 보면은 학습 데이터도 다운받을 수 있구요
한 24기가 그 gpu 24 메모리 정도 24기가 메모리 정도면 돌려볼 수도 있어요
실제로도 저도 이제 이것까지 다 돌려봤는데 하프까지 그래서 우리가 한번 좀 유의미하게 밟을 필요가 있다 라고 이제 생각하시고 보시면 됩니다
음 왜냐면 성능이 더 좋다고 하죠 gpt 3보다 더 많은 데이터와 더 오랜 시간을 돈을 써 가지고 성능도 더 뛰어나 거기다가 오픈소스다 보니까 16비트
부터 시작해 가지고 다 나와 있어 그래서 더 작은 gpu 로도 돌릴 수 있어 학습 데이터 까지 65 빌리온 까지 다 올라가 있어 거기다가 채 라마라고 해서 실제 채 쥐피티의 rl hf 강화학술 퓸원 피드팩
적용된 코드까지 다 올라와 있어요 여기 보시면 이제 rl hf 가 적용되서 트레이너 파일들이 올라와 있단 말이죠
gpt 코드를 봤으니까 라마 코드를 통해서 gpt 코드의 좀 더 프로덕션 레벨을 먼저 한번 봐 보도록 할게요
설명드려보면 페이스북 리서치의 라마 프로젝트인 것이구요 여기 보면 이제 루트 폴더가 있고 그 안에 또 라마가 있어요
루트에는 그냥 md 파일들은 다 설명 파일이고 여기 파일들이 몇 가지가 있는데 여기 다운로드가 학습 파라미터 다운로드 파일이에요 셀스크립트에요
근데 이제 사실은 이거는 엑세트 코드가 있어야 되는데 여러분이 아까 dl 인가 다른 링크를 통해서 요걸 통해서 다운받을 수도 있는 것이구요
더 빠르게 그러면 실제 사용은 이그 잼플 여기가 하나의 샘플 코드를 보여주는 거 사용을 어떻게 하라고
프럼프트도 있고 하죠 그래서 요 코드를 좀 더 효과적으로 보기 위해서 제가 비주얼 코드로 일단 가져왔어요
중요한 건 저희가 이 코드와 함께 최 라마까지 봐 볼 거예요 그래서 전반적으로 아카데믹 한 이후에 그 실질적인 코드들의 맥락과 흐름을 통해서 마지막 강화
하우스까지도 이렇게 대략 구현하면 되는 거구나 라고 하는 맥락 정도 스킵할 부분은 과감하게 스킵하면서 맥락 위주로 보셔야 됩니다
코드가 길어요 여기에는 이그 잼플과 셋업 이건 다 설치 파일들이에요 결과적으로 이그 잼플만 보면 되겠죠
나머지 뭐 많아 보이지만 다 지워도 되는 거에요 나중에 가져와도 되니까 다 필요 없어요 다 이런 라이젠스 있지만 지금은 잠깐 안 볼 거니까
뭐 설치 파일도 있겠죠 받으시면 돼요 결국은 다운로드 파일도 필요 없잖아요 그렇죠 그러면 뭐다? 이그 잼플 파일 하나가 있는 거야 그러니까 어떻게 쓰세요
그리고 실제로는 여기 라마에 들어가 있어요 라마 코드는 아주 심플해요 결국은 제너레이션 모델 토큰 나이죠
우리가 지금까지 수업을 제대로 따라왔다면 이제는 익숙할 토큰 나이저와 gpt 저희가 수업하면서 설명드렸죠 이거 제너레이션이다
결국 문장 생성하는 기능이 있는 거다 그리고 어떤 모델이라고 했죠 지금까지 배운 발을 바탕으로 좀 매칭도 시켜가면서
gpt 아키틱도 같이 띄워 가지고 같이 바보면 좀 더 좋을 것 같아요 이런 거 한번 봐보자는 거죠 이그 잼플을 한번 봐볼게요
정신 없어 보이니까 잠깐 닫아 놓게요 이렇게 이렇게 어 이그 잼플은 총 3개의 함수로 되어 있네요
메인을 크게 봤더니 아 일단 이 윗부분 불필요한 것들 많이 생략할 거예요 얘네들은 병렬처리를 위한 기능이겠죠
패러럴 세트 모델 패러럴 라고 해서 병렬처리 세팅을 해주는 거니까 이런 걸 볼 필요는 없을 것 같고요
실제 프로덕션 레벨에서 병렬처리까지도 한다면 코드를 보시면 되겠죠 그래서 되게 좋은 노큰소스라고 보시면 될 것 같고요
자 크게 이제 보면은 제너레이터를 가져와 가지고 그쵸 뭔지 모르니까 gpt 뭐라고요 문장을 생성하는 거라고요
그러면 제너레이터에 입력 데이터를 넣어주면 어떤 문장을 넣어주면 어떻게 생성해 주세요가 전부겠죠
되게 단순해요 이 코드가 심플하게 갑니다 프럼프트는 여기 보면 리스트 형태로 들어가 있는데 여러 개를 넣은 거예요 하나만 넣어도 되는데
이런 것도 있을 때 이런 몇 가지를 넣어본 거예요 그랬을 때 각각을 얘가 생성해 주겠죠 그래서 프럼프트를 입력으로 받아서 맥스 제너레이션 랭스
최대 길이 우리 다 본거 있죠 당연히 이제 문장 생성이니까 최대치를 적어주고요
오 여기 처음 보는 펜퍼러처랑 탑피 이런 것들이 있어요 이런 것들이 이제 실전에서는 사용되는 건데 코드 레벨로도 한번 봐볼 수 있겠지만
개념적으로는 문장을 생성할 때 몇 개의 파라미터들이 있어요 하이퍼 파라미터들이 있는데 러프하게 생각해 보면은
문장을 생성할 때 결과적으로 넥스트 문장을 나는 집에 갑니다를 할 때 나는 집에 갑니다
그 다음에 다음에 또 만나요 라고 할 수 있지만 세상에는 이제 다음에 말고도 나는 집에 갑니다 오늘 저녁에 뭐 봐요
나는 집에 갑니다 배고프네요 수없이 많은 문장들이 사실 생성될 수 있죠 그중에서 예를 들어서 확률이 있을 것 같아요
넥스트에 나올 수 있는 확률이 100%가 있는 건 나왔고요 생각보다 이제 높은 확률로 나오는 쫙 예를 들어서 5만개 단어 중에서
확률로 쫙 나열되겠죠 그 중에서 가장 높은 확률 90% 이상만 혹은 98% 이상만을 진정했을 때 탑피 라는 개념을 쓰고요
템퍼러처는 약간 온도라는 개념인데 온도가 낮을수록 되게 춥다 되게 건조해요 사실 정확한 대답만 할 뿐인 거고요
이 온도가 높을수록 되게 따뜻해져 의미가 그러면은 되게 창의적인 자세한 설명 안할게 이걸 보려고 하는거 아니니까
그래서 우리가 활용 확률 분포가 있다고 하면은 어떤 단어 하나가 98%야 나머지는 다 이렇게 한 5% 3% 이래
그럼 대부분 이해가 안나 결정되겠죠 특히 이제 탑피라고 그러면 얘가 결정되겠죠 근데 우리가 대부분 이렇게 하지 말고 온도를 높여주면 이렇게 안하고 좀 비슷비슷하게 맞춰져요
확률을 그래서 선택할 때 나는 오늘 집에 갑니다 다음회가 아니라 오늘은요 아 배고프네요 이런 다양한 단어들을 조금 더 창의적으로 할 수 있는 온도인데
일단 러프하게 이런 하이버 파라미터들이 있을 수 있다 정도만 이해하고 난다면 제너레이터 모델에서 제너레이트 해주는 cpt 처음에 우리 공부할 때처럼 생성이구나로 넘어가면 되겠죠
그리고 나면 프롬프트는 뭐 다양하게 들어오겠죠 하지만 중요한건 로드 모델만 보면 되겠죠
이 로드 모델을 가져와서 뭔가 해주니까 얘만 보면 돼요 뭔가 입력값이 있지만 파라미터들이 있지만 결국은 얘가 하는 일이 뭐겠어요 얘가 아마도
라마 모델을 가져와서 뭔가 처리를 하는 거겠죠 결국은 라마 모델을 리턴해주는 코드인데 파라미터들이 매개 변수들이
다 이렇게 체크 포인트 디렉토리 즉 사전에 저장된 학습 포인트를 가져올 그 콜도 위치라든가 토크나이저 우리는 이제 토크나이저가 있어야 되잖아요 얘는
사전에 학습된 토크나이저가 있겠죠 그 패스라든가 뭐 이런건 이제 병료 처리를 위한 거구요 그 다음에 이제 맥스 세컨스 랭스
시퀀스 그래서 맥스 길이 그 배치 사이드들의 입력값을 가지고 와서 뭔가 해주겠죠 시작을 위해서 시간 해준 것이구요
여기 보면 이제 체크 포인트를 패스해서 뭔가 가져오기 위한 작업들 해주는 거죠 그래서 결과적으로는 뭐냐면 이제 체크 포인트를 읽어오는 건데
아 뭐가 복잡해요? 로폴랭스 병렬 처리 때문에 복잡한데 결과적으로는 체크 포인트를 체크 포인트 패스해서 읽어온다
그러겠죠 그러면 이제 학습 데이터를 여기서 읽어온 거예요 그리고 나서 체크 포인트 디렉터에 보면은 이제 파라미터 제이슨 이라고 하는게 우리가 이제 파일을 다운받으면
이제 특정 폴더 7 밀리언이든 13 밀리언이든 특정 폴더에 관련된 파일들이 같이 들어와요
어쨌든 체크 폴더 디렉토리에서 특정 파라미터라고 하는 제이슨의 파라미터들이 이제 주어지겠죠
제가 이게 그 나중에 쓸쓸해 보겠지만 이렇게 모델 사이즈 이름을 이렇게 쳐서 다운받을 수 있어요 그러니까 77 밀리언 13, 30, 65 이렇게 빌리언 사이즈가 있고요
여기 가장 바깥에는 토크나이저 모델들도 있어요 우리 공부했죠 학습 해가지고 해 놓은 그 모델을 가지고 우리가 읽어서 할 수 있는 것도 있고요
그 안에 이제 폴더 구조도 한번 봐보세요 우리는 이제 만약에 7 밀리언 짜리를 써본다 하면 7 밀리언 밑에 있는 이 모델들이 올라와 있겠죠
이렇게 받을 수 있을 거예요 좀 이따 한번 쓸쓸해 볼게요 그리고 나서 이 파일을 말하는 거예요 이 파일은 뭐가 들어있냐면
이런 게 써 있어요 디멘션이 뭐죠? 인베딩 벡터의 디멘션 이 각들이 모델에서 우리가 인베딩 사이즈 공부했잖아요 토큰을 인베딩 사이즈 몇으로
511로 혹은 연습할 때 4로 3으로 했던 그 디멘션 인베딩 디멘션이 얘는 4096으로 한 거고요
멀티플 이게 이제 그 피드 포워드 네트워크 할 때 얘를 756으로 하고 그 다음에 얘는 헤드 멀티플이고 이게 맞을 거예요 아마 코드를
박으면 되겠지만 그 다음에 헤드의 개수 그 다음에 레이어를 몇 번 반복해 그 다음에 노몰라이즈 할 때 어떤 변수
그 로몰라이즈에 어떻게 입력되는 레이트 값이죠 그리고 어깨 사이즈는 이제 내부적으로 쓰는지 일단은 마이너스로 되어 있는 즉 하이버 파라미터 값이에요
별로 어렵지 않죠 그러면 얘는 우리가 생각하는 그 값들이 들어가 있다고 생각하시면 될 것 같고요
넘어가보면 이 값을 이용해 가지고 여기 하이버 파라미터로 모델의 아귀먼트를 만들어 준 거예요
여기 맥스 시퀀스 사이즈, 맥스 배치 사이즈 그 다음에 파라미터들을 위해서 토탈 모델의 아귀먼트가 만들어졌겠죠 그럼 얘를 가지고 뭔가 할 거 아니에요
그리고 나면 우리가 생각을 하면 뭘 하겠어요 결과적으로 우리가 원하는 건 지금 토크나이저와 모델 가지고 생성하는 걸 할 거
아니에요 그렇기 때문에 여기 보면 토크나이저, 토크나이저를 읽어 와서 여기 보면 모델, 트랜스포머 모델을 가지고
토크나이저는 여기 토크나이저를 통해서 단어의 개수가 몇 개인지를 통해서 보케 사이즈가 아까 마이너스 1로 되어 있었는데 여기서
보케 사이즈를 실제로 넣어 주네요 실제 토크나이저에 있는 단어의 개수를 보케 사이즈로 넣어주고
얘를 이용해서 이제 임패딩 벡터들을 만들겠죠 그리고 나서 트랜스포머 모델을 가지고
여기가 이제 뭐 실제 뭐 어텐션하고 하는, 이게 이제 GPT잖아요 근데 이게 정말 GPT인지 아닌지는 여기 좀 봐보면 되겠죠 그래서 크게 토크나이저와 모델이 있다
나머지는 뭐 당연히 모델로도 스테이픽까지 입력, 체크포인트 입력해주는 거고요 모델을 가져와도 체크포인트, 즉 얘가 GPT니까 GPT 모델을
읽어온 거겠죠 자 그리고 나서 보시면 이제 라마가 여기 보이는, 아 라마의 정체는 파이프라인인거죠
토크나이저를 넣고 모델을 넣어서 즉 라마 제너레이터는 우리 이거 4일차 수업에 살짝 얘기했던 기억나시죠?
퍼킹페이스에서 약간 파이프라인 만들 때 모델과 토크나이저를 넣으면 어떻게 할 수 있죠? 입력을 자연화를 넣으면은
지가 알아서 토크나이저가 잘라주고 인비딩 처리한 다음에 모델을 집어넣어주고 그 결과 값을 또 디코딩도 해줘가지고 나오잖아요
결과적으로 여기서 이제 제너레이터의 프롬프트는 텍스쳐트, 원본 텍스쳐트가 들어가기 때문에 토크나이저를 입력해서 만들어준거예요
즉 라마는 추가적으로 뭔가 하는 것 같아요 GPT 모델과 토크나이저를 통해서 뭔가를 하고 있어요
뭔가가 이제 제너레이터라는 걸로 바뀐거고요 제너레이터는 여기 리턴 해줄 때 라마잖아요
라마 자체는 제너레이터가 라마에요 그럼 우리가 이제 라마가 도대체 뭐냐를 좀 더 코드레벨로 이해할 수 있는 거죠
라마는 모데라고 하는 얘네들이 주장한 사이트 내에 거기가 아니라 좀 더 코드레벨로 한번 봐 보자는거죠
자 그러면 라마는 뭐냐 했더니 라마라는 여기 폴더 밑에 있는 모델, 아귀먼트, 트런스, 트랜스포머, 토크나이저, 라마가 있어요
자 라마는 트랜스포머와 토크나이저가 결합된 거에요 그러면 일단 첫번째 토크나이저부터 보고 트랜스포머 볼까요
토크나이저는 센터스 피스 프로시저라고 나오죠 그쵸 여기 보시면 센터스 피스 우리가 설치해서 토크나이저 공부할 때 배웠던 그 센터스 피스죠
여기 이제 우리가 EOS, EOS 패드 id 값 줬었던거 살짝 기억나시죠? 즉 이 부분은 뭐냐면 코드가 똑같을 수 밖에 없는게
그냥 센터스 피스 라이브를 써서 특정 킷값, Begin of, 자기네들이 지정할 수 있잖아요 문장 전 처리할 때 문장이 시작은요 문장이 끝은요
그 다음에 패딩 값은 뭘로 할 거요 라고 지정해주는 거니까 이 라이브를 용법인 거에요
요걸 가지고 토크나이저를 만들어주는 거 그냥 일반적인 거죠 자 그러면 토크나이저는 고려할게 없어요 우리가 알고 있는 그거구요
그럼 트랜스포머를 이제 라마로 쓴건데 라마부터 봐보고 그 다음에 트랜스포머를 봐보죠
라마는 이 안에 이제 라마가 여기 있잖아요 보니까 제너레이션에 있는게 라마구요 모델 밑에는 트랜스포머가 있구요
토크나이저 밑에는 토크나이저가 있는 거에요 그럼 우리는 이제 트랜스포머는 좀 이따 보고 라마라는 걸 먼저 보기 위해서 제너레이션을 가보죠
자 여기 보시니까 뭐 샘플 탑p 이런 것도 보이네요 라마를 보면 되겠죠 라마가 하는 일이 뭐야
우린 트랜스포머가 뭔지는 알아 라마가 하는 일이 뭐야 라고 보면 제너레이터에서 하는 일만 봐보면 이해할 수 있는 거구요
그러면 제너레이터에서 뭔가를 막 해요 트랜스포머를 먼저 잠깐 봐보죠 왜냐면 토크나이저는 우리가 알던 걘데
아 트랜스포머는 도대체 뭐하는 애지 라고 한번 가볼게요 자 트랜스포머는 여기 모델 밑에 있는 거에요
이 모델 밑에는 여러 개들이 있어요 자 보시면 모델 아규는 그냥 우리 아규먼트 설정해주는 거 있잖아요 그렇죠 이거 그거에요
그냥 하나의 클래스에요 파라미터, 하이퍼 파라미터가 가지고 있는 그리고 나와서 보면은 트랜스포머는 뭐가 있어요?
트랜스포머 블락이 있구요 그 블락 안에는 뭐가 있다고요? 어텐션과 퓨드 포워드가 있는 거죠
트랜스포머에는 트랜스포머 블락이 있고 어텐션과 퓨드 포워드가 있는 거예요
트랜스포머는 이제부터 우리가 제가 보기에 gpt랑 거의 비슷한 것 같은데 그 차이를 잠깐 봐 보자 이거죠
트랜스포머는 보니까 여기 이니트해지고 쭉 포워드를 보면 되는데요 여기 여기 보면은 쭉 위에 가보면은
자 패러로 임베딩이 있구요 임베딩이 있구요 여기 모듈 리스트가 있어요 그래서 여기 보니까 트랜스포머 블락이
모듈 리스트를 통해서 레이어의 개수만큼 반복해서 우리가 알고 있는 트랜스포머 블락이 여기 있는 것 같아요
그 다음에 노멀라이즈 우리가 기억나시죠? rms 노멀라이즈를 썼고 그 다음에 이제 뭐 아웃붓은
컬럼 패럴리미어라고 그래 가지고 최종적으로 보시면 디멘션을 보켓 사이즈로 바꿔주는 마지막 단어 맞축이니까
그쵸? 임베딩을 보켓 사이즈로 바꿔서 소프트맥스 하기 위한 마지막 레이어를 통과시켜 주죠
그러면은 이제 우리가 봤던 것처럼 아 뭔가 트랜스포머 블락에서 뭔가를 막 처리한 다음에 마지막 로몰라이즈 해주죠
그러면 여기 트랜스포머 블락에서 끝나고 여기 마지막 끝나고 나서 로몰라이즈 해줘야 되잖아요
마지막 로몰라이즈 하고 그 다음에 리니어 통과시켜서 문장 맞추고 즉 지금까지 그리고 여기 이제 패럴리 임베딩이라고 해서
인풋 임베딩과 포지션 임베딩이 들어가는 뭔가를 해줄 것 같아요 코드는 좀 더 봐 볼 수 있겠지만 좀 더 들어가 보면
애조차도 페어 스케일 뭐 라이브러리 이렇게 얘네들이 이제 가져다 쓴 거예요 얘가 이제 페이스북에서 만드는 병렬 처리를 위한 뭐
임베딩 그런 기능들인데 결과적으로 얘가 하는 일은 임베딩을 해주는 거겠죠
포클 임베딩 값을 뽑아내는 그런 거겠죠 임베딩 값을 구해서 임베딩 값을 가지고 트랜스포머 블락에서 이제 계속 도는 거잖아요
자 그러면은 트랜스포머 블락만 살짝 더 봐 볼까요 얘는 이제 거의 똑같은 거예요 조금 달라봐야 뭐가 다르다고 하나 정도 다르죠
레이얼 로몰라이즈가 다르다기보다도 rms놈이라는 걸 쓴 것 뿐인 거고요
구조는 똑같으면서 임베딩을 조금 얘는 약간 패러럴 병렬 처리를 위한 임베딩이 들어갔으니까
아마 거의 비슷할 텐데 좀 더 가보면 좀 다른 게 있을 수 있겠죠 그 정도 빼고는 지피트네 라고 이해하시면 되는 건데
그러면 이제 트랜스포머 블락에서 하는 일이 뭐겠어요? 어텐션 피드 포워드 잖아요
여기 위에는 어텐션과 피드 포워드가 들어가 있겠죠 그러니까 어텐션과 피드 포워드가 있고
우리가 중간중간에 쓸 rms가 두 개가 들어갔네요
자 보시면 하나 두 개가 들어가 있죠 그래서 얘를 통과하고 들어갔다가 얘를 통과해서 나왔다가
그 다음에 이런 부분들인데 더하기 자 그러면은 뭔가 입력 값으로 어텐션에 들어갔다가
그 다음에 이거 한번 보자 이거죠 마지막으로 뭔가가 들어가서 노멀라이즈를 통과하고 어텐션에 들어간 다음에 더하고
노멀라이즈를 통과하고 피드 포워도 더하고 나가기 자 그러면 이제 피드 포워드 여기를 봐 볼게요
봤더니 어텐션에 들어가는 입력 값이 노멀라이즈 해주죠 노멀라이즈 해주고 뭐 이건 이제 뭐 마스크 드니까
마스크가 들어가고 스타팅 포인트 뭐 로테이션 도니까 이런 값들이 들어가지만 결과적으로 하는 일은
어텐션 노멀라이즈 노멀라이즈를 한 다음에 그 결과 값을 어텐션에 집어 넣어주는 이 작업을 한거죠 이 두 개를
그쵸 그리고 나서 여기 x를 도했어요 뭐가 복잡해 보이지만 여기 add
그쵸 순서상으로는 노멀라이즈 어텐션 add 잖아요 근데 함수로 봤을 때는 노멀라이즈 그것이 리턴돼서
어텐션에 들어가고 그것이 마지막에 원래 값인 x를 더해 줘서 그 결과 값을 h 라고 한다
h 를 더해 주는 거죠 잔차를 더해 주고 그것이 9들 그러면 얘는 거의 100% 똑같죠 그 gpt 우리가 공부했던 것과
그냥 거의 100% 똑같다고 보시면 되겠죠 뭐 얘가 뭐 다르냐 하면은 다르지 않죠 여기 보시면
노멀라이즈에요 그리고 여기 보면 이제 뭐 차원의 값이 여기 들어가잖아요 계속 계속 계속 그 노멀라이즈를 통과할 때마다 차원이 계속 유지되고 있는
거지구요 자 그러면은 이제 우리는 이렇게 정리해 볼 수 있을 것 같아요 뭐 위에는 이제 뭐 여러가지 함수들은 기능적인 얘기인 거구요
자 결론은 뭐냐면 제너레이션에서 라마 모델을 봤는데 라마 모델은 입력으로 트랜스포머와 토크네이저를 받았죠
토크네이저는 우리가 알던 센터스피스 토크네이저를 가지고 사전에 학습한 그 모델을 가져오고 트랜스포머가 이제 gpt인데
gpt는 받더니 똑같다 rms 노멀라이즈 노멀라이즈 레이어니까 들어가고 그러면 라마가 하는 일은 이제 뭐냐라고만
봐 보면은 이제 우리가 라마를 완벽하게 이해할 수 있겠죠 프럼프터가 이제 길이니까 프럼프터를 받아 가지고
불필요한 이제 파라미터도 받아와서 여기 보면 이제 프럼프터 토크네이저가 있죠 그래서 토크네이저를 통해서
인코딩 이제 여기는 지금 이제 마지막으로 가야될 라마 모델을 안으로 들어온 거에요 얘는 하늘이 뭐겠어요? 자연어를 전
처리해서 모델이 집어넣어주고 그 결과 값을 다시 자연어로 디코딩해서 리턴해줄게 되겠죠?
제너레이트니까요 그래서 마지막에 끝나면 디코드가 됐죠 그리고 디코드 돼서 디코드의 문장이 하나하나 추가되어 마지막
디코드한 최종 문장이 나가는 최종 문장 코너가 있어요 문장을 만들었겠죠 그러면 쭉 올라와봤더니 또 여기서는 뭐예요
토큰을 프럼프터 토큰을 토크네이징해서 인코딩 했잖아요 이 값을 가지고 지금 쭉 보시면
우리가 여기서 이제 뭘 해줘야 된다고요? 값이 왔으니까 트랜스포머 모델에 돌려야겠죠? 그래서 보면 여기에 이제 모델을
모델이 여기네요 모델이 GPT 모델이에요 모델은 뭘 받아요? 토크네이징 돼서 정수화된 그 값을 받겠죠
그럼 여기 중간에 하는 일이 뭐겠어요? 모델이 뭔가 하는 일이 여기 있네요 문장을 랭스 반복해서 토탈 랭스만큼 반복해서죠
아 얘가 하는 일이 문장 생성이겠네요 그쵸? 여기가 반복 생성 문장을 생성해도 반복해서 그쵸?
여기가 이제 하나하나 생성해도 문장의 생성의 결과의 로지시 뭐라고요? 이게 이제 모델이 예측한 그 값인거고요
얘를 소프트맥스로 해서 소프트맥스에서 샘플을 뽑아내는 거잖아요 자 그럼 모델을 한번 봤더니 이 모델이 최종 결과를 뽑아낸게
이 값이 뭐냐면 이거에요 아웃풋 인베딩 값 소프트맥스 하기 전 값 모델은 이 값까지만 던져줘요 아웃풋으로
그걸 로지시라고 표현해 그 로지시를 마지막에 소프트맥스 하면 뭐가 나오죠? 지금 만약에 템플루처가 0보다 크면을 하고 0보다 크지 않으면 즉 마이너스면 무조건 아규맥스 단 하나 정해진 단 하나의 값을 무조건 넥셀 토큰을 정하고
만약에 템플루처 온도가 좀 따뜻하면 소프트맥스를 취하는데 그냥 취하지 말고 여기에 템플루처를 나눠서 약간 평준화 시킨 다음에
그걸 나눠버리면 약간 정교가 되어버리잖아요 그쵸 이 값으로 그리고 나서 확률 값을 샘플 p 탑 p 우리가 지정해 놓은 탑 p 90% 이상이면 90%
이런 것들 매개변수를 처리하는 부분이 이 코드인거에요 코드상으로 되게 쉽죠 그 안에 들어간 코드를 이렇게 되는거에요 아 우리는 하나를 알았네요
마이너스 1이면 무조건 항상 똑같은 애를 생성하는 것을 우리가 알아내네요 온도 값에 따라서 평준화 시키는 부분에 코드 레벨에서는
이렇게 처리한다 템플루처 그리고 나면 우리는 넥셀트 토큰을 얻은 코드를 100% 이해한거죠 이런 짜잘한 것은 효율적인 처리인거에요
효과적 메모를 줄이기 위해서 한거죠 그러면 넥셀트 토큰을 얻어와서 결국적으로 여기서 뭐하겠어요
뭔가 토큰스의 리스트에다가 넣었잖아요 여기다 토큰을 와서 포르프를 돌면서 이 토큰에다가 하나하나 추가하겠죠 넥셀 토큰을
이거 기억나시죠 무조건 하는게 아니라 넥셀트 토큰이니까 전체 인데 현재 커서의 위치에다가 대략 받거나 이런걸 하겠네요
그러면 우리는 코드를 통해서 넥셀트 토큰을 다 모아놓은 것을 가져와서 이니멀레이트 즉 반복해서 토큰을 하나하나 가져오는데
반복해서 i하고 t인데 이제 결과적으로는 하는 일이 여기 보면 뭔가 이제 토큰의 t코드 이 t가 토큰인거잖아요 하나하나씩 추가하는데
그 t를 이제 구할 때 뭔가 이제 처리를 해주네요 아마 이제 전체 쭉 문장을 가져온 다음에 마지막에다가
그 문장이 끝을 알려주는 걸 붙이는 것 같아요 문장이 끝났으면 알려주고 만약에 실패하면 이제 에러가 나는 이런 코드인데 뭐 중요한건 아니고
결국은 에러 처리와 함께 코드를 하나하나 추가하고 마지막에 엔드 오브 시퀀스까지를 추가하는 어떤 문장 생성 코드가 되는거죠
그러면은 이제 대너레이트를 이제 이해한 거죠 그러면 제가 한번 다시 물어보는 거죠 라마가 하는 일은 뭐죠
라마는 뭐죠 라고 제가 붙는다면 라마는 그냥 gpt3 인거죠
단 하나의 차이는 뭐냐면 모델에서 rms 아까 봤을 때 여기서 블락에서 보면 rms 라고 하는 로몰라이저를 썼다 정도
rms 로몰라이즈는 뭐냐면 우리가 로몰라이즈 여기 보면 토치의 디폴트 로몰라이저인거에요 그래서 로몰라이저도 여러가지가 있겠죠
그 중에 하나인거죠 그쵸 요거 빼고는 달라질게 거의 없다고 봐도
그렇죠 이런거 요거 이제 인베딩 어떻게 들어가는지 한번 보면 되겠네요 하지만 더하기는 바꿀게 없죠
바꿀게 없죠 그 다음에 요거 하나 바뀐거죠 더하기 뿐인거죠 그리고 셀프 포텐션도 바뀔게 없죠 결과적으로
바꾸고 싶어도 바꿀게 없는거에요 페이스북이 몇년만에 해봤자 자기네가 이름을 라마라고 바꿨는데 그건 뭐냐면
라마는 여기 최종적으로 여기 모델에서 보시면 모델과 토크나이저를 그냥 결합한 그냥 gpt3 인거죠
그래서 우리가 라마를 제대로 이해했다는 것은 gpt3, 왜냐면 페이스북이 주장한게 라마가 gpt3 를
벤치마킹 했고 gpt보다 더 좋고 충분하다고 했었으니까 지금 우리가 gpt3를 페이스북 레벨 글로벌 레벨의 기업이
전문가들이 프로덕션 레벨로 만든 오픈소스에 대한 코드를 100% 이해했다고 보시면 되는거죠
자 여기까지가 이제 포도 리뷰를 다 해본거구요

 

 

SMALL




[ English Summary ]

Facebook recently reduced the size of its GPT model and released a new model called LLaMA, which consists of only 65 billion parameters. 
Despite its smaller size, LLaMA, trained with more data and time, performs better than the larger GPT3 model.

The model's training parameters were also made public and can be used for research purposes.
LLaMA was recently leaked and made available for open source download, but we still recommend using it for research purposes only.

The model can run on GPUs with 24GB of memory, and the training data is available for up to 65 billion parameters.
LLaMA is an open-source project by Facebook Research, and the code is available for download and use.

However, due to the complexity of the code, it is recommended that you review the code in context and focus on the relevant parts.
Overall, LLaMA is an exciting development in the field of AI, and as it becomes available for research purposes, we can expect to see further advances in the field.




[ English Full Text ]

Facebook also released another model called LLaMA.
This is the same GPT, but with the size reduced to 65 billion.
and we trained it with more time and more data, and it performed better than GPT3 with 175 billion, so we released it.
I disclosed the model and learning parameters here.
This is also available for research purposes only by applying, but this is also a little unraveled recently.
I'll show it to you a little later, so we can take a look at it and study it for research purposes.
First of all, the size is about 65 billion, but you can go to the link later, and Facebook, like a latecomer, is mostly going open now.
Open AI can still go to a paid model as an API, and Facebook is actually not even their search engine.
There's no reason for it to be, so it's going open. This hour, they've just come out with the LLaMA model.
so I don't know a lot of details, but I've seen the GPT code base, and I'm pretty sure that we're going to have a production-level version of that model
and we're going to take a look at a model that we've learned a lot about and here's a link to an open-source model called LLaMA that Facebook has released
to an open-source model called LLaMA that was released by Facebook, and it wasn't long after this guy came out that the training parameters of the LLaMA model
training parameters of the LLaMA model have been broken. Somebody put it on a torrent, and somebody else put it on a hugging pace.
If you look at it, it's got 13 bilion, 30 bilion small int, half 16-bit flats, and then it's got 65 bilion half flats, int 4.
What this means is that I put all the lightweight models up, and then you can go here and download the actual models.
It's like it's been unlocked since I posted the torrent. It's not like there's anything stopping me, I'm just doing it for research. Everyone else is doing it.
It's funny that I'm the only one solving it. Anyway, so now if you look at the features, you can download the training data.
and you can run it on a GPU with 24 gigs of memory, 24 gigs of memory.
Actually, I've run it all the way up to this, and I've run it up to half, so you can look at it and say, "Well, we need to take a meaningful step.
Well, because it's got better performance, it's got more data, it's got more time, it's got better performance than GPT 3, and it's open source, so it's all out there, starting with 16-bit.
so you can run it on a smaller GPU, and the training data is all the way up to 65 bilions, and it's called Chae LLaMA, so it's actually Chae Jupity's RL HF Enhanced Academic Fume One Feedpack.
If you look here, you can see the trainer files are up now with RL HF applied.
We've seen the GPT code, so let's take a look at a little bit of the production level of the GPT code with the LLaMA code.
So this is the LLaMA project from Facebook Research, and if you look here, we have a root folder, and then we have LLaMA inside of that.
In the root, we have just the md files, which are all documentation files, and then we have a couple of files here, and this download is the training parameter download file, which is celscript.
But now you actually need to have the executable code for this, which you can download through this or through the DL authorization or whatever link I gave you earlier.
faster, but the actual use of it is that it shows you one sample code here, and it prompts you how to use it.
and there's prompts, so I've brought it over as visual code to help you see this code more effectively.
The important thing is that we're going to look at the Choi LLaMA along with this code, so overall, after the academic, the context and flow of the actual code, even the final enrichment house is roughly implemented like this.
You're going to want to look at it very contextually, skipping the parts that you're going to skip, like, "Oh, this is roughly how we're going to implement the house.
There's a lot of code here. There's an egg jam, there's a setup, these are all installation files, and eventually you'll only need to look at the egg jam.
There's a lot of other stuff, but you can delete it all. You can get it later. You don't need it all. It's all licensed like this, but we're not gonna look at it right now.
Well, there's an installation file. You can get it. You don't need a download file after all. Okay, so what is it? There's one file, an Egg Jam, so how do you use it? 
And we're actually in LLaMA here, and the LLaMA code is very simple, it's just a generation model token age.
Tokenizer and GPT, which you're probably familiar with if you've been following along. We've been talking about in class, this is generation.
So it has the ability to generate sentences. And it's a model. So we're going to do some matching based on the feet that we've learned.
I think it would be better if we could bring up GPT Archetype and look at it together, like, let's take a look at this. Let's take a look at the Egg Jamples.
It looks busy, so I'll close it for a while. Like this. So, there are three functions in the sample.
I'm looking at the main one, and I'm gonna skip a lot of the unnecessary stuff up here. These are for parallelism.
I don't think we're gonna need to see this because we're gonna use the parallel set model parallel to set up parallelism.
If you're actually doing parallelization at the production level, you can look at the code, so I think it's a pretty good open source.
Okay, so basically what we're doing is we're taking a generator and we're generating, I don't know what it is, a gpt or something, a sentence.
So you feed the generator some input data, and it's just like, "What sentence do you want me to generate?
It's very simple, this code is very simple, the prompts are in the form of a list here, but I've put a bunch of them in, I could have just put one.
I've put in a couple of these when there's one like this, and it's going to generate each one for me. So it's going to take the prompt as input, and it's going to generate the max generation length.
We've all seen the max length. Of course, now it's generating a sentence, so it's going to write down the max.
Oh, here's a pen perforator and a topi, which I've never seen before, and these are things that are now used in practice, and you can see them at the code level.
but conceptually, when you generate a sentence, you have some parameters, you have hyper-parameters, and if you think about it roughly.
When you generate a sentence, the result is that the next sentence, when you say I'm going home, I'm going home.
and then you can say see you next time, but there's a whole world of other ways to say I'm going home, I'm going to see what's for dinner tonight.
I'm going home and I'm hungry. There are a lot of sentences that could actually be generated, and I think there are probabilities, for example.
There's a 100 percent chance that it's going to be next, and there's a higher probability now than I thought there would be, like, out of 50,000 words.
out of 50,000 words, it's going to give you a list of probabilities, and the highest probability is 90% or 98% of the time, it's going to be calm, and then we use the concept of temperament.
Temperament is a little bit of a temperature concept, and the lower the temperature, the colder it is, the drier it is, and it's actually just giving the correct answer.
The higher the temperature, the warmer it is, and that's what it means, so I'm not gonna go into a lot of creative detail because you're not trying to see this.
So if we say there's a probability distribution of usage, and one word is 98%, and everything else is like this, 5%, 3%, and so on.
And then most of the time it's not going to make sense and it's going to be decided, especially if we say topi, it's going to be decided, but most of the time we don't do this, we don't do this, we don't do this, and it's going to be more or less evenly matched.
So when I'm choosing probabilities, I'm going home today, not next time, but today. Oh, I'm hungry. It's a temperature where I can be a little more creative with all these different words.
Once you have a rough understanding that you can have these hyper-parameters, you can move on to generate like we did in the beginning of CPT where you generate from a generator model.
And then you'll get a bunch of different prompts, but the important thing is to look at the load model.
We take this load model and we do something with it, and all we have to do is look at it, and we have some inputs, we have some parameters, but at the end of the day, what is it that it does?
it's probably taking the LLaMA model and doing something with it, but at the end of the day, it's code that returns the LLaMA model, and the parameters are stored
It's all like this checkpoint directory, where we're gonna pull in the pre-trained training points, the koldo locations, the torquers, we're gonna have to have torquers now, right?
pre-trained torquers, so that path or whatever, that's for the treatment, and then we're gonna have a Max Seconds Length
sequence, so the max length is taking the input from those batch sides and doing something with it, giving it time to start.
So what it's doing here is it's passing through the checkpoint to get something, so what it's doing is it's reading the checkpoint.
Oh, what's complicated? It's complicated because it's Loplace parallelism, but the end result is we're passing the checkpoint through the checkpoint and reading it.
Okay, so now we're reading the training data from here, and then if you look at the checkpoint director, it's now called Parameter Jason, which means that when we download the file now.
now it comes with files that are specific to that particular folder, whether it's 7 million or 13 million.
Anyway, in the checkpoint directory, we're now going to be given Jason's parameters, which are called specific parameters.
I'm sure this will come in handy later, but you can download them by typing in the model size name like this, so 77 millimeters, 13, 30, 65, so we have bilinear sizes.
And then on the outermost part of here, we have the torqueiser models that we've studied, that we've done over the course of the year, that we can read and do.
Now look at the folder structure in there. We've got all these models under 7 millimeters that we're going to try out.
I'm gonna get it like this, I'm gonna sweep through it a little bit later, and then I'm gonna say this file, what's in this file?
It says, "What's a dimension? The dimension of the embedding vector." These are the angles in the model that we studied the embedding size of.
511 or 4 or 3 as we practiced, the embedding dimension is 4096 here.
Multiply this is now 756 for the feed forward network, and then this is the head multiply and this is the head multiply, and this is probably the right code to put in
but then the number of heads, and then we'll iterate through the layer a couple times, and then when we do the normalization, what variables
And then the rate value that goes into that romalize, and then the shoulder size, which is now internally used, so it's negative for now, so it's a hyper parameter value.
It's not too hard, and then you can think of this as having the values that we think it should have.
So what it's doing is it's taking those values and it's creating an artefact of the model with the hyperparameters here.
max sequence size here, max batch size here, and then we've created a total model arithmetic for the parameters, and then we're going to do something with it.
And then when we think about it, what are we going to do? So what we want to do is we're going to do what we're generating with the torque analyzer and the model.
No, that's why we're gonna take the torqueizer, read the torqueizer, and then we're gonna take the model, the transformer model.
The torqueizer here, it's telling me how many words there are, and it's telling me that the bokeh size was minus one before.
it's actually putting in the bokeh size, the number of words in the actual torqueizer as the bokeh size.
and then we're gonna use that to create our impedance vectors, and then we're gonna take our transformer model.
This is where we're actually attaching to something, this is now GPT, but we'll see if it's really GPT or not. So basically we have the torqueizer and the model.
The rest of it is, of course, inputting the model, inputting the staples, inputting the checkpoints, so if you get the model, you get the checkpoints, so this is GPT, you're reading the GPT model.
so it's reading the GPT model. And then if you look at it, now you see the LLaMA here, ah, the LLaMA's identity is the pipeline.
We put in a torqueizer, we put in a model, so the LLaMA generator, remember we talked about this a little bit in day 4?
What happens when you create a little bit of a pipeline in PerkingFace, and you put in a model and a torqueizer, and you put in some naturalization on the input.
and the torqueizer takes care of cutting and invading, and then it puts the model in, and it decodes the resulting value, and it comes out.
As a result, the prompt for the generator here is now texture, the original texture, so I'm just typing in the torqueizer to create it.
So it's like he's doing something extra, he's doing something with the GPT model and the torqueizer.
Something has now turned into something called a generator, and the generator is the LLaMA when it returns here.
The LLaMA itself is a generator that's a LLaMA. So we can now have a more coded understanding of what the hell a LLaMA is.
Let's look at it at a more coded level, not in the site that these guys called modes claimed.
Okay, so I said, "What's a LLaMA?" and there's a folder called LLaMA here under models, articulation, trunks, transformers, torquers, and LLaMAs.
So the LLaMA is a combination of a transformer and a torquer. So let's start with the first torquer and then the transformer.
It says that the torqueizer is a centerpiece procedure, but if you look here, it's a centerpiece, which is the centerpiece that we set up and learned about when we were studying the torqueizer. 
Now here's the part where we gave the EOS, EOS pad id value, right? So this is the part where the code is exactly the same.
You can just use Centerpiece Live to specify a specific kit value, Begin of, they can specify the pre-sentence processing, the start of the sentence, the end of the sentence.
and then what do you want the padding value to be, so that's what this live is for.
It's just a generic way to make a torqueizer out of this. Okay, so the torqueizer is not a consideration. It's just what we know.
So Transformers is now a LLaMA. Let's look at the LLaMA first, and then Transformers.
The LLaMA is in here, and now the LLaMA is in here. Okay, so the LLaMA is in the generation, and under the model is the transformer.
And under the torque knife is the torque knife. So we're gonna go to Generations to see the LLaMA first and then the transformers later.
Okay, here we go, we've got some sample toppers and stuff. We're gonna look at the LLaMA. What does the LLaMA do?
We know what a Transformer is. We know what a LLaMA is doing. We can just look at what he's doing in the generator and we'll understand.
And he's about to do something in the generator. Let's take a quick look at Transformers first, because Talkizer is the guy we know.
I'm gonna go, "What the hell is a transformer?" Okay, so the transformer is under the model here.
There's a bunch of them under this model, and if you look at it, the model arguments are just setting up our arguments, right? This is it.
It's just a class that has parameters, hyper-parameters, and then when you come out, what's the silver transformer?
We have a transformer block, and what's inside that block? We have an attachment and a feed forward.
Transformers have a Transformer block, and they have an Attention and a Feed Forward.
Transformers are what we're going to use from here on out, which I think is pretty much the same as GPT, but let's look at the difference for a second.
Transformers, you've got an init here, you've got a forward, you've got a forward, you've got a forward, you've got a forward, you've got a forward, you've got a forward, you've got a forward.
we have a parallel embedding, we have an embedding, we have a module list here, so if you look at it, you can see that the transformer block
I'm going through the module list and looping through the number of layers, so I think we have the transformer block that we know is here.
And then normalize we used rms normalize if you remember, and then what's out now is a column parametrization.
Column parametrization, so when you finally look at it, it's the last word parametrization that turns the dimension into a boket size.
Right? It turns the embedding into a boket size, and it passes through the last layer to softmax.
And then we're going to do a final romalize after we've just processed something in the transformer block, like we saw, ah, something in the transformer block.
and then it ends up here in the transformer block, and then it ends up here at the end of the transformer block, and then we have to do a final romalize.
and then linearly pass it through so that it's sentence aligned, so what we've done so far and what we're doing here is called parallel embedding.
I think it's gonna do something that involves input embedding and position embedding, and I can look at the code a little bit more, but if I go a little bit deeper.
even the kid is using the pairscale library, which is what they're using now, which is what Facebook is using now for parallelization.
embeddings and stuff like that, and what she's doing is she's doing the embedding.
It's like pulling out the pockets embedding value. It's taking the embedding value, and it's taking the embedding value, and it's going to go around and around in the transformer block.
Okay, so let's just look at the silver transformer block a little bit more, and this one is pretty much the same, and the only thing that's different about it is that it's a little bit different.
It's not that the rayleigh is different, it's just that we're using an RMS guy.
Same structure, same embedding, but this one has a little bit of embedding for parallelism.
So it's probably pretty much the same, but there's probably some other things that are different, but other than that, it's pretty much the same thing.
So now, what is it that we're doing in the transformer block? It's an Attention Feed Forward.
So up here, we've got an attenuation and a feed forward, so we've got an attenuation and a feed forward.
and we've got two RMSs that we're going to use in between.
Okay, so we've got one and two, so we're going to go in through this, we're going to go in through this, we're going to go out through this.
and then we've got these, and then we've got this, and then we've got this, and then we've got this, and then we've got this, and then we've got this.
and then let's take a look at this, and then finally something comes in and it goes through the normalize, it goes into the attentions, and then it adds.
it goes through the normalize, it goes through the feed forward, it adds it, and then it exits, so now let's look at the feed forward here.
and it's going to normalize the input that's going into the Attention, it's going to normalize it, it's going to normalize it, and then it's going to mask it.
It's got a mask, it's got a starting point, it's got a rotation, it's got all these values, but what it's doing in the end is it's normalizing the
it's doing is it's normalizing an attribute, it's normalizing it, and then it's putting the resulting value into an attribute, so it's taking these two.
And then I did this x here, which looks complicated, but it's just add here.
But sequentially, it's add normalize attribute, but functionally, it's normalize it, it returns it, it goes into the attribute.
and it adds the original value, x, to the end of it, and the result is called h.
It's adding h. It's adding the residuals, and if they're 9s, this is almost 100% identical to the GPT that we studied.
that we've been studying. It's just almost 100% the same. What's different about this one is, it's not different. If you look here, it's normalized.
It's a normalization, and if you look here, now the dimensionality is going in here, and it's going to keep going, and it's going to keep going, and every time it goes through that normalization, the dimensionality is going to keep going.
Okay, so now we can organize it like this, where we've got all these different functions up here that are functional. 
So the bottom line is, we've got a LLaMA model in Generation, and the LLaMA model takes as input a transformer and a torque nager.
The torquer takes that pre-trained model of the centerpiece torquer that we know, and the transformer is now GPT.
GPT takes it and it's the same, it's an RMS normalize normalize layer, so it goes in and it's like, what's the LLaMA doing now?
and now we'll be able to understand him perfectly. The pumpter is now the length, so we take the pumpter.
unnecessary parameters, and now we've got a pumper torque navigator here, so we're going to use the torque navigator to encode
encoding, and now here's the last thing we need to do, we've got a LLaMA model that's coming in, and it's like, heaven forbid, it's transcribing natural language.
to the model and then it's going to decode the result back to natural language and return it, right?
It's a generator, so at the end of the day, it's decoded, and it's decoded, and it's decoded, and it's decoded sentence by sentence, and it's decoded sentence by sentence, until the final
final sentence that we've decoded. So we've got a sentence, and then we go up and we're like, what's going on here?
We've encoded the token by torqueing the frumpeter token, so if you take this value and you look at it now.
What are we supposed to do here? We've got a value, we're supposed to give it back to the transformer model, right? So if you look at it, here's the model now.
The model is here. The model is the GPT model. What does the model get? Well, it's going to get that torqued, integerized value.
So what's the model doing in the middle here? The model's doing something here, it's looping the sentence over and over again, total lang.
Oh, so what she's doing is generating sentences, right? This is the iterative generate sentence, and it's iterating over and over again, right?
This is the logarithm of the result of generating sentences, one by one. What is it? This is now the value that the model predicted.
We're using this as a softmax, and we're pulling samples from the softmax. Okay, so let's take a look at the model, and this is what the model came up with at the end.
This is the output embedding value. This is the value before softmax. The model only throws it up to this value as the output.
If we call it a logarithm, and we softmax that logarithm at the end, what do we get? Now, if the temp is greater than 0, and if it's not greater than 0, which means it's negative, then we're going to set the nexel token to a single, fixed value.
If the tempfluence temperature is a little bit warmer, we'll take the softmax, but instead of just taking it, we'll divide the tempfluence here to equalize it a little bit.
It gets a little bit sophisticated when you divide it up, but it's this value, and then we're going to take the probability value and we're going to set it to the sample p top p top p that we specified, and if it's above 90%, we're going to take 90%.
This is the part of the code that handles these parameters. It's pretty easy to do in code. The code that goes into it is like, "Oh, we got one.
We figured out that a minus one always creates the same kid, no matter what. So at the code level, where we're leveling it off based on the temperature value.
Tempfluence And then we understand 100% of the code that earned us the Nexelt token. This little thing is efficient processing.
It's an efficient way of reducing the amount of notes that we have to take, and then we get the Nexelt token, and then eventually, what do we do with it?
I put it in a list of tokens. I'm gonna take the tokens here and I'm gonna go through the fork and I'm gonna add them one by one to this token, and I'm gonna add the Nexel token.
You remember this, it's not a random thing, it's a Nexelt token, so it's a whole thing, but it's going to be roughly where the cursor is right now, and we're going to get it or something like that.
So what we're doing in our code is we're taking all of our Nexelt tokens and we're iterating over them, and we're getting them one by one.
It's i and t over and over again, and now what it's doing is it's saying, "Okay, this is the t-code of the token, this is the t of the token," and it's adding them one by one.
and then when we get that t, something is now processing it, so maybe it's now taking the whole sentence and then at the end.
and then at the end of it, it's going to tell me if the sentence is over, and if it fails, it's going to give me an error, but it's not important.
It ends up being some kind of sentence generator code that adds a bunch of code with error handling and an end-of-sequence at the end.
So now you understand the generator, and then I'll ask you again, what does a LLaMA do?
If I say, "What is a LLaMA," a LLaMA is just a GPT3.
The only difference is that in the model, if you look at the RMS earlier, if you look at the block here, it's using a romalizer called RMS.
So what is rms romalize, if we romalize here, it's the default romalizer for torch, so there's a lot of different romalizers.
It's one of them, but it doesn't really change much except for that.
Okay, this one, this one, we'll see how the embedding goes now, but the addition is unchanged.
and then the next thing you know, it's just addition. And the self-positioning doesn't change, and as a result.
even if you want to change it, you can't change it. I mean, Facebook changed their name to LLaMA after all these years.
LLaMA is really just a GPT3 that's just a combination of a model and a torquer if you look at the model here at the end.
So we know that LLaMA is a GPT3 because Facebook claimed that LLaMA was benchmarked against GPT3
benchmarked GPT3 and said it was better than GPT and it was good enough, so if we're talking about GPT3 as something that a Facebook-level global enterprise
to understand 100% of the code of an open source, production-level, expertly written, open source project.
Okay, that's it for the grape review. 

 

 

반응형
LIST
Comments