Views
No views yet
financial_text = """Upon auditing Non-Profit Org, it was clear that the organization has made strides in improving financial accountability and donor transparency.
However, the audit also unveiled significant inefficiencies in fund allocation, signaling a need for better financial oversight to ensure the organization's sustainability and mission effectiveness.
"""1{
2 "Overall_Sentiment": "Mixed",
3 "Positive_Aspect": [
4 "financial accountability",
5 "donor transparency"
6 ],
7 "Negative_Aspect": [
8 "fund allocation inefficiencies",
9 "need for financial oversight"
10 ]
11}1#!pip install --upgrade llama-cpp-python langchain_core langchain_community
2
3from langchain_community.llms import LlamaCpp
4from langchain_core.callbacks import CallbackManager, StreamingStdOutCallbackHandler
5
6# Callbacks support token-wise streaming
7callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
8
9llm = LlamaCpp(
10 model_path="Gemma-2B-it-finance-aspect-based-sentiment-gguf-Q8_0.gguf",
11 max_tokens=2048,
12 temperature=0,
13 top_p=1,
14 callback_manager=callback_manager,
15 verbose=True, # Verbose is required to pass to the callback manager
16)
17
18prompt_template = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
19
20### Instruction:
21Perform Aspect based sentiment analysis.
22Present your response in python JSON format with "Overall_Sentiment", "Positive_Aspect", "Negative_Aspect".
23
24
25### Input:
26{financial_text}
27
28
29### Response:
30"""
31
32financial_text = """Upon auditing Non-Profit Org, it was clear that the organization has made strides in improving financial accountability and donor transparency.
33However, the audit also unveiled significant inefficiencies in fund allocation, signaling a need for better financial oversight to ensure the organization's sustainability and mission effectiveness.
34"""
35
36prompt = prompt_template.format(financial_text=financial_text)
37
38response = llm.invoke(prompt)1{
2 "Overall_Sentiment": "Mixed",
3 "Positive_Aspect": [
4 "financial accountability",
5 "donor transparency"
6 ],
7 "Negative_Aspect": [
8 "fund allocation inefficiencies",
9 "need for financial oversight"
10 ]
11}