728x90
반응형

 티스토리 

 

LOCAL CHATGPT4 사용하기.

  회사 또는 보안으로 인한 제약사항이 있다면 로컬 컴퓨에서 사용가능한 생성형 AI를 만들어보자. 
  개인 정보나 회사 기밀정보가 있어서 ChatGPT 대안으로 공부하여 보자.
  아직 로컬용 오픈소스가 계속 발전되고 있으니, 추후에는 더 간편하게 사용 할수 있지 않을가 합니다.

GPT4ALL 사이트 : https://gpt4all.io/index.html

 

1. GPT4ALL

  아래 사이트를 참고하여 정리해 보았습니다.
아래 사이트에는 다양한 LLM 들이 있으니 참고하세요.
https://python.langchain.com/docs/integrations/llms/gpt4all

Import 준비 

from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate
from langchain_community.llms import GPT4All

LLM에 질문 하는 코드

template = """Question: {question}

Answer: Let's think step by step."""

prompt = PromptTemplate(template=template, input_variables=["question"])

LLM 위치 지정

local_path = (
    "./models/ggml-gpt4all-l13b-snoozy.bin"  # replace with your desired local file path
)
# Callbacks support token-wise streaming
callbacks = [StreamingStdOutCallbackHandler()]

# Verbose is required to pass to the callback manager
llm = GPT4All(model=local_path, callbacks=callbacks, verbose=True)

# If you want to use a custom model add the backend parameter
# Check https://docs.gpt4all.io/gpt4all_python.html for supported backends
llm = GPT4All(model=local_path, backend="gptj", callbacks=callbacks, verbose=True)
llm_chain = LLMChain(prompt=prompt, llm=llm)
question = "What NFL team won the Super Bowl in the year Justin Bieber was born?"

llm_chain.run(question)

아직 위코드를 실행을 못해 봤다.
완료후에 다시 후기를 써볼 예정.

GPT4All 사이트에 가서  윈도우용 설치 파일을 다운로드하여 다양한 모델을 다운로드 할수도 있다.

 .bin 또는 .gguf로 끝나는 파일을 다운로드
q_숫자는 양자화 정도를 나타낸다. 
숫자가 높을수록 인공지능 데이터가 많아 정확도 가 높고, 컴퓨터 사양도 좋아야 겠지..

https://huggingface.co/models?language=ko&sort=trending&search=gguf

For more info, visit https://github.com/nomic-ai/gpt4all.

마무리

- 이번 포스팅은 GPT4ALL 에 대해 알아봤습니다.

 

궁금한 사항은 댓글을 통해서 남겨 주시면 답변 드리겠습니다.
감사합니다.

 

 

728x90
반응형

+ Recent posts