3.2.1. Load transcripts
For the purposes of this cookbook, we have selected the "Earnings Calls Dataset" (jlh-ibm/earnings_call) which is made available under the Creative Commons Zero v1.0 license. This dataset contains a collection of 188 earnings call transcripts originating in the period 2016-2020 in relation to the NASDAQ stock market. We believe this dataset is a good choice for this cookbook as extracting information from - and subsequently querying information from - earnings call transcripts is a common problem in many financial institutions around the world.
Moreover, the often variable character of statements and topics from the same company across multiple earnings calls provides a useful vector through which to demonstrate the temporal knowledge graph concept.
Despite this dataset's focus on the financial world, we build up the Temporal Agent in a general structure, so it will be quick to adapt to similar problems in other industries such as pharmaceuticals, law, automotive, and more.
For the purposes of this cookbook we are limiting the processing to two companies - AMD and Nvidia - though in practice this pipeline can easily be scaled to any company.
Let’s start by loading the dataset from HuggingFace.
from datasets import load_dataset
hf_dataset_name = "jlh-ibm/earnings_call"
subset_options = ["stock_prices", "transcript-sentiment", "transcripts"]
hf_dataset = load_dataset(hf_dataset_name, subset_options[2])
my_dataset = hf_dataset["train"]my_datasetDataset({
features: ['company', 'date', 'transcript'],
num_rows: 150
})row = my_dataset[0]
row["company"], row["date"], row["transcript"][:200]from collections import Counter
company_counts = Counter(my_dataset["company"])
company_countsDatabase Set-up
Before we get to processing this data, let’s set up our database.
For convenience within a notebook format, we've chosen SQLite as our database for this implementation. In the "Prototype to Production" section and Appendix section A.1, "Storing and Retrieving High-Volume Graph Data", we discuss considerations for different dataset choices in a production environment.
If you are running this cookbook locally, you may choose to set memory = False to save the database to storage. The default file path, my_database.db, will be used, or you may pass your own db_path argument to make_connection.
We will set up several tables to store the following information:
- Transcripts
- Chunks
- Temporal Events
- Triplets
- Entities (including canonical mappings)
This code is abstracted behind a make_connection method which creates the new SQLite database. The details of this method can be found in the db_interface.py script in the GitHub repository for this cookbook.
from db_interface import make_connection
sqlite_conn = make_connection(memory=False, refresh=True)