Skip to content

Commit a71c54e

Browse files
sentiment-categorization-summarization-baseline
Baseline code for messages sentiment scoring, categorization and summarization.
1 parent bf78e13 commit a71c54e

File tree

13 files changed

+139
-64
lines changed

13 files changed

+139
-64
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Copyright (c) 2025 Oracle and/or its affiliates.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any
6+
person obtaining a copy of this software, associated documentation and/or data
7+
(collectively the "Software"), free of charge and under any and all copyright
8+
rights in the Software, and any and all patent rights owned or freely
9+
licensable by each licensor hereunder covering either (i) the unmodified
10+
Software as contributed to or provided by such licensor, or (ii) the Larger
11+
Works (as defined below), to deal in both
12+
13+
(a) the Software, and
14+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
15+
one is included with the Software (each a "Larger Work" to which the Software
16+
is contributed by such licensors),
17+
18+
without restriction, including without limitation the rights to copy, create
19+
derivative works of, display, perform, and distribute the Software and make,
20+
use, sell, offer for sale, import, export, have made, and have sold the
21+
Software and the Larger Work(s), and to sublicense the foregoing rights on
22+
either these or other terms.
23+
24+
This license is subject to the following condition:
25+
The above copyright notice and either this complete permission notice or at
26+
a minimum a reference to the UPL must be included in all copies or
27+
substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35+
SOFTWARE.
Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,32 @@
1-
> [!CAUTION]
2-
> Under construction.
1+
# Customer Message Analyzer
2+
3+
The Customer Message Analyzer is a tool designed to analyze customer messages through unsupervised categorization, sentiment analysis, and summary reporting. It helps businesses understand customer feedback without requiring extensive manual labeling or analysis.
4+
5+
6+
Reviewed: 01.04.2025
7+
8+
# When to use this asset?
9+
10+
Customer service teams, product managers, and marketing professionals would use this asset when they need to quickly understand large volumes of customer feedback, identify trends, and make data-driven decisions to improve products or services.
11+
12+
# How to use this asset?
13+
14+
To use the Customer Message Analyzer, follow these steps:
15+
16+
1. Input the customer messages into the system.
17+
2. The system will automatically cluster the messages into categories based on their content.
18+
3. Each message will receive a sentiment score indicating its emotional tone.
19+
4. Review the generated summary report highlighting dominant themes, sentiment trends, and actionable insights.
20+
21+
# Useful Links (Optional)
22+
23+
- [Confluence](https://confluence.oraclecorp.com/confluence/x/DaCEoAE)
24+
- Internal Reusable Assets
25+
26+
# License
27+
28+
Copyright (c) 2025 Oracle and/or its affiliates.
29+
30+
Licensed under the Universal Permissive License (UPL), Version 1.0.
31+
32+
See [LICENSE](https://github.com/oracle-devrel/technology-engineering/blob/main/LICENSE) for more details.

ai/generative-ai-service/sentiment+categorization/demo_code/backend/utils/config.py

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Batch Message Analysis and Categorization Demo
2+
This demo showcases an AI-powered solution for analyzing batches of customer messages, categorizing them into hierarchical levels, extracting sentiment scores, and generating structured reports.
3+
4+
## Key Features
5+
* **Hierarchical Categorization**: Automatically categorizes messages into three levels of hierarchy:
6+
+ Primary Category: High-level categorization
7+
+ Secondary Category: Mid-level categorization, building upon primary categories
8+
+ Tertiary Category: Low-level categorization, providing increased specificity and detail
9+
* **Sentiment Analysis**: Extracts sentiment scores for each message, ranging from very negative (1) to very positive (10)
10+
* **Structured Reporting**: Generates a comprehensive report analyzing the batch of messages, including:
11+
+ Category distribution across all three levels
12+
+ Sentiment score distribution
13+
+ Summaries of key findings and insights
14+
15+
## Data Requirements
16+
* Customer messages should be stored in a CSV file(s) within a folder named `data`.
17+
* Each CSV file should contain a column with the message text.
18+
19+
## Getting Started
20+
To run the demo, follow these steps:
21+
1. Clone the repository using `git clone`.
22+
2. Place your CSV files containing customer messages in the `data` folder.
23+
3. Install dependencies using `pip install -r requirements.txt`.
24+
4. Run the application using `streamlit run app.py`.
25+
26+
## Example Use Cases
27+
* Analyze customer feedback from surveys, reviews, or social media platforms to identify trends and patterns.
28+
* Inform product development and customer support strategies by understanding customer sentiment and preferences.
29+
* Optimize marketing campaigns by targeting specific customer segments based on their interests and concerns.
30+
31+
## Technical Details
32+
* The solution leverages Oracle Cloud Infrastructure (OCI) GenAI, a suite of AI services designed to simplify AI adoption.
33+
* Specifically, this demo utilizes the Cohere R+ model, a state-of-the-art language model optimized for natural language processing tasks.
34+
* All aspects of the demo, including:
35+
+ Hierarchical categorization
36+
+ Sentiment analysis
37+
+ Structured report generation
38+
are powered by GenAI, ensuring accurate and efficient analysis of customer messages.
39+
40+
## Output
41+
The demo will display an interactive dashboard with the generated report, providing valuable insights into customer messages, including:
42+
* Category distribution across all three levels
43+
* Sentiment score distribution
44+
* Summaries of key findings and insights
45+
46+
## Contributing
47+
We welcome contributions to improve and expand the capabilities of this demo. Please fork the repository and submit a pull request with your changes.
48+
49+
## License
50+
Copyright (c) [Year] Oracle Corporation. All rights reserved.
51+
52+
This demo is proprietary software owned by Oracle Corporation. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
53+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
54+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
55+
* Neither the name of Oracle Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
56+
57+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

ai/generative-ai-service/sentiment+categorization/demo_code/backend/feedback_agent.py renamed to ai/generative-ai-service/sentiment+categorization/files/backend/feedback_agent.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,6 @@ def initialize_model(self):
4747
model_kwargs=model_config["model_kwargs"],
4848
)
4949

50-
def initialize_embeddings(self):
51-
if self.model_name not in llm_config.MODEL_REGISTRY:
52-
raise ValueError(f"Unknown model: {self.model_name}")
53-
54-
model_config = llm_config.MODEL_REGISTRY[self.model_name]
55-
56-
embeddings = OCIGenAIEmbeddings(
57-
model_id=model_config["embedding_model"],
58-
service_endpoint=model_config["service_endpoint"],
59-
truncate="NONE",
60-
compartment_id=model_config["compartment_id"],
61-
auth_type=model_config["auth_type"],
62-
auth_profile=model_config["auth_profile"],
63-
)
64-
return embeddings
65-
6650
def read_messages(self):
6751
messages = handler.read_messages(filepath=messages_path)
6852
return handler.batchify(messages, 30)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
# Common Configuration
3+
COMPARTMENT_ID = "ocid1.compartment.oc1..XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
4+
DIRECTORY = "data"
5+
AUTH_TYPE = "API_KEY"
6+
CONFIG_PROFILE = "DEFAULT"
7+
ENDPOINT = "https://inference.generativeai.eu-frankfurt-1.oci.oraclecloud.com"
8+
9+
# COHERE data
10+
PROVIDER_COHERE = "cohere"
11+
GENERATE_MODEL_COHERE = "cohere.command-r-plus-08-2024"
12+
# LLAMA data
13+
PROVIDER_LLAMA = "meta"
14+
GENERATE_MODEL_LLAMA_33= "ocid1.generativeaimodel.oc1.eu-frankfurt-1.amaaaaaask7dceya4tdabclcsqbc3yj2mozvvqoq5ccmliv3354hfu3mx6bq"
15+

0 commit comments

Comments
 (0)