Skip to content

Commit e836793

Browse files
committed
create pipeline to extract questions and answer then save into text file
1 parent eece56f commit e836793

10 files changed

+149
-23
lines changed
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.

backend/services/answer_generation.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def setup_llm():
6969

7070
def answer_questions(qa_chain,input):
7171
query = f"""
72-
[INST] Based on the provided context, answer the question. query: {input} [/INST]
72+
[INST] You are a question answering chatbot. Based on the provided context, first analyze the whole context of the document including headings and sub headings of each chunk and then answer the question.question:query: {input} [/INST]
7373
"""
7474
result = qa_chain.invoke({"query": query})
7575
return result["result"]
@@ -131,37 +131,40 @@ def read_and_clean_questions(file_path):
131131

132132
return cleaned_questions
133133

134+
def save_to_file(questions, answers, output_file):
135+
with open(output_file, "w") as file:
136+
for index, (question, answer) in enumerate(zip(questions, answers)):
137+
file.write(f"{question}\n")
138+
file.write(f"Answer: {answer}\n")
139+
# file.write(f"Time spent: {answer['time_spent']} seconds\n")
140+
file.write("-" * 40 + "\n\n")
141+
134142
def main():
135143
questions = read_questions("questions.txt")
136-
cleaned_questions = read_and_clean_questions("questions.txt")
137-
print(cleaned_questions)
138-
print("------------------------")
139-
140-
file_path = "/Users/relisource/Personal Projects/QuestSolver/docs/BSBFIN501 Student Guide.docx"
144+
# cleaned_questions = read_and_clean_questions("questions.txt")
145+
print("Cleaning questions...")
146+
147+
file_path = "/Users/relisource/Personal Projects/QuestSolver/docs/financial_data/BSBFIN501 Student Guide.docx"
141148

142149
documents = load_docx(file_path)
143-
# print(f"documents : {documents}")
144150
splits = split_documents(documents)
145151
vectorstore = create_vector_store(splits)
146-
llm = setup_llm() # need to use opeanai here
152+
llm = setup_llm()
147153

148154
qa_chain = create_question_extraction_pipeline(vectorstore, llm)
149-
print("----------------------------------")
150-
print("\n")
151-
for index, question in enumerate(cleaned_questions):
155+
156+
answers = []
157+
print("Answering questions... This might take some time.")
158+
for question in questions:
152159
start_time = time.time()
153-
answer = answer_questions(qa_chain,question)
160+
answer = answer_questions(qa_chain, question)
154161
end_time = time.time()
155-
print(f"question {index+1}: {question}")
156-
print(f"answer : {answer}")
157-
print(f"Time spent: {end_time-start_time} seconds")
158-
print("--------------------------------")
159-
print("\n")
160-
# answer = answer_questions(qa_chain,"List three types of budgets.")
161-
# print(f"answer : {answer}")
162-
# end_time = time.time()
163-
# print("Extracted Questions:")
164-
# print(questions)
162+
163+
answers.append(answer)
164+
165+
output_file = "questions_and_answers.txt"
166+
save_to_file(questions, answers, output_file)
167+
print(f"Questions and answers saved to {output_file}")
165168

166169
if __name__ == "__main__":
167170
main()
-716 KB
Binary file not shown.

docs/BSBFIN501 Project Portfolio.docx

-712 KB
Binary file not shown.

questions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
1. Explain the basic principle of double entry bookkeeping.
2-
2. Complete the following table to describe the principles of cash and accrual accounting and an advantage and disadvantage of each method of accounting.
2+
2. Complete the following table to describe the principles of cash and accrual accounting and an advantage and disadvantage of each method of accounting.
33
- Type of accounting method
44
- Description
55
- One advantage and one disadvantage of this method

questions_and_answers.txt

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
1. Explain the basic principle of double entry bookkeeping.
2+
Answer: The basic principle of double-entry bookkeeping is that every financial transaction affects at least two different nominal ledger accounts. This system ensures that the accounting equation (Assets = Liabilities + Equity) always remains balanced. Here are the key points:
3+
4+
1. **Dual Effect**: Each transaction has a dual effect, meaning it involves at least two accounts. For example, if a business purchases equipment for cash, one account (Equipment) is debited, and another account (Cash) is credited.
5+
6+
2. **Debits and Credits**: In double-entry bookkeeping, debits and credits are used to record transactions. A debit entry increases asset or expense accounts and decreases liability, equity, or revenue accounts. Conversely, a credit entry decreases asset or expense accounts and increases liability, equity, or revenue accounts.
7+
8+
3. **Balancing the Books**: The total amount of debits must always equal the total amount of credits for each transaction. This ensures that the accounting equation remains balanced and helps in detecting errors.
9+
10+
4. **Recording Transactions**: Transactions are first recorded in journals, which are then posted to ledgers. The general ledger contains all accounts, while subsidiary ledgers contain specific account information.
11+
12+
By following these principles, double-entry bookkeeping provides a complete and accurate record of all financial transactions, ensuring the integrity of financial statements.
13+
----------------------------------------
14+
15+
2. Complete the following table to describe the principles of cash and accrual accounting and an advantage and disadvantage of each method of accounting. - Type of accounting method - Description - One advantage and one disadvantage of this method
16+
Answer: Sure, here is the completed table based on the provided context:
17+
18+
| Type of Accounting Method | Description | One Advantage | One Disadvantage |
19+
|---------------------------|-------------|---------------|------------------|
20+
| Cash Accounting | Tracks the actual cash money coming in and out of the business. Expenses and sales are recorded when cash changes hands. | Simple system that keeps track of business cash flow, suitable for smaller businesses. | Does not capture money that is owed or money owed to others, less control over transaction posting. |
21+
| Accrual Accounting | Records expenses and sales when they take place instead of when cash changes hands. | Tracks true financial position as it captures money owed and money owed to others, helpful for businesses dealing with lots of contracts or large amounts of money. | More complicated than cash accounting. |
22+
23+
This table summarizes the principles, advantages, and disadvantages of both cash and accrual accounting methods.
24+
----------------------------------------
25+
26+
3. Explain the two accounting principles on which the calculation and reporting of depreciation is based.
27+
Answer: The calculation and reporting of depreciation are based on two key accounting principles: the cost principle and the matching principle.
28+
29+
1. **Cost Principle**:
30+
- The cost principle requires that the depreciation expense is reported on the income statement.
31+
- The asset amount reported on the balance sheet should be based on the historical (original) cost of the asset, not on the amounts based on the cost to replace the asset or on the asset's current market value.
32+
33+
2. **Matching Principle**:
34+
- The matching principle requires that an asset's cost be allocated to the depreciation expense over the asset's life.
35+
- The asset's cost is divided up, with some of the cost being reported on each of the income statements issued during the life of the asset.
36+
- By assigning a portion of the asset's cost to various income statements, the accountant matches a portion of the asset's cost with each period in which the asset is used. This ensures that the asset's cost is being compared with the revenues earned by using the asset.
37+
----------------------------------------
38+
39+
4. List three types of budgets.
40+
Answer: Based on the provided context, three types of budgets are:
41+
42+
1. **Sales Budget**: This budget estimates the expected amount of money a company will receive from the sale of goods or services during a period. It helps set goals, estimate earnings, and forecast requirements.
43+
44+
2. **Purchases Budget**: This budget outlines the expected purchases of goods or services needed for production or resale. It helps manage inventory levels and ensure that the company has the necessary materials to meet sales forecasts.
45+
46+
3. **Cash Budget**: This budget is used to manage cash flows by estimating cash inputs and outputs for a given period. It helps avoid cash shortages by considering anticipated revenues, operating expenditures, asset sales and purchases, and debt settlements.
47+
----------------------------------------
48+
49+
5. List three key features of A New Tax System (GST) Act 1999.
50+
Answer: The context provided does not explicitly list the key features of A New Tax System (GST) Act 1999. However, based on general knowledge, here are three key features of the Act:
51+
52+
1. **Broad-Based Tax**: The GST is a broad-based tax of 10% on most goods, services, and other items sold or consumed in Australia.
53+
2. **Input Tax Credits**: Businesses can claim credits for the GST included in the price of goods and services they purchase for their business operations.
54+
3. **Registration Requirement**: Businesses with a certain turnover threshold are required to register for GST and regularly report and remit GST collected to the Australian Taxation Office (ATO).
55+
56+
For more detailed and specific information, you may refer to the ATO website or the actual text of the A New Tax System (Goods and Services Tax) Act 1999.
57+
----------------------------------------
58+
59+
6. Outline the four main taxation and superannuation obligations for a business.
60+
Answer: Based on the provided context, the four main taxation and superannuation obligations for a business are:
61+
62+
1. **Taxation Law Compliance**:
63+
- Businesses must comply with various taxation laws, including the Income Tax Assessment Act and the Fringe Benefits Tax Assessment Act. This involves accurately reporting income, claiming deductions, and paying the correct amount of tax.
64+
65+
2. **Goods and Services Tax (GST)**:
66+
- Businesses must comply with the New Tax System (Goods and Services Tax) Act 1999. This includes registering for GST if the business meets the turnover threshold, charging GST on taxable sales, and lodging regular Business Activity Statements (BAS) to report and pay GST.
67+
68+
3. **Superannuation Guarantee**:
69+
- Employers are required to comply with the Superannuation Guarantee (Administration) Act. This involves paying a minimum rate of superannuation contributions (currently 10.5%) on behalf of eligible employees into a complying superannuation fund.
70+
71+
4. **Record-Keeping and Reporting**:
72+
- Businesses must maintain accurate financial records as required by the Australian Taxation Office (ATO). This includes keeping records of all transactions, income, expenses, and superannuation contributions for a minimum of five years. Accurate record-keeping ensures compliance with tax laws and facilitates audits by the ATO.
73+
74+
These obligations ensure that businesses operate within the legal framework and contribute to the overall financial system's integrity.
75+
----------------------------------------
76+
77+
7. List three types of records that a company must keep for tax purposes.
78+
Answer: Based on the provided context, three types of records that a company must keep for tax purposes are:
79+
80+
1. Records that explain all transactions.
81+
2. Records that are written or recorded in paper or digital format.
82+
3. Records that are written in English or a format that can be easily converted.
83+
84+
These records must be kept for a minimum of five years, with some potentially required to be held for up to seven years.
85+
----------------------------------------
86+
87+
8. Explain why the ATO conducts audits.
88+
Answer: The Australian Taxation Office (ATO) conducts audits to ensure compliance with taxation laws and regulations. Audits help the ATO verify that businesses and individuals are accurately reporting their income, claiming the correct deductions, and paying the right amount of tax. This process is essential for maintaining the integrity of the tax system, ensuring that everyone pays their fair share, and preventing tax evasion and fraud. By conducting audits, the ATO can identify and address discrepancies, enforce tax laws, and promote voluntary compliance among taxpayers.
89+
----------------------------------------
90+
91+
9. List three key principles that should be followed when managing a work team. 10. Describe the difference between a static and a flexible budget. 11. Explain the relevance of electronic spreadsheets to budgeting. 12. Outline how often business’ must report GST. 13. Describe the following terms associated with financial statements: - Cash flow statements - Balance sheets - Ledgers - Profit and loss statements 14. Describe a method that can be used to evaluate a budget or financial plan.
92+
Answer: Based on the provided context, here are the answers to your questions:
93+
94+
**9. List three key principles that should be followed when managing a work team.**
95+
1. **Clear Communication:** Ensure that all team members understand their roles, responsibilities, and the financial objectives of the team and organization.
96+
2. **Support and Resources:** Provide the necessary resources and systems to help team members understand financial concepts and procedures, such as training and instructional documentation.
97+
3. **Monitoring and Evaluation:** Regularly review and evaluate financial management plans to ensure they are effective and align with the team's and organization's goals.
98+
99+
**10. Describe the difference between a static and a flexible budget.**
100+
- **Static Budget:** A static budget is fixed and does not change with variations in business activity levels. It is set for a specific period and remains unchanged regardless of changes in revenue or expenses.
101+
- **Flexible Budget:** A flexible budget adjusts based on changes in business activity levels. It allows for variations in costs and revenues, making it more adaptable to changing circumstances.
102+
103+
**11. Explain the relevance of electronic spreadsheets to budgeting.**
104+
Electronic spreadsheets are crucial for budgeting because they allow for:
105+
- **Data Organization:** Efficiently organizing and managing large amounts of financial data.
106+
- **Calculations:** Performing complex calculations quickly and accurately.
107+
- **Scenario Analysis:** Easily creating and comparing different budget scenarios.
108+
- **Visualization:** Presenting data in a visually appealing manner using charts and graphs.
109+
- **Collaboration:** Sharing and collaborating on budget documents with team members.
110+
111+
**12. Outline how often businesses must report GST.**
112+
The context does not provide specific information on how often businesses must report GST. Generally, the frequency of GST reporting can vary by country and business size, typically ranging from monthly, quarterly, to annually.
113+
114+
**13. Describe the following terms associated with financial statements:**
115+
- **Cash Flow Statements:** These statements show the inflows and outflows of cash within a business over a specific period, highlighting how well the company manages its cash position.
116+
- **Balance Sheets:** A balance sheet provides a snapshot of a company's financial position at a specific point in time, detailing assets, liabilities, and shareholders' equity.
117+
- **Ledgers:** Ledgers are comprehensive records of all financial transactions within a business, categorized by accounts.
118+
- **Profit and Loss Statements:** Also known as income statements, these show the company's revenues, expenses, and profits or losses over a specific period.
119+
120+
**14. Describe a method that can be used to evaluate a budget or financial plan.**
121+
One method to evaluate a budget or financial plan is **Variance Analysis.** This involves comparing the budgeted figures to the actual financial performance. By identifying and analyzing variances, managers can understand the reasons behind discrepancies and take corrective actions to align future performance with financial objectives.
122+
----------------------------------------
123+

0 commit comments

Comments
 (0)