Harnessing the Power of Text Generation with Mamba 790M Cognitive Actions

24 Apr 2025
Harnessing the Power of Text Generation with Mamba 790M Cognitive Actions

The adirik/mamba-790m API introduces an exciting way for developers to integrate advanced text generation capabilities into their applications. With the Generate Text with Mamba 790M action, you can leverage a powerful language model comprising 790 million parameters to craft text based on your prompts. This pre-built action not only saves you time but also provides customizable options to fine-tune the outputs according to your specific needs.

Prerequisites

Before you dive into using the Cognitive Actions, ensure you have the following:

  • API Key: You will need an API key for the Cognitive Actions platform. This key will authenticate your requests.
  • Basic Setup: Familiarity with making HTTP requests and handling JSON responses will be beneficial.

In conceptual terms, authentication typically involves passing your API key in the headers of your requests.

Cognitive Actions Overview

Generate Text with Mamba 790M

Description: This action allows you to utilize the Mamba 790M language model to generate coherent and contextually relevant text responses based on a provided prompt. You can customize the output with options for randomness, length, and repetition control.

Category: Text Generation

Input

The input schema requires the following fields:

  • prompt (required): Text prompt to send to the model.
    Example: "How are you doing today?"

Optional fields include:

  • seed: An integer to specify the seed used for generating random numbers, ensuring repeatability of results.
  • topK: Determines the number of top most likely tokens considered during text decoding (default is 1).
  • topP: Sets the cumulative probability mass of the most likely tokens considered (default is 1, between 0.01 and 1).
  • maxLength: Sets the upper limit of tokens generated in the response (default is 100, between 1 and 5000).
  • temperature: Controls the randomness of the generated outputs (default is 1, values between 0.1 and 5).
  • repetitionPenalty: Applies a penalty to repeated words in generated text (default is 1.2).

Here’s an example input payload:

{
  "topK": 1,
  "topP": 1,
  "prompt": "How are you doing today?",
  "maxLength": 100,
  "temperature": 1,
  "repetitionPenalty": 1.2
}

Output

The action typically returns a sequence of generated tokens as output, which may look like this:

[
    "I'm ",
    "good. ",
    "I ",
    "just ",
    "got ",
    "back ",
    "from ",
    "the ",
    "doctor's ",
    "office...",
    ":)<|endoftext|>Q:\n\n"
]

This output can include a mixture of coherent text, spacing, and may also contain various formatting elements.

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet demonstrating how to call the Cognitive Actions execution endpoint for this action:

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 = "bdfcd759-bfcb-41e5-9ecb-73c5f95a4ce8"  # Action ID for Generate Text with Mamba 790M

# Construct the input payload based on the action's requirements
payload = {
    "topK": 1,
    "topP": 1,
    "prompt": "How are you doing today?",
    "maxLength": 100,
    "temperature": 1,
    "repetitionPenalty": 1.2
}

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, you set the action ID and construct the input payload based on the action's requirements. The endpoint URL and the request structure are illustrative; you may need to adjust them based on your actual API setup.

Conclusion

The Generate Text with Mamba 790M action offers a robust solution for developers looking to incorporate advanced text generation capabilities into their applications. With customizable parameters, you can fine-tune the outputs to suit your specific needs, whether for chatbots, content creation, or other creative applications. As you explore this action, consider experimenting with different input settings to discover the full potential of the Mamba 790M model in your projects. Happy coding!