我想要一天分享一點「LLM從底層堆疊的技術」,並且每篇文章長度控制在三分鐘以內,讓大家不會壓力太大,但是又能夠每天成長一點。
import vertexai
from vertexai.language_models import TextGenerationModel
vertexai.init(project = "aiex-57523", location = "us-central1")
parameters = {"temperature": 0.2,
"max_output_tokens": 256,
"top_p": 0.8,
"top_k": 40}
model = TextGenerationModel.from_pretrained("text-bison@001")
response = model.predict("""Summarize the following conversation between a service rep and a customer in a few sentences. Use only the information from the conversation. Service Rep: How may I assist you today? Customer: I need to change the shipping address for an order. Service Rep: Ok, I can help you with that if the order has not been fulfilled from our warehouse yet. But if it has already shipped, then you will need to contact the shipping provider. Do you have the order ID? Customer: Yes, it\'s 88986367. Service Rep: One minute please while I pull up your order information. Customer: No problem Service Rep: Ok, it looks like your order was shipped from our warehouse 2 days ago. It is now in the hands of the shipping provider, so you will need to contact them to update your delivery details. You can track your order with the shipping provider here: https://www.shippingprovider.com Customer: Sigh, ok. Service Rep: Is there anything else I can help you with today? Customer: No, thanks.""", **parameters)
wrapped_text = textwrap.fill(response.text, width = 40)
print(wrapped_text)
結果為:






















