This demo showcases how to use LLMs to turn audio files from call center conversations between customers and agents into valuable data, all in a single workflow orchestrated by MLRun. It illustrates the potential power of LLMs for feature extraction, and the simplicity of working with MLRun.
MLRun automates the entire workflow, auto-scales resources as needed, and automatically logs and parses values between the different workflow steps.
The demo demonstrates two usages of GenAI:
- Unstructured data generation: Generating audio data with ground truth metadata to evaluate the analysis.
- Unstructured data analysis: Turning audio calls into text and tabular features.
The demo contains a single notebook that encompasses the entire demo.
Most of the functions are imported from MLRun's hub, which contains a wide range of functions and modules that can be used for a variety of use cases. See also the MLRun hub documentation. All functions used in the demo include links to their source in the hub. All of the python source code is under /src.
⚠️ Important This demo can take an hour to complete when running without GPUs.
This demo uses:
- OpenAI's Whisper — To transcribe the audio calls into text.
- Flair and Microsoft's Presidio — To recognize PII so it can be filtered out.
- HuggingFace — The main machine-learning framework to get the model and tokenizer for the features extraction.
- Vizro — To view the call center DB and transcriptions, and to play the generated conversations.
- MLRun — the orchestrator to operationalize the workflow. MLRun 1.9 and higher, Python 3.11, with CPU or GPU.
- SQLAlchemy — Manage the MySQL DB of calls, clients and agents. Installed together with MLRun.
- MySQL database. Installed together with MLRun. (SQLite is not currently supported.)
This project can run in different development environments:
- Local computer (using PyCharm, VSCode, Jupyter, etc.)
- Inside GitHub Codespaces
- Other managed Jupyter environments
To get started, fork this repo into your GitHub account and clone it into your development environment.
To install the package dependencies (not required in GitHub codespaces) use:
make install-requirements
If you prefer to use Conda, use this instead (to create and configure a conda env):
make conda-env
Make sure you open the notebooks and select the mlrun conda environment
The MLRun service and computation can run locally (minimal setup) or over a remote Kubernetes environment.
If your development environment supports Docker and there are sufficient CPU resources, run:
make mlrun-docker
The MLRun UI can be viewed in: http://localhost:8060
If your environment is minimal, run mlrun as a process (no UI):
[conda activate mlrun &&] make mlrun-api
For MLRun to run properly, set up your client environment. This is not required when using codespaces, the mlrun conda environment, or iguazio managed notebooks.
Your environment should include MLRUN_ENV_FILE=<absolute path to the ./mlrun.env file> (point to the mlrun .env file
in this repo); see mlrun client setup instructions for details.
Note: You can also use a remote MLRun service (over Kubernetes): instead of starting a local mlrun: edit the mlrun.env and specify its address and credentials.
!pip install SQLAlchemy==2.0.31 pymysql dotenv
Set the following configuration: choose compute device: CPU or GPU; choose the language of the calls; and whether to skip the calls generation workflow and use pre-generated data. For example:
# True = run with GPU, False = run with CPU
run_with_gpu = False
use_sqlite = False
engine = "remote
language = "en" # The languages of the calls, es - Spanish, en - English
skip_calls_generation = False
Differences between installing on Iguazio cluster and Platform McKinsey:
- SQLite is supported
- Set
run_with_gpu = False,use_sqlite = True,engine = "remote". .envmust includeOPENAI_API_KEY,OPENAI_API_BASE, andS3_BUCKET_NAME.- S3 Bucket —
S3_BUCKET_NAME
⚠️ Important Fill in the following variables in your.envfile.
Note: The requirement for the OpenAI token will be removed soon in favor of an open-source LLM.
Tokens are required to run the demo end-to-end:
- OpenAI ChatGPT — To generate conversations, two tokens are required:
OPENAI_API_KEYOPENAI_API_BASE
- MySQL — A URL with username and password for collecting the calls into the DB.
MYSQL_URL
If you want to install mysql using helm chart, use this command:
helm install -n <"namesapce"> myrelease bitnami/mysql --set auth.rootPassword=sql123 --set auth.database=mlrun_demos --set primary.service.ports.mysql=3111 --set primary.persistence.enabled=falseExample for MYSQL_URL if you use the above command:
mysql+pymysql://root:sql123@myrelease-mysql.<"namesapce">.svc.cluster.local:3111/mlrun_demos
import dotenv
import os
import sys
import mlrun
dotenv_file = ".env"
sys.path.insert(0, os.path.abspath("./"))
dotenv.load_dotenv(dotenv_file)
assert not run_with_gpu
assert os.environ["OPENAI_API_BASE"]
assert os.environ["OPENAI_API_KEY"]
if not mlrun.mlconf.is_ce_mode():
assert os.environ["MYSQL_URL"]
use_sqlite = False
else:
use_sqlite = True
- Create the project
- Notebook: call-center-demo.ipynb
- Description:
- Key steps: Create the MLRun project.
- Key files:
- Generate the call data
-
Notebook: call-center-demo.ipynb
-
Description: Generate the call data. (You can choose to skip this step ans use call data that is already generated and available in the demo.)
-
Key steps: To generate data, run: Agents & clients data generator, Insert agents & clients data to DB, Get agents & clients from DB, Conversation generation, Text to Audio, and Batch Creation. and Batch creation. Then run the workflow.
-
Key files:
-
MLRun hub functions:
- Calls analysis
-
Notebook: call-center-demo.ipynb
-
Description: Insert the call data to the DB, use diarization to analyze when each person is speaking, transcribe and translate the calls into text and save them as text files, recognice and remove any PII , anaylze text (call center conversation) with an LLM, postprocess the LLM's answers before updating them into the DB. Then run the all analysis workflow.
-
Key steps: Insert the calls data to the DB, perform speech diarization, transcribe, recognize PII, analysis. Then run the workflow.
-
Key files:
-
MLRun hub functions:
- View the data
- Notebook: call-center-demo.ipynb
- Description: View the data and features, as they are collected, in the MLRun UI. Deploy Vizro to visualize the data in the DB.