Unleashing Creativity with the Goliath-120B Cognitive Actions

24 Apr 2025
Unleashing Creativity with the Goliath-120B Cognitive Actions

In this post, we will explore the nateraw/goliath-120b API, which provides developers with powerful Cognitive Actions for advanced text generation. The Goliath-120B model is an auto-regressive causal language model that combines the strengths of two fine-tuned Llama-2 70B models, enabling the creation of high-quality text with customizable parameters. By leveraging this API, developers can streamline content creation, enhance applications with natural language capabilities, and provide users with engaging experiences.

Prerequisites

Before diving into the integration of the Goliath-120B Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of JSON and RESTful APIs.
  • Familiarity with Python for executing API calls.

Authentication typically involves passing your API key in the request headers, allowing you to securely access the Cognitive Actions.

Cognitive Actions Overview

Generate Text Using Goliath Model

The Generate Text Using Goliath Model action allows you to utilize the Goliath-120B model for generating text based on an input prompt. This action falls under the text-generation category and offers various parameters to customize the output.

Input

The input for this action is structured as follows:

{
  "prompt": "write me a blogpost all about parmigiano reggiano. Include helpful tips, like what to do with the rinds, whether you should buy pre-grated vs non-grated, etc, etc. Grumble about poor quality american Parmesan.",
  "topK": 50,
  "topP": 0.95,
  "temperature": 0.8,
  "maxNewTokens": 2048,
  "promptTemplate": "You are a helpful AI assistant.\n\nUSER: {prompt}\nASSISTANT:",
  "presencePenalty": 1,
  "frequencyPenalty": 0
}
  • prompt (required): The input text to guide the generation.
  • topK (optional): The number of top probable tokens to retain for output generation.
  • topP (optional): Cumulative probability threshold for token selection.
  • temperature (optional): Controls the randomness of the output.
  • maxNewTokens (optional): Maximum number of tokens the model can generate.
  • promptTemplate (optional): Template to format the prompt for the AI model.
  • presencePenalty (optional): Increases penalty for token presence to reduce repeated content.
  • frequencyPenalty (optional): Reduces the likelihood of frequent tokens.

Example Input

Here is an example input payload showcasing the required and optional fields:

{
  "topK": 50,
  "topP": 0.95,
  "prompt": "write me a blogpost all about parmigiano reggiano. Include helpful tips, like what to do with the rinds, whether you should buy pre-grated vs non-grated, etc, etc. Grumble about poor quality american Parmesan.",
  "temperature": 0.8,
  "maxNewTokens": 2048,
  "promptTemplate": "You are a helpful AI assistant.\n\nUSER: {prompt}\nASSISTANT:",
  "presencePenalty": 1,
  "frequencyPenalty": 0
}

Output

The output of the action is a JSON array containing the generated text, which is broken down into tokens. Below is a snippet of the example output:

[
  " Title",
  ":",
  " The",
  " King",
  " of",
  " Che",
  "eses",
  ":",
  " All",
  " H",
  "ail",
  " Par",
  "m",
  "ig",
  "iano",
  " Reg",
  "g",
  "iano",
  "!",
  ...
]

The output may vary based on the input prompt and parameters used, providing a rich and varied text generation experience.

Conceptual Usage Example (Python)

Below is a conceptual Python code snippet that demonstrates how to call the Goliath model's text generation action using a hypothetical Cognitive Actions API endpoint:

import requests
import json

# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint

action_id = "66d3a421-72e4-4c5c-9802-8b6b72bf2497" # Action ID for Generate Text Using Goliath Model

# Construct the input payload based on the action's requirements
payload = {
    "topK": 50,
    "topP": 0.95,
    "prompt": "write me a blogpost all about parmigiano reggiano. Include helpful tips, like what to do with the rinds, whether you should buy pre-grated vs non-grated, etc, etc. Grumble about poor quality american Parmesan.",
    "temperature": 0.8,
    "maxNewTokens": 2048,
    "promptTemplate": "You are a helpful AI assistant.\n\nUSER: {prompt}\nASSISTANT:",
    "presencePenalty": 1,
    "frequencyPenalty": 0
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json={"action_id": action_id, "inputs": payload} # Hypothetical structure
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body: {e.response.text}")

In this snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable is structured according to the required input schema, and the response is handled appropriately, showcasing success or error messages.

Conclusion

The Goliath-120B Cognitive Actions provide developers with robust tools for generating high-quality text tailored to specific needs. By utilizing the action for text generation, you can enhance your applications with engaging content, automate writing tasks, and offer personalized user experiences. As a next step, consider experimenting with different prompts and parameters to discover the full potential of the Goliath model in your projects!