• Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms & Conditions
Friday, October 23, 2026
freevirtualsolutions.com
  • Home
  • Virtual Assistant
  • Enterprise Technology
  • Customer Support
  • Marketing Support
  • Workforce Management
No Result
View All Result
  • Home
  • Virtual Assistant
  • Enterprise Technology
  • Customer Support
  • Marketing Support
  • Workforce Management
No Result
View All Result
Free Virtual Solutions
No Result
View All Result
Home Enterprise Technology

Getting began with Google’s PaLM API

Ermias S. by Ermias S.
3 years ago
in Enterprise Technology
0
399
SHARES
2.3k
VIEWS
Share on FacebookShare on Twitter


Pathways Language Mannequin 2 (PaLM 2) is a big language mannequin (LLM) developed by Google. It was introduced in Might 2023 as a successor to the PaLM mannequin, which was initially launched in January 2022. The PaLM 2 mannequin is skilled on an enormous information set of textual content and code and might carry out a variety of duties, comparable to phrase completion, code completion, query answering, summarization, and sentiment evaluation.

PaLM 2 is a basis mannequin that’s core to Google’s platform for generative AI. PaLM 2 powers Bard, Google’s AI chatbot that competes with OpenAI’s ChatGPT, and Duet AI, Google’s AI assistant framework that’s being built-in into merchandise comparable to Google Workspace and Google Cloud.

Google is making the PaLM API out there inside the Vertex AI platform and as a standalone API endpoint. Builders can entry the Vertex AI PaLM API at present, whereas the standalone endpoint is on the market solely by way of the Trusted Testers program.

Up and working with Python and Vertex AI

Assuming you’re a subscriber to Google Cloud, this tutorial walks you thru the steps of exploring the PaLM API out there within the Vertex AI platform. Please notice that the service is in preview, and the API might change sooner or later.

Let’s begin by making a Python digital atmosphere for our experiment.

python3 -m venv venv
supply venv/bin/activate

Then we set up the Python module to entry the Google Vertex AI platform.

pip set up google-cloud-aiplatform

We may also set up Jupyter Pocket book, which we’ll use as our growth atmosphere.

pip set up jupyter

The library, vertexai.preview.language_models, has a number of courses together with ChatModel, TextEmbedding, and TextGenerationModel. For this tutorial, we’ll concentrate on the TextGenerationModel, the place PaLM 2 will assist us generate a weblog put up primarily based on the enter immediate.

As a primary step, import the precise class from the module.

Import vertexai.preview.language_models import TextGenerationModel

We’ll then initialize the item primarily based on the pre-trained mannequin, text-bison@001, which is optimized for producing textual content.

mannequin = TextGenerationModel.from_pretrained("text-bison@001")

The subsequent step is to outline a operate that accepts the immediate as an enter and returns the response generated by the mannequin as output.

def get_completion(prompt_text):
    response = mannequin.predict(
        prompt_text,
        max_output_tokens=1000,
        temperature=0.3
    )
    return response.textual content
vertex ai palm api 01 IDG

The tactic, predict, accepts the immediate, the variety of tokens, and temperature as parameters. Let’s perceive these parameters higher.

Textual content era mannequin parameters

Whereas we submit prompts to the PaLM API within the type of textual content strings, the API converts these strings into chunks of that means known as tokens. A token is roughly 4 characters. 100 tokens correspond to roughly 60 to 80 phrases. If we would like the mannequin’s output to be inside 500 phrases, it’s secure to set the max_output_tokens worth to 1000. The utmost worth supported by the mannequin is 1024. If we didn’t embody this parameter, the worth would default to 64.

The subsequent parameter, temperature, specifies the creativity of the mannequin. This setting controls how random the token choice will likely be. Decrease temperatures are higher for prompts that want a selected and fewer artistic response, whereas greater temperatures can lead to extra various and artistic solutions. The temperature worth might be between 0 and 1. Since we would like a little bit of creativity, we set this to 0.3.

Temperature too is an non-compulsory parameter, the default worth for which varies by mannequin. Two different non-compulsory parameters, top_k and top_p, help you change how the mannequin selects tokens for output, however we’ll skip them right here.

With the tactic in place, let’s assemble the immediate.

immediate = f"""
Write a weblog put up on renewable power. Restrict the variety of phrases to 500.
"""

Invoke the tactic by passing the immediate.

response=get_completion(immediate)
print(response)
vertex ai palm api 02 IDG

It is best to see a well-written weblog put up generated by PaLM.

Let’s make this life like by asking PaLM to generate the content material formatted in HTML. For that, we have to modify the immediate.

immediate = f"""
Write a weblog put up on renewable power. Restrict the variety of phrases to 500.
Format the output in HTML.
"""

To print the output in HTML format, we will use the built-in widgets of the Jupyter Pocket book.

from IPython.show import show, HTML
show(HTML(response))

Now you can see the weblog put up formatted in HTML.

vertex ai palm api 03 IDG

Under is the whole code to your reference.

from vertexai.preview.language_models import TextGenerationModel
mannequin = TextGenerationModel.from_pretrained("text-bison@001")
def get_completion(prompt_text):
    response = mannequin.predict(
        prompt_text,
        max_output_tokens=1000,
        temperature=0.3
    )
    return response.textual content
immediate = f"""
Write a weblog put up on renewable power. Restrict the variety of phrases to 500.
Format the output in HTML.
"""
response=get_completion(immediate)
print(response)
from IPython.show import show, HTML
show(HTML(response))

In only a few strains of code, we have now invoked the PaLM 2 LLM to generate a weblog put up. In upcoming tutorials, we’ll discover different capabilities of the mannequin together with code completion, chat, and phrase embeddings. Keep tuned.

Copyright © 2023 IDG Communications, Inc.



Source_link

Tags: APIGooglesPaLMstarted
Previous Post

E-commerce Pricing Methods for D2C Manufacturers

Next Post

Individuals of 20four7VA: Arlene – 20four7VA

Next Post
Individuals of 20four7VA: Arlene – 20four7VA

Individuals of 20four7VA: Arlene - 20four7VA

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Customer Support (1,841)
  • Enterprise Technology (4,688)
  • Marketing Support (3,984)
  • Virtual Assistant (4,293)
  • Workforce Management (1,552)

Free Virtual Solutions

Welcome to freevirtualsolutionsThe goal of freevirtualsolutions is to give you the absolute best news sources for any topic! Our topics are carefully curated and constantly updated as we know the web moves fast so we try to as well.

Category

  • Customer Support
  • Enterprise Technology
  • Marketing Support
  • Virtual Assistant
  • Workforce Management

Recent Post

  • Stop Rewriting the Same AI Prompt Every Day. Build a Reusable Assistant Instead.
  • What It Is, How to Measure It, and What It Actually Tells You
  • What Is Fund Administration? Roles, Models & Tips
  • Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms & Conditions

Copyright © 2023 Freevirtualsolutions.com | All Rights Reserved.

No Result
View All Result
  • Home
  • Virtual Assistant
  • Enterprise Technology
  • Customer Support
  • Marketing Support
  • Workforce Management

Copyright © 2023 Freevirtualsolutions.com | All Rights Reserved.

Chat with us

Hi there! How can I help you?