본문 바로가기
데이터&AI/LLM

일론머스크의 AI, xAI의 오픈소스 LLM 사용해보기 (grok)

by 일등박사 2024. 3. 19.

2024년 3월 17일!!!

일론머스크가 만든 AI 회사인 xAI에서

초거대 언어모델 grok을 오픈소스로 공개했습니다~!!

ㅁ 그록의 간단한 소개

  - 파라미터: 3,140억 개 (314B)

 -  아키텍처: 혼합 전문가 8개(MoE)

 -  전문가 활용: 토큰 당 2개의 전문가 사용

 -  레이어: 64

  • Architecture: Mixture of 8 Experts (MoE)
  • Experts Utilization: 2 experts used per token

 -  어텐션 헤드: 쿼리에 48개, 키/값에 8개

 -  임베딩 크기: 6,144

 -  토큰화: 131,072개 토큰

 -  추가 기능:

  • 회전 임베딩 (RoPE): 긴 시퀀스 처리를 위한 효율적인 방법
  • 활성화 분할과 8비트 양자화: 하드웨어 가속을 통한 효율적인 학습과 추론 지원

 -  최대 시퀀스 길이 (컨텍스트): 8,192 토큰 (일반적 GPT-4와 동일)

 

 >참고, 기존 모델들과의 비교

https://drfirst.tistory.com/entry/GPT%EB%A5%BC-On-premise%EC%97%90%EC%84%9C-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B3%A0-%EC%8B%B6%EC%9D%84%EB%95%8C%EB%8A%94

 

GPT를 On-premise에서 사용하고 싶을때는??

GPT의 시대입니다. 하루가 다르게 다양한 기술들이 나오고 있습니다 GPT plugin 이 개발되어 적시성을 필요로하는 데이터도 바로바로 GPT를 통해 볼 수 있게되고 GPT-Index(LLaMa-index)를 통하여 PDF, 위키

drfirst.tistory.com

모델명 개발사 OpenSource 경쟁모델 parameter 수(bn) 특이사항
GPT-3 OpenAI X - 175 davinci, curie 등 세부 모델 존제
GPT-4 OpenAI X - 1,000 32K / 8K context로 구분
Bard Google X chatGPT    
LLaMa Meta O GPT3 65 2/23출시. 65B.33B.7B 모델로 구분
(숫자가 Parameter수)

 

ㅁ설치 방법

 

1. conda 가상환경 만들기(생략가능) 

  > 기존 Python 환경과 충돌할 수 있으니 환경을 만들어줍니다.

#가상환경만들기
conda create -n grokenv python=3.11
#가상 환경 실행하기
source activate grokenv

 

2. huggingface git clone및 설치

git clone https://github.com/xai-org/grok-1.git && cd grok-1
pip install huggingface_hub[hf_transfer]

## 아래 코드는 오래걸림!!
huggingface-cli download xai-org/grok-1 --repo-type model --include ckpt-0/* --local-dir checkpoints --local-dir-use-symlinks False

 

 

3. 마지막 requirements설치 및 생행!!

pip install git+https://github.com/deepmind/dm-haiku
pip install --upgrade "jax[cuda12_pip]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
## 충분한  GPU 메모리가 필요합니다. 그렇지 않다면 CUDA OOM 에러가 발생합니다! 
pip install -r requirements.txt
python run.py

 

※ ValueError: Number of devices 1 must equal the product of mesh_shape (1, 8) 에러가 날경우!!

run.py 의 60번째줄 

local_mesh_config=(1, 8),

local_mesh_config=(1, 1),

로 바꿔주세요!!

 

8>1로 바뀌는 부분은 gpu의 개수를 넣으면 됩니다~!

 

ㅁ 그록 사용 결과!!

 

 

....OSError: [Errno 28] No space left on device: './checkpoints/ckpt-0/tensor00000_000' - 

할수있다@!!!

 

/dev/shm의 모든 파일을 지우고 다시실행!~!!

그러나.. killed 에러발생...

찾아보니 메모리 부족이라고합니다. 300GB 이상이 필요하다고하네요..,

 

그럼!! 테스트는 아무나 못하겠군요!!!!!!

ㅁ 참고

Grok 블로그: https://x.ai/blog/grok-os

Grok Github: https://github.com/xai-org/grok-1

Grok HuggingFace : https://huggingface.co/xai-org/grok-1

 

xai-org/grok-1 · Hugging Face

Grok-1 This repository contains the weights of the Grok-1 open-weights model. You can find the code in the GitHub Repository. Download instruction Clone the repo & download the int8 checkpoint to the checkpoints directory by executing this command in the r

huggingface.co

 

GitHub - xai-org/grok-1: Grok open release

Grok open release. Contribute to xai-org/grok-1 development by creating an account on GitHub.

github.com

 

댓글