Latencies for Marti v0
This notebook is used to generate the graphs in my Substack post about my analysis of the prototype of Marti AI. All graphs were made with seaborn, using minimal customization. The data was generated by talking to a version of the Marti prototype with timing statements, accessible on in a separate GitHub branch.
Data generation
# generate data about the times for each part of the operation
# user times is the amount of time the user spends talking
# listen times is the amount of time the program spends in listening mode
# buffer times is the difference between user times and listen times, which is the amount of time that the program buffers to ensure that the user is done speaking
# recognize times is the amount of time that the program takes to turn the user's speech into text
# think times is the amount of time that the program takes to return the text output for the user
# generate times is the amount of time that the program takes to turn text into speech
# read times is the amount of time that the program takes to read the generated audio, not including time playing the audio
user_times = [3.53, 1.81, 5.24, 3.14, 3.53, 4.44, 3.49, 3.85, 1.48, 1.86, 2.64, 3.76, 1.86, 2.66, 4.49, 3.47, 3.81, 3.21, 4.50, 3.02, 3.06]
listen_times = [6.5022499561309814, 4.427386283874512, 4.326539993286133, 5.218196153640747, 5.100186109542847, 6.614777088165283, 5.056102275848389, 3.220916986465454, 3.147758960723877, 3.7746741771698, 3.650014877319336, 6.38067889213562, 4.603470087051392, 4.430200815200806, 5.703462839126587, 4.781328916549683, 5.39479398727417, 4.716341972351074, 5.652783155441284, 4.413949728012085, 4.455374240875244]
buffer_times = [listen_time - user_time for listen_time, user_time in zip(listen_times, user_times)]
recognize_times = [1.6909189224243164, 1.0840249061584473, 1.5180540084838867, 2.0668721199035645, 1.692863941192627, 2.8224809169769287, 2.4820170402526855, 1.0097508430480957, 1.0307588577270508, 1.2826569080352783, 1.457226037979126, 1.8728969097137451, 1.4664230346679688, 1.7909152507781982, 2.25940203666687, 2.1372830867767334, 2.610731601715088, 1.1604321002960205, 2.0273590087890625, 2.074542760848999, 1.619128942489624]
think_times = [2.1137890815734863, 1.4204962253570557, 1.5143821239471436, 2.2850210666656494, 1.4985020160675049, 1.5348238945007324, 2.040102005004883, 1.7425520420074463, 0.9219210147857666, 1.1603200435638428, 3.7914979457855225, 1.6758239269256592, 1.6205110549926758, 1.842151165008545, 1.8236520290374756, 2.3010358810424805, 1.7801809310913086, 1.4898388385772705, 2.7025678157806396, 1.1539373397827148, 1.0625710487365723]
generate_times = [0.956312894821167, 0.49080395698547363, 0.3302750587463379, 0.4471161365509033, 0.3730340003967285, 0.43520092964172363, 0.48029184341430664, 0.4222593307495117, 0.3813629150390625, 0.3173530101776123, 0.5469510555267334, 0.5209412574768066, 0.3671531677246094, 0.4146718978881836, 0.32427191734313965, 1.306190013885498, 0.6348428726196289, 0.7616047859191895, 0.47567319869995117, 0.3313148021697998, 0.35553503036499023]
read_times = [0.3130319118499756, 0.14511704444885254, 0.1421198844909668, 0.14771318435668945, 0.14586901664733887, 0.14693403244018555, 0.14595508575439453, 0.1464698314666748, 0.1440601348876953, 0.1438748836517334, 0.14755892753601074, 0.15033888816833496, 0.14429998397827148, 0.14671683311462402, 0.13856887817382812, 0.1457977294921875, 0.14838719367980957, 0.14347600936889648, 0.15015602111816406, 0.14775514602661133, 0.14155888557434082]
#convert the lists into a single pandas df
import pandas as pd
times_df = pd.DataFrame(
{'User Times': user_times,
'Buffer Times': buffer_times,
'Recognize Times': recognize_times,
'Think Times': think_times,
'Generate Times': generate_times,
'Read Times': read_times
})
All components
# visualize the latencies of all modules in a single graph of box plots
import seaborn as sns
import matplotlib.pyplot as plt
melted_times = pd.melt(times_df)
melted_times.set_axis(["Program Components", "Latencies"], axis = 1, inplace = True)
# The box plot
all_latencies = sns.boxplot(data = melted_times, x = "Program Components", y = "Latencies")
# Show the plot
sns.set(rc={'figure.figsize':(15, 10)})
all_latencies.get_figure();
Listen components
## visualize latencies of only the listening module in a single box plot
listen_melted_times = pd.melt(times_df[['User Times', 'Buffer Times', 'Recognize Times']])
listen_melted_times.set_axis(["Program Components", "Latencies"], axis = 1, inplace = True)
# The box plot
listen_latencies = sns.boxplot(data = listen_melted_times, x = "Program Components", y = "Latencies")
# Show the plot
sns.set(rc={'figure.figsize':(15, 10)})
listen_latencies.get_figure();
Think component
# visualize the latency of thinking with a KDE, with the mean plotted
sns.displot(times_df, x="Think Times", kind="kde", aspect = 2)
plt.axvline(x=times_df['Think Times'].mean(), color='red')
Speak components
#visualize the latency of the components of the speak module with violin plots
# visualize latencies of only the listening module in a single box plot
speak_melted_times = pd.melt(times_df[['Generate Times', 'Read Times']])
speak_melted_times.set_axis(["Program Components", "Latencies"], axis = 1, inplace = True)
# The box plot
speak_latencies = sns.violinplot(data = speak_melted_times, x = "Program Components", y = "Latencies")
# Show the plot
sns.set(rc={'figure.figsize':(15, 10)})
speak_latencies.get_figure();
Correlations
# generate a correlation matrix to test correlations between different latencies
corr = times_df.corr()
# Set up the matplotlib figure
f, ax = plt.subplots(figsize=(7, 9))
ax.xaxis.tick_top()
# Generate a custom diverging colormap
cmap = sns.diverging_palette(230, 20, as_cmap=True)
# Draw the heatmap with the mask and correct aspect ratio
sns.set_style(rc = {'figure.facecolor': '#1C1D1F'})
sns.heatmap(corr, cmap=cmap, vmax=.3, center=0,
square=True, linewidths=.5, cbar_kws={"shrink": .5}, annot = True)