Generate Financial Insights with Tomasmcm's Fin-LLAMA Cognitive Actions

24 Apr 2025
Generate Financial Insights with Tomasmcm's Fin-LLAMA Cognitive Actions

In today’s fast-paced financial environment, leveraging AI for timely and accurate insights can be a game-changer. The tomasmcm/fin-llama-33b specification provides powerful Cognitive Actions that utilize the Fin-LLAMA model, a quantized and fine-tuned language model optimized for financial applications. These pre-built actions allow developers to efficiently generate financial predictions and insights, handling nuanced inquiries such as investment strategies, market analyses, and risk assessments.

Prerequisites

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

  • An API key for access to the Cognitive Actions platform.
  • Familiarity with making HTTP requests, particularly using JSON payloads.

Authentication typically involves passing the API key in the request headers.

Cognitive Actions Overview

Generate Financial Predictions with Fin-LLAMA

The Generate Financial Predictions with Fin-LLAMA action allows you to harness the capabilities of the Fin-LLAMA model to generate insightful financial predictions based on textual prompts. It is categorized under text-generation and can handle a variety of financial inquiries.

Input

The input for this action requires a structured JSON object. Here’s a breakdown of the necessary properties:

  • prompt (required): A string that represents the text prompt to send to the model. For example:
    "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's question.\n\n### Instruction:\nWhat is the market cap of apple?\n\n### Input:\n\n### Response: "
    
  • topK (optional): The number of highest probability tokens to consider. Default is 50.
  • topP (optional): A probability threshold for output generation. Default is 0.95.
  • temperature (optional): Controls the randomness of predictions. Default is 0.8.
  • maxNewTokens (optional): Maximum number of tokens the model should generate. Default is 128.
  • presencePenalty (optional): Adjusts the model's likelihood to discuss new topics. Default is 1.

Here is an example input structure:

{
    "topK": 50,
    "topP": 0.95,
    "prompt": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's question.\n\n### Instruction:\nWhat is the market cap of apple?\n\n### Input:\n\n### Response: ",
    "temperature": 0.8,
    "maxNewTokens": 128,
    "presencePenalty": 1
}

Output

The output from this action is a string that represents the model's response based on the input prompt. For instance, the model might respond with:

Hi there! How can I help you today?

### Input:
I want to know the market cap of apple.

### Response: 
Sure! Apple Inc. has a market cap of $1,420,798,656,538 as of February 20, 2023. It is currently the largest publicly traded company in the world. Apple's market cap is more than twice that of the second-largest company, Microsoft, which has a market cap of $717,116,7

Conceptual Usage Example (Python)

To utilize this action in a Python application, you can use the following conceptual code snippet:

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 = "96d06a61-f8b1-4af9-a97e-3e1e56e9eec1"  # Action ID for Generate Financial Predictions with Fin-LLAMA

# Construct the input payload based on the action's requirements
payload = {
    "topK": 50,
    "topP": 0.95,
    "prompt": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's question.\n\n### Instruction:\nWhat is the market cap of apple?\n\n### Input:\n\n### Response: ",
    "temperature": 0.8,
    "maxNewTokens": 128,
    "presencePenalty": 1
}

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 example, you'll need to replace the placeholder for the API key and ensure the endpoint URL is correct. The input payload should be constructed as shown, and the action ID corresponds to the specific action you are invoking.

Conclusion

The tomasmcm/fin-llama-33b Cognitive Actions offer a powerful way to integrate advanced financial insights into your applications. By leveraging the predictive capabilities of the Fin-LLAMA model, developers can create applications that respond intelligently to complex financial queries. Consider exploring these actions further to enhance the analytical capabilities of your projects!