-
See Also
- ServiceExecute
- ServiceConnect
- ChatEvaluate
- LLMSynthesize
- LLMConfiguration
-
- Service Connections
- GoogleGemini
- OpenAI
- Anthropic
-
-
See Also
- ServiceExecute
- ServiceConnect
- ChatEvaluate
- LLMSynthesize
- LLMConfiguration
-
- Service Connections
- GoogleGemini
- OpenAI
- Anthropic
-
See Also
"PaLM" (Service Connection)
Connecting & Authenticating
Requests
"Completion" — create text completion for a given prompt
| "Prompt" | the prompt for which to generate completions |
| "MaxTokens" | Automatic | maximum number of tokens to generate | |
| "Model" | Automatic | name of the model to use | |
| "N" | Automatic | number of completions to return (1 to 8) | |
| "StopTokens" | None | up to four strings where the API will stop generating further tokens | |
| "Temperature" | Automatic | sampling temperature (between 0 and 1) | |
| "TopProbabilities" | Automatic | sample only among the k highest-probability classes | |
| "TotalProbabilityCutoff" | None | sample among the most probable classes with an accumulated probability of at least p (nucleus sampling) |
"Chat" — create a response for the given chat conversation
| "Messages" | a list of messages in the conversation |
| "Model" | Automatic | name of the model to use | |
| "N" | Automatic | number of completions to return (1 to 8) | |
| "Temperature" | Automatic | sampling temperature (between 0 and 1) | |
| "TopProbabilities" | Automatic | sample only among the k highest-probability classes | |
| "TotalProbabilityCutoff" | None | sample among the most probable classes with an accumulated probability of at least p (nucleus sampling) |
"TextEmbedding" — create an embedding vector representing the input text
| "Text" | text that the model will turn into an embedding |
| "Model" | Automatic | name of the model to use |
"TokenCount" — run a model's tokenizer on a prompt and return the token count
| "Input" | text or messages to tokenize |
| "Model" | Automatic | name of the model to use |
Examples
open all close allBasic Examples (2)
palm = ServiceConnect["PaLM"]ServiceExecute[palm, "Completion", {"Prompt" -> "Roses are red
Violets are blue, "}]Generate a response from a chat:
ServiceExecute["PaLM", "Chat", {"Messages" -> {<|"Role" -> "User", "Content" -> "hello there"|>}}]Scope (11)
Completion (3)
Change the sampling temperature:
ServiceExecute["PaLM", "Completion", {"Prompt" -> "please complete this text.", "Temperature" -> 1}]Increase the number of characters returned:
ServiceExecute["PaLM", "Completion", {"Prompt" -> "please complete this text.", "MaxTokens" -> 3}]ServiceExecute["PaLM", "Completion", {"Prompt" -> "please complete this text.", "N" -> 2}]Chat (3)
Respond to a chat containing multiple messages:
ServiceExecute["PaLM", "Chat", {"Messages" -> {
<|"Role" -> "User", "Content" -> "tell me three colors"|>}}]Change the sampling temperature:
ServiceExecute["PaLM", "Chat", {"Messages" -> {<|"Role" -> "User", "Content" -> "tell me three colors"|>}, "Temperature" -> 0}]ServiceExecute["PaLM", "Chat", {"Messages" -> {<|"Role" -> "User", "Content" -> "What colors are bears?"|>}, "N" -> 2}]TextEmbedding (2)
Compute the vector embedding of some text:
ServiceExecute["PaLM", "TextEmbedding", {"Text" -> "ciao"}]//ShortCompute the distance between vector embeddings to find semantic similarities:
embeddings =
Table[
ServiceExecute["PaLM", "TextEmbedding", {"Text" -> text}],
{text, {"Paris", "London", "I love rock'n'roll"}}
];DistanceMatrix[embeddings]//MatrixPlotTokenCount (3)
Get a token count for a string prompt:
ServiceExecute["PaLM", "TokenCount", {"Input" -> "hello", "Model" -> "text-bison-001"}]Get a token count for a messages prompt:
ServiceExecute["PaLM", "TokenCount", {"Input" -> {<|"Role" -> "User", "Content" -> "hello"|>}, "Model" -> "chat-bison-001"}]When not specified, the model is chosen automatically:
ServiceExecute["PaLM", "TokenCount", {"Input" -> "hello"}]ServiceExecute["PaLM", "TokenCount", {"Input" -> {<|"Role" -> "User", "Content" -> "hello"|>}}]See Also
ServiceExecute ▪ ServiceConnect ▪ ChatEvaluate ▪ LLMSynthesize ▪ LLMConfiguration
Service Connections: GoogleGemini ▪ OpenAI ▪ Anthropic