liveBook · Manning

Generative modeling

As explained in Build Financial Software with Generative AI (From Scratch)

Generative artificial intelligence, or generative AI, produces new content such as text, code, images, or other data from learned patterns and input.

Generative AI creates new content in response to input. It can act like an interactive rubber duck: instead of merely listening as you describe a problem, it offers ideas and feedback. Tools such as ChatGPT and GitHub Copilot use large language models to assist with development. section 1.5.1

For an Automated Clearing House (ACH) dashboard, generative AI can help developers write and troubleshoot code across the user interface and backend. It can also help generate test data, including company details and logos. section 1.1 section 10.8

A practical workflow is to:

  • Define the problem and give a clear, concise prompt; include an example when useful. section 1.5.2
  • Review the result and ask for specific changes. Knowing the desired behavior helps even when you need help with syntax. section 1.5.2 section 1.5.4
  • Test the result against expected behavior and verify version-specific advice rather than assuming it is current. section 1.5.3 section 1.5.7

Refining a balance formatter

Ask ChatGPT to format a current balance in Python, then request a function and type hints. A further prompt changes the function to return the formatted string instead of printing it, leaving the caller to decide what to do with the result. section 1.5.2

Listing 1.4 Returning a string
def print_balance(current_balance: str) -> str:  #1
    """
    Returns the current balance in a formatted string.

    Parameters:
    - current_balance (str): The current balance to be formatted, as a string.

    Returns:                                #2
    - str: The formatted current balance.    #2
    """
    return f"Current Balance: ${float(current_balance):,.2f}" #3

# Ask the user to enter the current balance
user_input = input("Enter current balance: ") #4

# Call the function to get the formatted balance and then print it
formatted_balance = print_balance(user_input)  #5
print(formatted_balance)   #6

The revised function returns a formatted balance; the calling code prints it separately. section 1.5.2

Debugging recent transactions

A transaction-list function is expected to retain three entries but produces only two. A unit test captures the expected count and first remaining transaction; an AI tool can help investigate the logic, while the test provides a check on any proposed fix. section 1.5.3

Protect what you put into a prompt. Proprietary code, personal information, and nonpublic business information may be sensitive. For debugging, consider a smaller, generalized snippet that still reproduces the problem, and check the tool’s data-handling policies. section 1.5.6

How Build Financial Software with Generative AI (From Scratch) covers it

How deep it goes
Introduces practical prompting and iterative code refinement, while stopping short of a comprehensive treatment of generative AI.
Examples
Works through a Python balance formatter, a faulty transaction list, and an HTML5 D3.js bar chart.
What it assumes
Assumes basic software development concepts, while showing that the balance example can be developed without prior Python knowledge.
What you can do after
Apply it via ChatGPT to refine code and investigate bugs, then test results and verify version-specific suggestions.
How it connects
Connects generative AI to machine learning, large language models, rubber duck debugging, and unit testing.

Also explained in

Compare how 32 books explain generative modeling →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Financial Software with Generative AI (From Scratch). The section links point to the parts of the book it draws on.