我想要一天分享一點「LLM從底層堆疊的技術」,並且每篇文章長度控制在三分鐘以內,讓大家不會壓力太大,但是又能夠每天成長一點。
準備好前置作業後,以下開始使用 Vertex AI PaLM 2 進行 QA 問答:
from vertexai.preview.language_models import ChatModel, InputOutputTextPair
vertexai.init(project = "aiex-57523", location = "us-central1")
chat_model = ChatModel.from_pretrained("chat-bison@001")
parameters = {"temperature": 0.2,
"max_output_tokens": 256,
"top_p": 0.8,
"top_k": 40}
chat = chat_model.start_chat(context = """Answer a question on the text submitted""")
response = chat.send_message("""Based on the following text, Does Gemini repeat existing text? “ Gemini is a multimodal LLM, understanding and generating text, code, images, and more. It excels at reasoning across vast amounts of information, solving complex problems, and adapting to various tasks through fine-tuning.”""", **parameters)
wrapped_text = textwrap.fill(response.text, width = 40)
print(wrapped_text)
結果為:





















