I am presently working on a project. So a dear friend of mine is in an accounting firm. I saw a problem that involved too much of human effort. Like the guys would read bank statement, categorize entries in excel file, recheck debit and credit total with the total given in the statement and then enter in their system (quickbooks and excel files). I came up with an idea to use privateGPT after watching some videos to read their bank statements and give the desired output. That way much of the reading and organization time will be finished. So questions are as follows: Has anyone been able to fine tune privateGPT to give tabular or csv or json style output? Any links to article of exact video since I have been getting generic info. How can we save the desired output of private GPT to a csv? I was looking for something like $Python3 privategpt.py -m "What is the closing balance of $1" -i xyz.pdf >> ABC.txt where -i would mean input file and -m would mean prompt. This works only when I have the output fine tuned to the way I want. Does private GPT have model stacking capabilities? I want to expand this to reading scanned bank statements. how to finetune responses of Private GPT. For instance I just want the closing balance or sum of debit and credit transaction, not the extra info. How to remove extra details? Moreover how can we save the responses to txt file? Tried various video tutorials and docs. It did not cover the issue

1

There are 1 best solutions below

2
On

Try this

    # Replace 'your_string' with the actual string you want to save
your_string = "Hello, this is your string."

# Specify the file path where you want to save the text file
file_path = "output.txt"

# Open the file in write mode ('w' for writing)
with open(file_path, 'w') as file:
    # Write the string to the file
    file.write(your_string)

print(f"The string has been saved to {file_path}")

You can also try

# Interactive questions and answers
while True:
    query = input("\nEnter a query: ")
    if query == "exit":
        break
    if query.strip() == "":
        continue

    # Get the answer from the chain
    start = time.time()
    res = qa(query)
    answer, docs = res['result'], [] if args.hide_source else res['source_documents']
    end = time.time()

    # Print the result
    print("\n\n> Question:")
    print(query)
    print(f"\n> Answer (took {round(end - start, 2)} s.):")
    print(answer)

    # Save the answer to a text file
    save_to_text_file(answer)

    # Print the relevant sources used for the answer
    # for document in docs:
    #    print("\n> " + document.metadata["source"] + ":")
    #    print(document.page_content)

def save_to_text_file(answer): # Specify the file path where you want to save the text file file_path = "answer_output.txt"

# Open the file in write mode ('w' for writing)
with open(file_path, 'w') as file:
    # Write the answer string to the file
    file.write(answer)

print(f"The answer has been saved to {file_path}")