Generate Human-Like Paraphrases with the sharaddition/paraphrase-gpt Actions

21 Apr 2025
Generate Human-Like Paraphrases with the sharaddition/paraphrase-gpt Actions

In the world of content creation and education, the ability to generate human-like paraphrases of text is invaluable. The sharaddition/paraphrase-gpt Cognitive Actions provide developers with an easy-to-use interface for generating paraphrases using a powerful T5 model fine-tuned on a GPT-3.5 paraphrase corpus. These pre-built actions help streamline content modification and improve readability while maintaining the original meaning, making them particularly beneficial for content creators, educators, and anyone looking to enhance their writing.

Prerequisites

To get started with the sharaddition/paraphrase-gpt actions, you will need the following:

  • An API key for the Cognitive Actions platform. This key will allow you to authenticate your requests.
  • Familiarity with making HTTP requests in your preferred programming language.

For authentication, you typically pass the API key in the request headers, ensuring that only authorized users can access the Cognitive Actions.

Cognitive Actions Overview

Generate Paraphrases

Description:
This action utilizes a T5 model fine-tuned on a GPT-3.5 paraphrase corpus to generate human-like paraphrases, ensuring that the original sentence's meaning is preserved. It is particularly useful for content creators and educators looking to rephrase text effectively.

Category:
Text Generation

Input

The input schema for this action is as follows:

{
  "topP": 1,
  "prompt": "Your text to paraphrase here.",
  "numBeams": 5,
  "maxLength": 250,
  "temperature": 0.75,
  "numBeamGroups": 5,
  "diversityPenalty": 3,
  "noRepeatNgramSize": 2,
  "repetitionPenalty": 10,
  "numReturnSequences": 5
}
  • prompt (required): The text or query to be processed (e.g., "These practices, also known as ‘dark patterns,’ are in the nature of unfair trade practices…").
  • topP (optional): Cumulative probability threshold for token sampling (default: 1).
  • numBeams (optional): Number of sequences to explore during generation (default: 5).
  • maxLength (optional): Upper limit for the number of tokens in generated text (default: 50).
  • temperature (optional): Influences randomness in the output (default: 0.75).
  • numBeamGroups (optional): Number of beam groups for exploring sequences (default: 5).
  • diversityPenalty (optional): Penalty for repeated phrases (default: 3).
  • noRepeatNgramSize (optional): Prevents repetition of n-grams of specified size (default: 2).
  • repetitionPenalty (optional): Penalty for repeated phrases (default: 10).
  • numReturnSequences (optional): Number of different sequences to return (default: 5).

Example Input:

{
  "topP": 1,
  "prompt": "These practices, also known as ‘dark patterns,’ are in the nature of unfair trade practices and are covered under the Consumer Protection Act, which is punishable, according to Union consumer affairs secretary Rohit Kumar Singh.",
  "numBeams": 5,
  "maxLength": 250,
  "temperature": 0.75,
  "numBeamGroups": 5,
  "diversityPenalty": 3,
  "noRepeatNgramSize": 2,
  "repetitionPenalty": 10,
  "numReturnSequences": 5
}

Output

The output of this action will be an array of paraphrased sentences. Here’s what you can expect:

Example Output:

[
  "According to Rohit Kumar Singh, the Union consumer affairs secretary, 'dark patterns' are unfair trade practices that fall under the Consumer Protection Act and can be punished.",
  "Rohit Kumar Singh, the Union consumer affairs secretary, has stated that 'dark patterns' are unfair trade practices and fall under the Consumer Protection Act, which is punishable by law.",
  "The 'dark patterns' are unfair trade practices that fall under the scope of the Consumer Protection Act and can be punished, as stated by Union consumer affairs secretary Rohit Kumar Singh.",
  "Union consumer affairs secretary Rohit Kumar Singh has stated that 'dark patterns' are unfair trade practices, which fall under the scope of the Consumer Protection Act and can be punished.",
  "'Dark patterns,’ also known as unfair trade practices, are covered by the Consumer Protection Act and can result in punishment, according to Union consumer affairs secretary Rohit Kumar Singh."
]

Conceptual Usage Example (Python)

Here’s a conceptual example of how you might call the Generate Paraphrases action using Python:

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 = "f8ddfa6c-2dd6-47bf-977d-9159fb3c6392" # Action ID for Generate Paraphrases

# Construct the input payload based on the action's requirements
payload = {
    "topP": 1,
    "prompt": "These practices, also known as ‘dark patterns,’ are in the nature of unfair trade practices and are covered under the Consumer Protection Act...",
    "numBeams": 5,
    "maxLength": 250,
    "temperature": 0.75,
    "numBeamGroups": 5,
    "diversityPenalty": 3,
    "noRepeatNgramSize": 2,
    "repetitionPenalty": 10,
    "numReturnSequences": 5
}

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 will notice the action_id for the Generate Paraphrases action and the payload containing the necessary input parameters. The endpoint URL and request structure are illustrative, and you should adjust them based on the actual service you are using.

Conclusion

With the sharaddition/paraphrase-gpt Cognitive Actions, developers can effortlessly integrate powerful paraphrasing capabilities into their applications. By leveraging these actions, you can enhance the quality of your content, improve readability, and provide more value to your users. Whether for content creation, educational purposes, or enhancing user experience, these actions are a valuable addition to any developer's toolkit. Start integrating them today and see how they can transform your text generation workflows!