snrspeaks commited on
Commit
9c4e132
·
verified ·
1 Parent(s): bc3fb26

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +79 -0
README.md CHANGED
@@ -1,3 +1,82 @@
1
  ---
2
  license: gemma
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: gemma
3
  ---
4
+ This is Gemma 2B model (GGUF Q8_0) fine-tuned for financial aspect based sentiment analysis with structured JSON response.
5
+
6
+ **Input**
7
+ ```
8
+ financial_text = """Upon auditing Non-Profit Org, it was clear that the organization has made strides in improving financial accountability and donor transparency.
9
+ 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.
10
+ """
11
+ ```
12
+
13
+ **Response**
14
+ ```json
15
+ {
16
+ "Overall_Sentiment": "Mixed",
17
+ "Positive_Aspect": [
18
+ "financial accountability",
19
+ "donor transparency"
20
+ ],
21
+ "Negative_Aspect": [
22
+ "fund allocation inefficiencies",
23
+ "need for financial oversight"
24
+ ]
25
+ }
26
+ ```
27
+
28
+ ### Get started with Langchain
29
+ ```python
30
+ #!pip install --upgrade llama-cpp-python langchain_core langchain_community
31
+
32
+ from langchain_community.llms import LlamaCpp
33
+ from langchain_core.callbacks import CallbackManager, StreamingStdOutCallbackHandler
34
+
35
+ # Callbacks support token-wise streaming
36
+ callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
37
+
38
+ llm = LlamaCpp(
39
+ model_path="Gemma-2B-it-finance-aspect-based-sentiment-gguf-Q8_0.gguf",
40
+ max_tokens=2048,
41
+ temperature=0,
42
+ top_p=1,
43
+ callback_manager=callback_manager,
44
+ verbose=True, # Verbose is required to pass to the callback manager
45
+ )
46
+
47
+ 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.
48
+
49
+ ### Instruction:
50
+ Perform Aspect based sentiment analysis.
51
+ Present your response in python JSON format with "Overall_Sentiment", "Positive_Aspect", "Negative_Aspect".
52
+
53
+
54
+ ### Input:
55
+ {financial_text}
56
+
57
+
58
+ ### Response:
59
+ """
60
+
61
+ financial_text = """Upon auditing Non-Profit Org, it was clear that the organization has made strides in improving financial accountability and donor transparency.
62
+ 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.
63
+ """
64
+
65
+ prompt = prompt_template.format(financial_text=financial_text)
66
+
67
+ response = llm.invoke(prompt)
68
+ ```
69
+ ### Response:
70
+ ```json
71
+ {
72
+ "Overall_Sentiment": "Mixed",
73
+ "Positive_Aspect": [
74
+ "financial accountability",
75
+ "donor transparency"
76
+ ],
77
+ "Negative_Aspect": [
78
+ "fund allocation inefficiencies",
79
+ "need for financial oversight"
80
+ ]
81
+ }
82
+ ```