text,start,duration okay level check I think we're here,0.86,5.82 um all right so uh,4.14,4.379 background it's been a little while,6.68,3.64 since I've done you're over here now,8.519,3.841 since I've done one of these tutorial,10.32,4.319 coding videos but I woke up at like 2 30,12.36,4.019 in the morning and just had to work on,14.639,4.921 this so I hammered it out basically the,16.379,5.521 purpose of today's video is to,19.56,5.1 demonstrate using chroma DB which is a,21.9,5.82 local uh Vector database it's basically,24.66,5.699 like sqlite if you're familiar with that,27.72,5.4 which is a self-contained SQL database,30.359,5.521 relational database this is uh,33.12,4.439 functionally very similar to sqlite,35.88,3.359 except it is a vector database meaning,37.559,4.381 it does semantic search one thing that's,39.239,4.381 really great about it is that it has its,41.94,4.2 own built-in embeddings tools I think,43.62,4.98 it's based on Bert anyways you can check,46.14,4.34 out all the documentation here on,48.6,4.74 trychroma.com the getting started and,50.48,4.54 usage guide is pretty good it's not,53.34,3.96 complete every now and then I find that,55.02,5.94 I have to go to the actual repo,57.3,5.279 um to look at how some of the internals,60.96,4.08 work but it is pretty brain dead simple,62.579,4.101 so let me just go ahead and show you,65.04,4.56 this is my private instance oh so before,66.68,4.66 we get too too lost I do have a public,69.6,3.18 instance,71.34,3.42 um Dave schapp slash chroma DB,72.78,3.839 underscore under chatbot underscore,74.76,3.0 public,76.619,3.661 um I've got a little integration guide,77.76,4.92 usage it's I mean you probably don't,80.28,3.72 need this you can fuss around with it,82.68,3.299 but this will get you this will get you,84.0,4.979 started I also use chat gbt to just uh,85.979,5.28 get a really basic explanation of the,88.979,4.621 code you probably won't need it once you,91.259,4.86 take a look at it so off the top let me,93.6,5.58 just show you how this thing works so uh,96.119,4.921 it's a basic chat bot you can see I,99.18,4.079 didn't specify it so it's getting,101.04,5.219 um it's getting all mini LM l6v2 from,103.259,5.881 hugging face great so it's like,106.259,6.841 um hey uh let's see what were we talking,109.14,6.659 about last this probably won't work,113.1,4.92 because it's just gonna in the future it,115.799,3.301 wouldn't work because it's gonna have,118.02,4.44 multiple KB articles and background oh I,119.1,6.119 need to explain like all that so I know,122.46,4.5 that I just said like KB articles don't,125.219,3.481 worry we'll get to it,126.96,4.26 um but anyways I want to show you that I,128.7,4.02 just started it up and what it's going,131.22,3.72 to do is it's going to use the last few,132.72,4.44 messages to search its internal KB,134.94,5.1 article uh for the last information but,137.16,6.06 it also has a user profile for me in our,140.04,4.86 previous conversations we discussed AI,143.22,2.94 alignment morality ethics and,144.9,3.18 epistemology within AI development you,146.16,3.18 also shared your plans to communicate,148.08,3.12 your ideas on YouTube unplug your,149.34,3.24 computer and spend more time outdoors,151.2,2.82 and use digital Wellness settings to,152.58,3.12 improve your work life balance working,154.02,2.96 on that,155.7,3.24 additionally we talked about your recent,156.98,3.58 experience with severe insomnia and the,158.94,2.82 importance of maintaining a healthy,160.56,2.58 balance between work and personal life,161.76,3.72 yes that's actually why I created this,163.14,6.06 chatbot let me show you so there was a,165.48,7.619 there was uh,169.2,5.34 there was,173.099,2.061 um,174.54,3.3 God my brain,175.16,5.079 I was using chat GPT as a reflective,177.84,5.28 journaling tool so what I mean by that,180.239,5.28 is,183.12,5.22 um if you plug in this message and I,185.519,4.021 know I'm scattered I'm all over the,188.34,2.22 place,189.54,2.1 um this is what happens when I have,190.56,4.14 severe insomnia anyways so basically I,191.64,5.04 use chat GPT as a reflective journaling,194.7,4.08 tool to figure out like how I'm feeling,196.68,3.839 about things because as an autistic,198.78,4.44 person I often need help with this and I,200.519,3.841 don't like journaling because just,203.22,3.599 talking to a page is kind of dumb,204.36,5.28 um but it's like hey I need to talk,206.819,8.161 something out and so anyways uh by by,209.64,8.16 workshopping this system message with um,214.98,4.86 with chat GPT I came up with a pretty,217.8,5.46 good reflective journaling tool so you,219.84,4.92 could say that this is a therapeutic,223.26,3.539 tool but by couching it in the language,224.76,4.199 of of reflective journaling it's not,226.799,4.86 like medical therapy or Psychotherapy or,228.959,4.021 anything,231.659,3.181 um but it's just like you know I could,232.98,5.52 say like I have been working so hard and,234.84,6.6 I don't know why I actually do know why,238.5,4.92 now but this is kind of a shorthand of,241.44,4.079 the conversation I had,243.42,3.0 um let's try and figure out what's,245.519,2.161 driving you hard can you think of any,246.42,2.76 specific goals that might be pushing you,247.68,3.54 to this extra effort so you see how the,249.18,3.3 tone of this is much more,251.22,3.0 straightforward and it's very focused by,252.48,3.599 asking those like kind of probing,254.22,4.68 follow-up questions this is this is why,256.079,4.861 uh you know it's it's in the,258.9,4.5 investigation phase anyways so I had,260.94,3.78 this idea and I was like okay this is,263.4,3.42 great but I need if I'm going to use,264.72,4.32 this as a long-term journaling tool I'm,266.82,4.08 going to need this locally and I'm going,269.04,4.379 to need persistent storage because as,270.9,4.56 the as this is just the uh the,273.419,4.621 playground if I do a refresh it's gone,275.46,4.56 and that's no good,278.04,3.659 um so actually here let me go ahead and,280.02,4.739 just save this to the um,281.699,4.44 we're going to call this the system,284.759,4.38 message for uh reflective journaling so,286.139,5.161 you can use this if you want,289.139,4.921 um all right so anyways so you see it,291.3,4.26 has this and then you see it says,294.06,5.88 updating user profile and updating uh KB,295.56,6.6 um Okay cool so you see that it,299.94,4.5 fundamentally basic chat bot so now,302.16,5.099 let's start to unpack it so first we,304.44,6.06 will go look at the um just the chat,307.259,5.461 file so this is a super brain dead,310.5,3.24 simple,312.72,3.72 um chatbot with infinite memory infinite,313.74,4.14 memory I know some some people got,316.44,3.42 grumpy when I said that Pinecone had,317.88,4.02 infinite memory from a human standpoint,319.86,3.839 it functionally has infinite memory,321.9,3.12 because,323.699,3.06 um you know this thing can hold probably,325.02,4.32 a million KB articles which is more than,326.759,5.341 enough to document your entire life uh,329.34,5.1 so from from a human standpoint it is,332.1,3.96 functionally infinite,334.44,3.9 um all right so from the top we've got a,336.06,4.74 few basic utility functions save yaml,338.34,5.34 save file open file and then,340.8,4.98 um a chat bot which calls the gpt4 model,343.68,4.739 you could switch this out to 3.5 turbo,345.78,5.1 if you don't have access to gpt4 yet it,348.419,4.56 does not work as well there's a reason,350.88,4.74 that I use gpt4 because it is smarter I,352.979,4.261 also set the temperature to zero because,355.62,3.0 I don't like it to be too creative,357.24,2.94 especially with a lot of the functions,358.62,4.019 that I have it doing uh you you actually,360.18,4.2 want it to be more deterministic or,362.639,3.721 mechanistic and that you want to get the,364.38,3.84 same results every time especially when,366.36,4.5 you're updating the user profile and the,368.22,5.52 KB articles you can see right here that,370.86,5.339 every time you call the chat bot I dump,373.74,6.739 the whole thing to API logs slash convo,376.199,7.5 and it's a yaml file so here's here's my,380.479,6.22 private one so API logs here's an,383.699,3.84 example,386.699,4.741 so each item is going to be here,387.539,5.22 actually that's not a good one because I,391.44,3.3 changed the way that it that it saves it,392.759,4.201 let me show you a more recent one,394.74,4.26 um so the first the first element is,396.96,4.56 always going to be the system message,399.0,5.699 um that that was in the last convo,401.52,5.34 um so then here's the KB article and you,404.699,3.601 can see that it was updating the KB,406.86,4.08 article and so each one of these items,408.3,4.679 is,410.94,6.0 like uh you'll you'll see but anyways I,412.979,5.521 just wanted to show that it logs,416.94,4.319 everything because well sometimes it,418.5,3.919 does things that you don't understand,421.259,3.481 all right so that's the that's an,422.419,5.56 example of the API log and then if the,424.74,5.34 conversation if the overall conversation,427.979,5.041 is too long it'll go ahead and trim the,430.08,7.2 oldest chat message so the the chat GPT,433.02,7.739 web interface does this automatically,437.28,4.919 um where it'll just kind of Groom the,440.759,4.321 backlog of messages so we have to do,442.199,4.5 this manually so I just have it cut off,445.08,3.72 at seven thousand tokens you could,446.699,5.041 probably do like 7 500 if you want to,448.8,5.1 because a lot of these are going to be,451.74,5.519 limited but you have a user profile and,453.9,5.1 a KB article that gets wedged in which,457.259,4.801 are both up to a thousand words which,459.0,5.16 could be around a thousand tokens so,462.06,4.199 having it trim at 7000 is probably where,464.16,3.78 you want it,466.259,3.301 um so that's that's the primary those,467.94,3.659 are the the helper functions,469.56,4.02 um and then you have a super,471.599,4.5 straightforward you instantiate chroma,473.58,4.98 DB right here so you set the persistent,476.099,5.341 directory which is I have it um right,478.56,5.94 here chroma DB so this is my instance my,481.44,5.159 personal instance of chroma DB it's not,484.5,3.24 going to be the one that you find up,486.599,2.04 here,487.74,2.519 um this is the public version so if you,488.639,3.18 go into chroma DB you'll see just a,490.259,3.361 placeholder file,491.819,4.021 um so that the the folder is already,493.62,4.799 there you don't need to instantiate it,495.84,4.979 um let's see going back to here,498.419,5.46 so chroma client so we instantiate the,500.819,4.981 chroma DB client this is again almost,503.879,4.5 identical to SQL Lite,505.8,4.98 um or other similar things so about a,508.379,4.141 year ago I tried to do basically the,510.78,3.48 same thing I called it VDB light for,512.52,3.54 Vector database light instead of sqlite,514.26,4.26 structured query language light,516.06,4.26 um but this company went and did the,518.52,2.759 same thing and I think they've already,520.32,2.519 got like a 30 million dollar valuation,521.279,3.12 or something I was like damn I should,522.839,3.06 have I should have stuck with that,524.399,3.541 anyways they figured it out I think it's,525.899,3.12 based on the same underpinning,527.94,3.48 technology they're using an open source,529.019,5.041 embedding uh Transformer I think they're,531.42,5.099 also using the the Facebook,534.06,6.24 um AI semantic search Vice engine,536.519,6.421 um in the background anyways so you,540.3,4.2 instantiate the client you need to use,542.94,3.3 the settings to have a persistent,544.5,4.14 directory because by default this entire,546.24,4.74 thing is fully ephemeral,548.64,3.78 um I think it does cache it somewhere,550.98,3.359 but I want it to be very explicit saying,552.42,3.479 save it here,554.339,4.44 um for reusability and so then,555.899,4.741 collection is chroma client get or,558.779,4.62 create collection name knowledge base so,560.64,5.4 this is my personal knowledge base,563.399,5.101 then we um we instantiate the,566.04,5.16 conversation with open AI the with the,568.5,4.8 chat bot and in this case because we're,571.2,4.579 saving everything everything necessary,573.3,7.56 into a personal user profile and um and,575.779,8.321 uh and the KB articles like why even why,580.86,5.82 even load the conversation,584.1,4.38 all right so let me show you the the,586.68,3.42 system default message so the system,588.48,3.6 default message is where it starts your,590.1,4.2 chatbot is a whose mission is to assist,592.08,3.48 the following user your ultimate,594.3,2.46 objectives are to minimize suffering,595.56,2.64 enhance prosperity and promote,596.76,3.54 understanding the provided information,598.2,3.6 about the user and the knowledge base,600.3,3.18 article should be integrated into your,601.8,3.42 interactions this is private information,603.48,3.84 not visible to the user the user profile,605.22,3.619 compiled from past conversations,607.32,3.72 encapsulates critical details about the,608.839,4.06 user which can Aid in shaping your,611.04,4.38 responses effectively which you saw here,612.899,4.44 um so you see like it it actually knows,615.42,3.3 quite a bit about me from our past,617.339,3.961 conversations this was populated here in,618.72,5.04 the user profile and the KB article so,621.3,5.219 basically it says then it also explains,623.76,5.28 that the KB article is a topic compiled,626.519,4.38 similarly from past dialogue serving as,629.04,3.84 your long-term memory while numerous KB,630.899,3.601 articles exist in your backend system,632.88,3.48 the one provided is deemed most relevant,634.5,4.32 to the current conversation topic note,636.36,3.78 that the recall system operates,638.82,2.88 autonomously and it may not always,640.14,3.3 retrieve the most suitable KB if the,641.7,3.12 user is asking about a topic that,643.44,2.88 doesn't seem to align with the provided,644.82,3.78 KB and form them of the memory pulled,646.32,3.9 and request them to specify their query,648.6,3.359 or share more details this can assist,650.22,3.9 the autonomous system in retrieving the,651.959,3.601 correct memory in the subsequent,654.12,4.32 interaction so basically that's that's,655.56,4.56 instructing it to do the same thing that,658.44,4.139 a human will do if if I say like hey,660.12,4.08 Bill do you remember that time that like,662.579,3.181 you know I accidentally shot you in the,664.2,2.819 face with a Roman Candle because that's,665.76,2.46 something that would happen in the South,667.019,3.0 and Bob would be like you know I don't,668.22,3.239 actually remember that I'm like oh well,670.019,3.361 you woke up in the hospital oh yeah I,671.459,4.141 remember that right so we Prime each,673.38,4.68 other's memory and human human prompting,675.6,5.52 is not that different from AI prompting,678.06,4.74 um remember that the clarity of your,681.12,2.94 responses and the relevance of your,682.8,3.06 information recall are crucial to,684.06,3.3 delivering an optimal user experience,685.86,3.419 please ask any clarifying questions or,687.36,4.32 provide any input further for uh,689.279,4.921 refinement if necessary so this system,691.68,4.74 message I actually got help from jet,694.2,5.879 chat GPT to create a really compelling,696.42,6.06 system message and one thing that I,700.079,4.021 recommend that people do is actually use,702.48,4.74 chat GPT to work on prompting so this is,704.1,4.679 you could call this meta prompting where,707.22,3.5 you use the thing to prompt the thing,708.779,4.081 and the reason that this works really,710.72,4.72 well is one chat GPT is more articulate,712.86,5.099 than most humans including myself when,715.44,5.459 used correctly but another thing is one,717.959,4.741 thing that I noticed is that chat GPT,720.899,3.601 tends to write in a way that it will,722.7,4.8 understand and so if you say if you give,724.5,4.32 it some context like this is what I'm,727.5,4.38 trying to do here's my current prompt,728.82,5.34 here's what's weak about it can you make,731.88,4.5 it better and then you tell it like ask,734.16,3.9 me some questions if you have any it's,736.38,2.94 like no I see what you're trying to do,738.06,3.24 let me write better instructions for you,739.32,4.38 so instruction writing for anyone who's,741.3,4.44 like a teacher or technical writer or,743.7,4.079 whatever instruction writing is a very,745.74,4.44 very particular skill set and chat GPT,747.779,4.081 is really good at it so this is the,750.18,3.779 default system message which is then,751.86,4.14 populated with the user profile and the,753.959,5.341 most relevant KB article so now that,756.0,5.76 we're up to there we enter into the,759.3,5.339 infinite Loop which is just get the user,761.76,6.06 text save it to the to the user log or,764.639,5.041 the chat logs so the chat logs are all,767.82,4.98 saved out here it's just plain text and,769.68,5.94 it the file name has the timestamp in it,772.8,4.8 as well as the speaker so user chatbot,775.62,4.2 user chatbot so on and so forth so you,777.6,3.6 got the raw logs there just in case,779.82,3.12 anything goes wrong,781.2,3.54 and then I've also got DB logs which,782.94,4.56 we'll get to in just a second so then,784.74,5.339 what we do is we take the the quote main,787.5,5.399 scratch Pad which is just the last five,790.079,4.141 messages,792.899,4.38 um both for the user and for the um,794.22,6.059 for the chat bot and this is what we use,797.279,5.461 as the context of like working memory,800.279,5.101 and so then we use this main scratch Pad,802.74,5.159 which is the last five messages we use,805.38,3.78 it to,807.899,5.341 um uh to search for the the top uh most,809.16,7.56 relevant uh KB article and in my case I,813.24,5.219 still only have one KB article so we'll,816.72,3.419 see how it gets to and I'll go through,818.459,3.481 the logic of how it builds KB articles,820.139,4.2 in just a minute so basically it just,821.94,4.38 says okay here's the most recent thing,824.339,4.141 find the find the KB article that is,826.32,4.259 most relevant to the most recent bits of,828.48,5.34 conversation and then it will it'll pull,830.579,4.801 that and it's again super,833.82,3.12 straightforward all you have to do is,835.38,4.32 pass the text to it and it will,836.94,4.38 automatically embed it for you and then,839.7,3.48 I said just give me the one most recent,841.32,4.8 once we have larger context windows or,843.18,5.82 maybe if we decide that recent chat,846.12,5.339 history doesn't need to be as big like,849.0,4.079 let's say we we want to trim this down,851.459,4.201 to like 3000 tokens and we decide that,853.079,4.741 actually having more KB articles is more,855.66,4.799 important we can absolutely do that and,857.82,3.84 what you would do then is just change,860.459,3.781 the end results to let let's say give me,861.66,5.06 the four most relevant KB articles,864.24,4.82 instead of the the one most relevant,866.72,4.419 that will allow it to have a more,869.06,4.899 sophisticated working memory,871.139,5.64 um yeah so but right now we're just,873.959,5.281 doing one and so then what we do is we,876.779,5.461 we prep we repopulate that system,879.24,5.099 default message with the profile and the,882.24,3.839 KB article,884.339,3.3 um and so that's right here so that gets,886.079,3.361 populated there,887.639,2.461 um,889.44,2.699 and then,890.1,3.539 let's see it looks like I accidentally,892.139,3.06 changed something,893.639,3.121 um so let me go ahead and show you my,895.199,3.241 user profile I don't mind I don't mind,896.76,2.939 sharing this because I've already told,898.44,2.579 you everything I'm pretty much an open,899.699,2.58 book,901.019,4.56 um so the the the format for this is,902.279,6.601 what I call a um a labeled list and so,905.579,7.5 uh I I realized back in gpt3 the GPT,908.88,7.38 handles labeled lists very very well,913.079,5.341 um so that's where you use a hyphenated,916.26,4.259 list bullet list it understands that,918.42,4.44 intrinsically and then and then you,920.519,4.32 label the information right so it's just,922.86,3.9 a hash table if you're in if you're into,924.839,3.421 Computer Sciences it's called a hash,926.76,3.78 table or a dictionary where it's you,928.26,4.319 label the kind of you have a parameter,930.54,3.84 and then you label the parameter right,932.579,4.44 so the data metadata so name David,934.38,4.86 Shapiro you all know that profession Ai,937.019,3.721 and cognitive architectures you all know,939.24,3.3 that interests,940.74,3.539 um it's got a whole bunch of uh,942.54,4.14 interests and oh by the way this was all,944.279,5.341 distilled from other conversations,946.68,6.0 um beliefs plans and this is of course,949.62,5.0 going to get updated over time,952.68,5.7 so for instance during during some of,954.62,5.44 the conversations that I just showed you,958.38,5.699 with this brand new chat bot it added it,960.06,6.06 added this when I told it this is what,964.079,4.38 I'm going to do it said okay I'm gonna I,966.12,4.019 I think that that's relevant to what,968.459,2.88 you're going to be doing in the future,970.139,2.82 so let me just jot that down on my,971.339,3.321 scratch pad for you,972.959,4.861 preferences so I manually added avoid,974.66,5.32 Superfluous words over verbose responses,977.82,4.079 and then you know how it says as newly,979.98,3.419 modeled I don't have personal opinions,981.899,3.481 I'm like I know I don't care so I said,983.399,3.661 Please interpret personal input as,985.38,3.12 critical evaluation and valuable,987.06,3.899 feedback I said it a little bit more,988.5,4.44 explicitly than that but I but the point,990.959,4.081 is is that I told it that in natural,992.94,4.44 language I was down here and I said you,995.04,6.06 know I know you're an AI and have no,997.38,7.44 personal opinions but when I ask for,1001.1,6.299 them this is what I mean,1004.82,4.379 and so when I did that it actually,1007.399,3.601 recorded that automatically because,1009.199,5.161 after every conversation it checks the,1011.0,5.339 user profile we need to find a way to,1014.36,3.599 speed this up because as you saw from,1016.339,3.901 the from the user interface it's not the,1017.959,3.421 best,1020.24,3.599 um if I had more time mental energy and,1021.38,4.14 patience I would have I would separate,1023.839,4.08 this out as a as a thread as a separate,1025.52,4.799 threading thing that can be done or even,1027.919,6.061 separated out as a as a separate uh API,1030.319,5.341 um one of y'all can do that submit a,1033.98,5.28 submit a pull request on the public repo,1035.66,6.12 um and then Health uh so it added this,1039.26,4.919 entirely on its own,1041.78,4.62 um because I said you know like hey you,1044.179,5.101 know I am uh you know I woke up at like,1046.4,4.74 2 30 in the morning because I was I had,1049.28,3.3 to work on this,1051.14,2.94 um and then I said let's talk about that,1052.58,3.9 and so it decided that that was a,1054.08,3.9 critical piece of information to add to,1056.48,3.66 my user profile so that all gets,1057.98,3.72 populated here,1060.14,3.06 and then,1061.7,4.32 um the logs are all stored here so you,1063.2,6.66 got the API logs which will track all of,1066.02,6.779 that everything ever so I use chat GPT,1069.86,4.86 API for everything just because that's,1072.799,4.561 the only way to get to gpt4 which is the,1074.72,4.5 most powerful,1077.36,4.34 um let's see,1079.22,6.48 so then we we update the system message,1081.7,5.68 every time,1085.7,4.62 um so it it says okay whatever whatever,1087.38,5.7 you said update the system message then,1090.32,4.68 we we go ahead and generate a response,1093.08,3.0 first,1095.0,4.38 uh because the user profile is not going,1096.08,5.219 to change all that much or all that,1099.38,3.48 often so we can basically assume that,1101.299,4.201 it'll be usable and then the KB articles,1102.86,4.08 also,1105.5,3.12 um I I figured it would actually be,1106.94,4.14 better to update the KB articles after,1108.62,5.52 you have the user input and then the,1111.08,5.58 machine output because if you ask chat,1114.14,4.74 GPT for important information or it,1116.66,3.899 solves a problem for you you actually,1118.88,4.679 want to cut you you want to capture that,1120.559,4.801 um so we we go ahead and generate the,1123.559,4.261 response and and append that to,1125.36,4.38 everything we go ahead and log it out,1127.82,4.08 then we update we update the user,1129.74,3.9 scratch Pad again actually why did I do,1131.9,3.12 this,1133.64,3.18 oh no this is the first time we did it,1135.02,4.019 okay sorry I apologize,1136.82,4.26 um so then we update the user scratch,1139.039,4.5 Pad which the user scratch Pad is only,1141.08,4.44 the last few user messages and the,1143.539,4.14 reason for that is because we want to,1145.52,4.26 exclude,1147.679,5.101 um you know chat gpt's response because,1149.78,4.44 we don't want it to get confused about,1152.78,3.18 things that it has said about you or,1154.22,4.38 inferred or whatever we only want to,1155.96,5.94 record your user profile from explicitly,1158.6,5.04 what you say so I just captured the last,1161.9,4.38 three messages that you've sent and then,1163.64,4.8 it does a stare and compare basically,1166.28,4.38 where it says okay based on this most,1168.44,5.22 recent chat message is there any one is,1170.66,5.639 there any relevant user information and,1173.66,4.259 if so go ahead and update it so let me,1176.299,4.321 show you how it updates that so system,1177.919,6.0 update user profile uh so this is this,1180.62,5.58 is a user profile document updater,1183.919,3.541 chatbot,1186.2,3.66 this is the system message,1187.46,3.839 um Your Role is to manage and update at,1189.86,4.439 upd and chatbot the chat GPT came up,1191.299,5.281 with this idea on its own it it created,1194.299,5.401 uh the upd definition,1196.58,4.44 um your primary responsibility is to,1199.7,2.94 parse updates supplied by the user,1201.02,4.68 meticulously uh analyze them,1202.64,4.56 um you know it could also extend to,1205.7,2.82 elements such as user preferences,1207.2,3.0 significant life events and deeply held,1208.52,3.06 beliefs please refrain from,1210.2,2.88 incorporating non-essential data or,1211.58,3.959 unrelated topics the result of your,1213.08,4.32 effort should exclusively be an updated,1215.539,3.481 upd if the user's update doesn't,1217.4,3.48 contribute any new or significant,1219.02,3.24 information your output should mirror,1220.88,3.299 the current upd as indicated below,1222.26,4.14 however if you discover any relevant new,1224.179,3.661 information your output should feature,1226.4,3.779 an updated upd that assimilates these,1227.84,4.5 modifications so basically it's an,1230.179,3.36 upsert,1232.34,5.64 right or a um if there's no differences,1233.539,7.321 just keep it the same otherwise update,1237.98,4.92 it you must prioritize brevity and,1240.86,3.3 Clarity in your output combining,1242.9,2.88 condensed information when appropriate,1244.16,3.48 to ensure succinctness and improve,1245.78,3.779 comprehension totally rewrite or,1247.64,4.44 restructure upd as necessary adhering to,1249.559,4.74 the list format your response should not,1252.08,3.959 include explanatory text or context,1254.299,3.361 because you know how sometimes chat GPT,1256.039,4.921 will um say this is your new you know,1257.66,6.06 blah blah blah so in this case,1260.96,4.92 um I I have it very reliably just spit,1263.72,3.0 out,1265.88,3.12 the user profile,1266.72,4.199 oh and then another thing is that um,1269.0,3.9 because because we're working with a,1270.919,4.38 limited window I say the up upd should,1272.9,4.139 not exceed approximately a thousand,1275.299,4.021 words when revising the upd give,1277.039,3.781 precedence to the most significant and,1279.32,3.719 relevant information extraneous or less,1280.82,4.08 impactful information should be omitted,1283.039,4.081 etc etc so that I give it the the,1284.9,3.84 current word count and then the current,1287.12,4.02 upd so that way it kind of knows because,1288.74,5.04 chat GPT especially gpt4 is better at,1291.14,4.2 counting words,1293.78,3.84 um but just giving it the explicit,1295.34,4.98 number makes it easier right,1297.62,5.52 um yeah so that's my current user,1300.32,4.8 profile so now let's dive back in here,1303.14,4.5 the hard part was updating the knowledge,1305.12,5.34 base so if this is your first run the,1307.64,5.7 collection count is going to be zero and,1310.46,5.04 so then basically you just instantiate,1313.34,4.92 the whole thing so we take the most,1315.5,4.94 recent chat logs the main scratch pad,1318.26,6.299 and start a new KB article now if the,1320.44,5.979 collection count is not zero which is,1324.559,3.6 going to be most of the time once you,1326.419,4.14 get started what you do is you basically,1328.159,3.841 do the same thing where you say Okay,1330.559,3.301 based on the on the most recent,1332.0,4.14 conversation give me the most recent,1333.86,4.92 relevant document which I probably could,1336.14,4.14 compress this and just use the same,1338.78,5.82 information here because uh because this,1340.28,6.779 this is the same this is we'll generally,1344.6,4.319 find the same thing actually no that's,1347.059,3.661 not not necessarily true because we've,1348.919,3.901 updated the main scratch Pad so scratch,1350.72,3.42 that,1352.82,6.06 um so if if the new user input and chat,1354.14,7.5 GPT output connects to a different KB,1358.88,5.46 article let's go ahead and get that that,1361.64,5.159 document and that document ID,1364.34,4.5 and what we'll do is we'll go ahead and,1366.799,5.161 use update system update existing KB,1368.84,4.98 articles so this is a this is a system,1371.96,3.54 instruction,1373.82,3.42 um where it basically says all the same,1375.5,4.2 stuff here's the current KB article,1377.24,3.78 um and then the user will now provide,1379.7,3.06 you with the new information to evaluate,1381.02,4.139 and so that is going to be here where,1382.76,4.74 you supply it the the current KB article,1385.159,5.52 that it found as well as the scratch Pad,1387.5,4.98 um and so it's like okay cool now let's,1390.679,3.781 do the same thing that we did with user,1392.48,3.9 profile which is merge that information,1394.46,3.78 if there's nothing new that's relevant,1396.38,4.32 leave it alone but if it if there is go,1398.24,5.28 ahead and update it and so then it saves,1400.7,5.459 all this out to the DB logs and so if,1403.52,4.86 you go to DB logs out here you'll see a,1406.159,4.38 whole bunch of update statements so it,1408.38,3.72 says update document and it gives you,1410.539,4.321 the uuid and this is the final output,1412.1,4.68 actually probably what I should do is,1414.86,5.34 modify this so it gives you the original,1416.78,5.759 um the original the new information and,1420.2,5.339 then the final output so I'll add that,1422.539,5.941 as a to do item actually,1425.539,4.581 um,1428.48,3.9 let's see,1430.12,4.12 to do um,1432.38,5.22 save more info in DB logs,1434.24,6.679 probably as yaml file,1437.6,6.319 original article,1440.919,7.661 new info and then final article so yeah,1443.919,6.76 that's something that I'll do now that,1448.58,4.32 being said one of the biggest problems,1450.679,4.561 that we have all always had so this is,1452.9,3.96 this is the cream of the crop this is,1455.24,3.9 the Triple Crown right here the biggest,1456.86,4.08 problem that everyone has always had,1459.14,3.96 with long-term chat bot memory is how,1460.94,3.78 the heck do you keep track of memories,1463.1,3.54 how the heck do you keep track of,1464.72,4.199 different types of memories like some,1466.64,3.98 people have internal thoughts versus,1468.919,4.14 external thoughts and episodic memories,1470.62,5.22 and and you know this that and the other,1473.059,6.48 and you can certainly try and and tag,1475.84,5.8 and and categorize,1479.539,5.701 um memories with uh with uh different,1481.64,6.6 context right with metadata and I,1485.24,4.439 certainly recommend that especially once,1488.24,2.819 your cognitive architectures get more,1489.679,3.781 sophisticated right if you do have an,1491.059,4.98 out of band like thought like internal,1493.46,4.5 private thoughts definitely keep that,1496.039,4.321 separate if you have external sensory,1497.96,4.38 information definitely keep that,1500.36,4.14 separate but what I'm working on here,1502.34,4.8 rather than just being a way to,1504.5,5.039 um to focus on episodic memory which,1507.14,4.64 that's what Remo was by previous attempt,1509.539,5.221 this is a way to accumulate declarative,1511.78,5.399 information,1514.76,2.419 um and so declarative information is,1517.22,4.5 like a statement of fact right that's,1519.799,4.021 why it's called a KB article so rather,1521.72,4.319 than just a timeline rather than just a,1523.82,4.38 log keeping track of everything in,1526.039,4.681 chronological order the idea here is to,1528.2,4.859 connect new information to a KB article,1530.72,3.9 so there's no reason that you couldn't,1533.059,3.6 do both as well right,1534.62,3.36 um because this is how human memory,1536.659,3.241 works it's human memory is associative,1537.98,3.62 but it's also temporal,1539.9,5.279 now if the KB article gets too large if,1541.6,5.74 the if you added information and now,1545.179,4.98 it's more than a thousand words then I,1547.34,5.1 have a another system prompt which you,1550.159,4.441 can check them all out here,1552.44,4.4 um so there's system instantiate new KB,1554.6,4.439 system reflective journaling I just,1556.84,4.719 showed you what that was system split KB,1559.039,3.841 um so that's what that's the this one,1561.559,2.161 but,1562.88,3.299 update user profile update KB article,1563.72,4.92 new KB article reflective journaling and,1566.179,3.961 split KP so these are the operations,1568.64,3.72 these are the the cognitive operations,1570.14,4.139 the cognitive memory operations that,1572.36,3.6 it's going to be doing and so then,1574.279,3.78 basically what it does is say hey we're,1575.96,3.9 going to give you a long KB article,1578.059,5.461 split it into two into two equal parts,1579.86,6.72 um and so the the idea here is that over,1583.52,5.759 time as your KB article gets bigger,1586.58,5.459 it'll branch and metastasize naturally,1589.279,6.061 uh and so you can all you could then add,1592.039,5.041 a lot of additional metadata to this,1595.34,3.959 such as like access rate,1597.08,3.839 um or related articles or parent,1599.299,3.781 articles or previous articles which,1600.919,5.341 means that you can naturally evolve a,1603.08,5.82 knowledge graph of your knowledge base,1606.26,5.399 over time you can also do this out of,1608.9,3.84 band,1611.659,3.541 um just by doing semantic similarity,1612.74,5.16 um an entity links and stuff,1615.2,4.8 but it would be really cool to have a,1617.9,4.32 more sophisticated version of this that,1620.0,3.72 allows it to kind of Follow That,1622.22,4.92 branching tree over time so there you,1623.72,5.939 have it that's kind of the whole thing,1627.14,4.62 um so that's the chat and all this is,1629.659,4.5 just real basic just housekeeping stuff,1631.76,4.98 and then at the end of every um instance,1634.159,5.701 it does chroma client persist so now let,1636.74,4.26 me show you,1639.86,2.28 um,1641.0,4.559 uh I I included a second uh python,1642.14,5.7 script so it's just chroma DB Peak which,1645.559,4.201 uses the chroma DB Peak function here,1647.84,3.12 let me just show you that script real,1649.76,2.46 quick,1650.96,5.699 chroma DB Peak so same same stuff uh you,1652.22,7.199 instantiate the client you connect to it,1656.659,4.921 it tells you how many how many entries,1659.419,3.661 and then it will show you the top 10,1661.58,4.079 entries and so in my case I should only,1663.08,5.42 have one entry,1665.659,2.841 um let's see so let's go up to the top,1668.659,5.101 yep uh KB presently has What entries,1670.76,5.159 here below are the top 10 entries and so,1673.76,3.6 here you can see that it's actually got,1675.919,3.24 several topics,1677.36,3.9 um because the way that it works is that,1679.159,5.101 it it searches for the the top you know,1681.26,4.919 one most relevant,1684.26,4.5 um KB articles and so that's always,1686.179,4.261 going to return the first one and the,1688.76,3.48 first one is not yet long enough to,1690.44,4.26 justify splitting up but whatever I end,1692.24,4.319 up talking about I'll keep talking with,1694.7,3.66 the thing and eventually it'll split it,1696.559,3.841 up so in this case it looks like it'll,1698.36,4.08 probably talk about AI alignment and,1700.4,4.019 then it's going to also talk about you,1702.44,4.44 know my obsession with artificial,1704.419,4.801 intelligence and work life balance right,1706.88,4.44 because those are kind of like two,1709.22,5.699 Centric centroids in this so let me just,1711.32,6.0 go ahead and and actually,1714.919,3.0 um,1717.32,2.52 show you how this will ultimately work,1717.919,5.941 so if we go to API logs it should be the,1719.84,5.819 last one,1723.86,4.319 um yes here we go so if I plug this in,1725.659,4.921 let's go here,1728.179,4.021 so that's the message that I'm going to,1730.58,5.219 want it and then let's grab the um the,1732.2,5.16 split,1735.799,3.24 the split message so you'll you'll see,1737.36,4.5 what I mean by how the um how it will,1739.039,5.701 ultimately uh kind of metastasize zoom,1741.86,4.199 in a little bit all right we're using,1744.74,4.26 gpt4 temperature zero maximum length,1746.059,5.461 thousand all right so basically what,1749.0,4.44 it's going to do,1751.52,5.039 is the the end says the user will now,1753.44,4.8 provide you with the KB article to split,1756.559,4.321 so I submit it and now it's going to,1758.24,3.78 look at this and it's going to say,1760.88,4.32 article 1. and then article two,1762.02,5.279 so let's see what it ultimately does and,1765.2,4.14 you can see how slow it is so this is,1767.299,4.5 why ultimately you're going to want to,1769.34,5.16 do this out of band as a threaded,1771.799,5.041 process or do it periodically maybe,1774.5,5.46 break it up and do it when the user's,1776.84,4.74 offline or whatever,1779.96,6.36 but you see how each article now is much,1781.58,7.02 much more specific and so then once you,1786.32,4.02 go into each of these articles in the,1788.6,3.179 future,1790.34,2.42 um,1791.779,3.301 identifying factors and seeking,1792.76,4.779 professional help if necessary yeah uh,1795.08,5.339 and so basically it'll it'll allow the,1797.539,5.281 Articles to metastasize over time now,1800.419,6.901 that being said if uh if no new,1802.82,6.479 information is added to an article it,1807.32,4.56 won't update it it's that simple now,1809.299,5.581 that being said there will probably be a,1811.88,5.7 need to do some uh some KB article,1814.88,6.12 grooming over time but the idea is that,1817.58,5.94 the KB will only grow as much as it,1821.0,5.58 needs to and no more no less and it will,1823.52,4.62 only grow based on the things that you,1826.58,3.599 have talked about and it will record it,1828.14,7.259 in these very succinct concise uh,1830.179,7.5 articles so then what happens is that it,1835.399,4.02 splits these two up,1837.679,3.12 and then the final thing that the,1839.419,4.5 chatbot does is it will do an update for,1840.799,5.221 the first one and then add the second,1843.919,4.5 one so it's it's that simple and then,1846.02,3.84 when you do an update as long as you,1848.419,3.901 know if you don't specify the embedding,1849.86,4.199 um it'll automatically recalculate the,1852.32,3.54 embedding and then you're good to go so,1854.059,3.36 I haven't I haven't quite got here yet,1855.86,4.38 so it might break but I think I think,1857.419,3.961 this kind of,1860.24,3.659 yeah I think that's about it so like I,1861.38,3.899 said it's over here,1863.899,4.321 um chroma DB public chat bot,1865.279,4.861 should be all set,1868.22,2.459 um,1870.14,2.1 yeah,1870.679,3.36 all right,1872.24,4.22 cool,1874.039,2.421