snrspeaks's picture
Update README.md
9c4e132 verified
---
license: gemma
---
This is Gemma 2B model (GGUF Q8_0) fine-tuned for financial aspect based sentiment analysis with structured JSON response.
**Input**
```
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.
"""
```
**Response**
```json
{
"Overall_Sentiment": "Mixed",
"Positive_Aspect": [
"financial accountability",
"donor transparency"
],
"Negative_Aspect": [
"fund allocation inefficiencies",
"need for financial oversight"
]
}
```
### Get started with Langchain
```python
#!pip install --upgrade llama-cpp-python langchain_core langchain_community
from langchain_community.llms import LlamaCpp
from langchain_core.callbacks import CallbackManager, StreamingStdOutCallbackHandler
# Callbacks support token-wise streaming
callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
llm = LlamaCpp(
model_path="Gemma-2B-it-finance-aspect-based-sentiment-gguf-Q8_0.gguf",
max_tokens=2048,
temperature=0,
top_p=1,
callback_manager=callback_manager,
verbose=True, # Verbose is required to pass to the callback manager
)
prompt_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.
### Instruction:
Perform Aspect based sentiment analysis.
Present your response in python JSON format with "Overall_Sentiment", "Positive_Aspect", "Negative_Aspect".
### Input:
{financial_text}
### Response:
"""
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.
"""
prompt = prompt_template.format(financial_text=financial_text)
response = llm.invoke(prompt)
```
### Response:
```json
{
"Overall_Sentiment": "Mixed",
"Positive_Aspect": [
"financial accountability",
"donor transparency"
],
"Negative_Aspect": [
"fund allocation inefficiencies",
"need for financial oversight"
]
}
```