Generate, Embed, or Rerank Text with a Generative AI Action
You can use AI to generate, embed, or rerank text with a generative AI action. Oracle Cloud Infrastructure Generative AI provides answers or information to the questions you ask by generating text. It also enables you to create text embeddings and rerank text.
Capabilities
OCI Generative AI is a fully managed AI service that offers customizable large language models (LLMs) for various use cases such as chat, generating text embeddings, and reranking text. Oracle Integration supports using OCI Generative AI in an integration with the generative AI action.
- Chat: You can prompt the OCI Generative AI chat model to generate text. You can ask questions and get text responses. For this action, OCI Generative AI returns a text response to your question or request. You can also include an image as part of your chat, and it will be used to provide the response. The OCI Generative AI’s chat model enables you to brainstorm ideas, get answers to questions, write descriptions or content, explain concepts, perform image analysis, and much more.
- EmbedText: You can create embeddings for the text you provide using OCI Generative AI. The text can be a phrase, a sentence, or one or more paragraphs. An embedding is a numeric representation of a text. Embeddings are useful to find similarity between text, for semantic searches when the search is based on the meaning of the text rather than keywords, text classification, and so on. For this action, OCI Generative AI returns the embedded result.
- Rerank: You can rerank text responses based on input documents and a prompt. Rerank assigns an index and a relevance score to each document, indicating which document is most related to the prompt.
See Generative AI.
Prerequisites
See Prerequisites for information on the prerequisites you must satisfy in the Oracle Cloud Infrastructure Console.
Invoke Oracle Cloud Infrastructure Generative AI from an Integration
- Add a Generative AI action to an integration in either of the following ways:
- On the side of the canvas, click Actions
and drag the OCI Generative AI action to the appropriate location.
- Click
at the location where you want to add the OCI Generative AI action, then select OCI Generative AI.
- On the side of the canvas, click Actions
- Enter a name and optional description, then click Continue.
- Select the following information, then click Continue.
Element Description Select Categories Select one of the following categories to use:- On demand: This option enables you to use pre-trained foundational models (on-demand models) to perform actions using the OCI Generative AI without the need to create your own model. Pre-trained models enable you to use AI with no data science experience.
- Dedicated: This option allows you to use compute resources for fine-tuning custom models or for hosting endpoints. The AI clusters are dedicated to your models and are not shared with other customers. You can provision your own endpoint if you use this option.
Action If you selected the On demand category, select one of the following actions:- Chat
- EmbedText
If you selected the Dedicated category, select one of the following actions:- Chat
- Rerank
- EmbedText
- Select the following information, then click Continue.
Element Description Region Select the region you want to use.
Note: Ensure you select the region in which OCI is provisioned for you.
Compartment Select the Oracle Cloud Infrastructure compartment in which your Oracle Integration is installed.
Model This field is available only when you select the On demand category and the Chat action in Step 3.
Select a model for your generative AI action.- If you select GENERIC (llama), all the Meta Llama models are listed for selection in the Model ID field.
- If you select COHERE, all the Cohere models are listed for selection in the Model ID field.
Model ID This field is available only when you select the On demand category and the Chat or EmbedText action in Step 3.
Select a model ID to use.
Endpoint This field is available only when you select the Rerank action in Step 3.
Select an endpoint to use.
Endpoint ID This field is available only when you select the Dedicated category and the Chat or EmbedText action in Step 3.
Select an endpoint ID to use.
- On the Summary page, click Finish.
- Open the mapper and define the mappings between the source and target elements as needed.
For Chat action, perform the following steps.
- Expand the topmost request node in the Target section.
- Within the topmost request node in the Target section, expand Request Wrapper, expand Chat Request, expand Messages, and then expand Content.
- Within Content, right-click Text, and select Create target node.
- Click Design View
in the Expression Builder.
- You can prompt the OCI Generative AI chat model to generate text by specifying your request for the Text target element in the Expression Builder. In the Expression Builder, enter the question you want to ask or specify what information you need (for example, 'Tell me about ELE').
- You can also include an image as part of your chat. You need to send it in base-64 format. You need to specify the image URL in the target Url element (within Image URL).
Note:
In the mapper, you can optionally override the following values you initially selected when you performed Step 4:- Compartment Id: Use this to specify a compartment Id to override the default compartment that was selected for the model to be deployed.
- Api Format (model): Use this to override the default API format used for model serving.
- Model Id: Use this to override the initially selected model identifier.
You can also optionally configure other fields as needed in the mapper based on the model you selected, including setting servingType, Citation Quality, Preamble Override, tuning parameters such as Top p/Temperature, and so on. See CohereChatRequest Reference.
For EmbedText action, perform the following steps.
- Expand the topmost request node in the Target section.
- Within the topmost request node in the Target section, expand Request Wrapper, and then expand Body.
- Within Body, right-click Inputs, and select Create target node.
- Click Design View
in the Expression Builder.
- For the Inputs target element, in the Expression Builder, specify the text for which OCI Generative AI needs to generate an embedding.
- Right-click Input Type, and select Create target node.
- Optionally, you can specify the input type using the Input Type target element.
You can also optionally configure other fields as needed in the mapper, such as Compartment Id, Model Id, Is Echo, and so on.
For Rerank action, perform the following steps.
- Expand the topmost request node in the Target section.
- Within the topmost request node in the Target section, expand Request Wrapper, and then expand Body.
- Within Body, right-click each of the Documents element, and select Create target node.
- Click Design View
in the Expression Builder.
- For each of the Documents target element, in the Expression Builder, specify the documents that you want to rerank. This is a list of document strings to rerank based on the query you specify.
- Right-click Input, and select Create target node.
- For the Input target element, in the Expression Builder, specify the input text (input query for search in the documents).
You can also optionally configure other fields as needed in the mapper, such as Compartment Id, Endpoint Id, Is Echo, and so on.
- Exit the mapper.
The generative AI action is now configured.
Here's what happens when you activate and run the integration based on the action you selected:- Chat: Provides a text response to your question.
- EmbedText: Provides an embedding for the text you specified.
- Rerank: Provides an index and a relevance score to each document based on the input query you specified.