Taking a look at financial data with Ollama

Several weeks ago a person asked me to assist her with organizing her financial records to take them to a tax professional. This person does not use a financial program like GnuCash which could make that project much easier. Instead we downloaded a csv file from her bank and then she used Microsoft Excel to add a category to each expense. This was a tedious process. I used a pivot table to further organize and display her data which she took to the tax preparer.

Recently while working on other projects with Ollama I wondered if it might be possible to use a local large language model to accomplish the same task. It is easy to download Ollama. If you are a LInux user like I am you can enter the following command in a terminal.

curl -fsSL https://ollama.com/install.sh | sh

I experimented with phi3.5 and Llama3.2 and found the latter to work better for me. It is easy to pull the model down to your computer with the following command:

$ ollama pull Llama3.2

Once the model was downloaded to my computer I wanted to make my own custom model to analyze my financial data set which was a csv file from the bank. I created a model file which I called financial using nano. Here is the text of the modelfile I created for this activity:

FROM llama3.2

# set the temperature to 1 [higher is more creative, lower is more coherent]

PARAMETER temperature .6

# set the system message

SYSTEM “””

You are a financial analyst. Analyze the financial information I supply.

“””

I used the model file to to create the custom model for this financial analysis. I set the temperature PARAMETER to .6 to make the work more accurate. I entered the following command in the terminal:

$ ollama create financial -f financial

This created the unique LLM based on Llama3.2 to perform the financial analysis. I made sure that the csv file from my financial institution was in the same directory as I was currently operating. This is important and then entered the following command to pull the csv file into the custom LLM.

ollama run financial:latest "$(cat data.csv)", Summarize my transactions. 

This gave me a complete summary of the debits and credits that were included in the small csv file. I have encountered some errors and I plan to keep working with the model and reading. I’m encoueraged by the results.