ChatGLM
ChatGLM-6B is an open bilingual language model based on General Language Model (GLM) framework, with 6.2 billion parameters. With the quantization technique, users can deploy locally on consumer-grade graphics cards (only 6GB of GPU memory is required at the INT4 quantization level).
ChatGLM2-6B is the second-generation version of the open-source bilingual (Chinese-English) chat model ChatGLM-6B. It retains the smooth conversation flow and low deployment threshold of the first-generation model, while introducing the new features like better performance, longer context and more efficient inference.
ChatGLM3 is a new generation of pre-trained dialogue models jointly released by Zhipu AI and Tsinghua KEG. ChatGLM3-6B is the open-source model in the ChatGLM3 series
# Install required dependencies
%pip install -qU langchain langchain-community
ChatGLM3
This examples goes over how to use LangChain to interact with ChatGLM3-6B Inference for text completion.
from langchain.chains import LLMChain
from langchain_community.llms.chatglm3 import ChatGLM3
from langchain_core.messages import AIMessage
from langchain_core.prompts import PromptTemplate
template = """{question}"""
prompt = PromptTemplate.from_template(template)
endpoint_url = "http://127.0.0.1:8000/v1/chat/completions"
messages = [
AIMessage(content="我将从美国到中国来旅游,出行前希望了解中国的城市"),
AIMessage(content="欢迎问我任何问题。"),
]
llm = ChatGLM3(
endpoint_url=endpoint_url,
max_tokens=80000,
prefix_messages=messages,
top_p=0.9,
)
llm_chain = LLMChain(prompt=prompt, llm=llm)
question = "北京和上海两座城市有什么不同?"
llm_chain.run(question)
'