我想要一天分享一點「LLM從底層堆疊的技術」,並且每篇文章長度控制在三分鐘以內,讓大家不會壓力太大,但是又能夠每天成長一點。
有鑒於 AI說書 - 從0開始 - 431 | Vertex AI PaLM 2 API 說 AI 助手產生的結果是有問題的,以下我們重新生成程式碼:
import vertexai
from vertexai.preview.language_models import CodeGenerationModel
vertexai.init(project = "aiex-57523", location = "us-central1")
parameters = {"temperature": 0.2, "max_output_tokens": 1024}
model = CodeGenerationModel.from_pretrained("code-bison@001")
response = model.predict(prefix = """Correct the following code in Python that calculates a Fibonacci suite up to 10 numbers starting from 0 or 1. The code is inaccurate because it calculates 11 numbers instead of 10. Provide a corrected code:from vertexai.preview.language_models import CodeChatModel vertexai.init(project=\"aiex-57523\", location=\"us-central1\") chat_model = CodeChatModel.from_pretrained(\"codechat-bison@001\") parameters = { \"temperature\": 0.5, \"max_output_tokens\": 1024 } chat = chat_model.start_chat() response = chat.send_message(\"\"\"Write the code in Python for a function in Python that calculates a Fibonacci suite up to 10:\"\"\", **parameters) print(f\"Response from Model: {response.text}\")""", **parameters)
print(f"Response from Model: {response.text}")



















