🖥️
Dive to AI
  • Get started
  • GPT4All
    • LangChain, GPT4All 설치
    • AI 모델 실행
    • 번역을 맡겨 보자
    • AI 응답 개선하기
  • AI 사용하기
    • AI를 효율적으로 사용하는 법
    • 어떻게 AI를 활용해야 할까?
  • 여러 가지 AI
    • Chat AI
    • Coding AI
    • Hugging Face
  • AI 관련 개념들
    • Reader-Retriever Model
    • RAG
    • Fine-tuning
  • Other
    • 그 외
  • Links
    • GitHub
    • Dive to Argo
Powered by GitBook
On this page
  • AI 모델 다운로드하기
  • Python으로 AI 모델 실행하기

Was this helpful?

  1. GPT4All

AI 모델 실행

PreviousLangChain, GPT4All 설치Next번역을 맡겨 보자

Last updated 1 year ago

Was this helpful?

AI 모델 다운로드하기

이제 구동할 AI 모델이 필요합니다.

저는 GPT4All 홈에서 mistral-7b-openorca.Q4_0.gguf 모델을 다운로드하겠습니다.

Python으로 AI 모델 실행하기

llm_sample.py
from langchain_community.llms.gpt4all import GPT4All
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain

model = GPT4All(model="model/mistral-7b-openorca.Q4_0.gguf", n_threads=8)

template = """
Answer to the question: {question}
"""
prompt = PromptTemplate(template=template, input_variables=["question"])

llm_chain = LLMChain(prompt=prompt, llm=model, verbose=True)

# run the question
print(llm_chain.invoke({
    "question": "Who is Son Heung-min?"
}))

실제로 실행해 보면 다음과 같습니다.

답변이 오긴 했는데, 손흥민 선수가 5자리 이름으로 개명을 했고 출생지도 틀렸습니다. (손흥민 선수는 춘천에서 태어났는데 고양으로 출생지가 바뀌었습니다)

이렇게 AI가 잘못된 정보나 허위 정보를 내놓는 것을 Hallucination이라고 합니다.

한국어로 질문을 바꿔 보았습니다. 알아듣기는 하는데, 대답은 영어로 나옵니다. Hallucination은 오히려 더 심해진 것 같기도 하고요. (손흥민 선수는 2010 ~ 2013년에 함부르크에서 뛰었습니다)

아무래도 많이 부족한 친구인 것 같습니다. 예시 코드부터 불안한데... 사용할 수 있을까요?

LangChain은 수많은 AI 모델 구동을 지원하고, 참고하여 다음과 같은 코드를 작성합니다.

그중 GPT4All도 있습니다.
모델은 적당한 폴더에 위치시킵니다.
한국어로 질문했을 때