GitHub:nomic-ai/gpt4all It is an open source chatbot ecosystem learned with vast amounts of data, including conversations in silver code and chat format.
In this example, using LangChain GPT4All Describes how to interact with the model.
Method of installation
First, access the official homepage to download and install the installation file.
from langchain.prompts import ChatPromptTemplate
from langchain_community.llms import GPT4All
from langchain_core.output_parsers import StrOutputParser
from langchain_core.callbacks import StreamingStdOutCallbackHandler
# Prompt
prompt = ChatPromptTemplate.from_template(
"""<s>A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.</s>
<s>Human: {question}</s>
<s>Assistant:
"""
)
# GPT4All 언어 모델 초기화
# model is GPT4All Initialize language model
llm = GPT4All(
model=local_path,
backend="gpu", # GPU Settings
streaming=True, # Streaming Settings
callbacks=[StreamingStdOutCallbackHandler()], # Set callback
)
# create a chain
chain = prompt | llm | StrOutputParser()
# Execute query
response = chain.invoke({"question": "What is the capital of South Korea?"})
The capital of South Korea is Seoul.
Seoul is a large city with a population of about 10 million people, located in the northern part of the Korean Peninsula. It is considered one of the largest cities in the world and serves as a cultural, economic and political center. The city's history dates back to the Three Ages and has since developed into an important area in Baekje, Goryeo and Joseon.
Seoul boasts a rich cultural heritage, including various museums, palaces and temples. The main attractions are Gyeongbokgung Palace, Changdeokgung Palace and Deoksugung Palace.
Seoul also has a thriving economy and is home to many multinational companies. The city is famous for its technology industry and has major companies such as Samsung and LG.
Overall, Seoul is a lively and exciting place to visit. You can find everything from historic sights to modern architecture, and the city's energy and diversity attracts travelers from all over the world.