Why Agentic Systems Need Ontologies — Frank Coyle, UC Berkeley

AI Engineer · 21 min · 276 sentences · from YouTube's caption track

Each timecode opens YouTube at the start of that sentence. Line anchors (#s42) are the cue ids in the WebVTT, and every line carries its start and end seconds. All transcripts has every talk, and the whole corpus as one file.

  1. 00:01[music]
  2. 00:12Um, okay, we're going to launch here.
  3. 00:15So, my name is Frank Coyle.
  4. 00:17Um, I'm I'm an educator and teaching at Berkeley now.
  5. 00:21I've been doing this computer science stuff for oh, 30, 35 years.
  6. 00:26And um
  7. 00:28[snorts]
  8. 00:28I'm intro and right now it's kind of a critical time for uh poor computer science students.
  9. 00:34Used to be the used to be the only game in town.
  10. 00:36Degree was a guaranteed job, and now thanks to AI, it's not.
  11. 00:40But then again, 5,000 people are here.
  12. 00:43So, AI and and agents are um seem to be the way to go.
  13. 00:48So, the question is how do we leverage this new universe that we are moving quickly into.
  14. 00:54And so, I want to talk about how agents and ontologies will big word fit together.
  15. 01:00But before you do before I do that, I wanted to um wanted to give you my uh my educational philosophy.
  16. 01:09And this comes [clears throat] from uh someone called Sister Corita Kent.
  17. 01:13And it was made popular by John Cage, who is a uh an avant-garde musician.
  18. 01:19And you got to think about this little bit.
  19. 01:23Nothing is a mistake.
  20. 01:25There is no win.
  21. 01:26There's no fail.
  22. 01:28There's only make.
  23. 01:30And more and more today, that's what's important.
  24. 01:33Get down and make stuff, and that's how you're going to learn, not by necessarily reading.
  25. 01:38I'm also a big fan of writing.
  26. 01:41My early career was in neuroscience.
  27. 01:43I'm kind of coming back into it now that Agent AI is bringing uh kind of cognitive science back.
  28. 01:50But engage your senses.
  29. 01:53Get a notebook.
  30. 01:54Get a pen, a pencil.
  31. 01:56Draw pictures, write stuff down.
  32. 02:00Just don't type because when you type you when you're typing your brain is thinking about the letters on the keyboard.
  33. 02:06When you're writing in a book, your whole brain, your your whole all your all your sensory systems are engaged and you're going to learn faster that way.
  34. 02:16Okay.
  35. 02:18On to our talk.
  36. 02:21Agents and ontology.
  37. 02:22So, there are two lineages here and I want to talk about both, give you a little philosophical background.
  38. 02:27Um agents, when did we start talking about agents?
  39. 02:32Well, goes goes back to the early initial days of AI.
  40. 02:36People like John McCarthy, uh uh uh uh uh Selfridge, Marvin Minsky, Society of Mind.
  41. 02:43People started thinking about the fact that this new computing technology was going to lead us into some kind of artificial intelligence, which is a term that came in 1956
  42. 02:55when all these characters got together and tried to figure out where the future was going.
  43. 03:00Okay?
  44. 03:01And the concept of an agent finally evolved, things that perceive and decide and then act and that's what we're seeing now.
  45. 03:09Now, what about ontologies?
  46. 03:10Well, it turns out ontologies are not that new.
  47. 03:13Okay?
  48. 03:14It was actually Aristotle who first came up with the concept of we need a philosophy of of being.
  49. 03:22Like, whoa, kind of heavy.
  50. 03:23Um but came up with categories of being and this kind of relates to what people are doing now with graph databases and knowledge representation.
  51. 03:33And there are a couple of other people who kind of formalized it.
  52. 03:36Uh Von Quine was a philosopher and then this guy Gruber, 1993.
  53. 03:42And I think this captures what knowledge and uh graph technology really represents.
  54. 03:51It is a a formal specification of a shared conceptualization.
  55. 03:56And that's what we want to give to our agents.
  56. 03:59We want to give them our concept our conceptualization of the universe, our universe, our domains.
  57. 04:05Okay?
  58. 04:06And now, what's happening is you're getting the convergence of something that is probabilistic, the agents, the LLMs, with the the more formal representations that you have with ontologies.
  59. 04:22And so, this term is now being used you hearing this a lot, neuro-symbolic AI.
  60. 04:29Sounds pretty fancy, but it's really neural networks tied into symbolic AI, which rule-based systems come under that category, um as do the knowledge graphs that we're that we're assembling.
  61. 04:46And so, what I'd like to argue is that neuro-symbolic AI sort of represents a way to keep the LLM on its guardrails, because LLMs are by nature probabilistic.
  62. 05:02People worry about hallucinations, but that's the feature.
  63. 05:06That's actually a feature of large language models.
  64. 05:09It's who we are.
  65. 05:11We hallucinate in a way.
  66. 05:12We imagine things that may not exist, and then we turn them into reality.
  67. 05:17And that's what large language models do in in a way.
  68. 05:20Okay?
  69. 05:21So, let's just quickly overview what ontologies are.
  70. 05:27It's not They're not complicated.
  71. 05:28They're basically a representation of entities and their relationships to other entities.
  72. 05:35And these entities have properties.
  73. 05:38And this whole concept of graph databases arose when people began to realize that relational databases sticking data into tables was too restrictive.
  74. 05:53You wanted to add something new to a relational database, so you have to add a new column.
  75. 05:59Man, I had then then you have to redo the whole structure.
  76. 06:02With a with a graph database, you can just attach another item.
  77. 06:05You can just attach a property.
  78. 06:07You can attach a relationship.
  79. 06:09Okay?
  80. 06:09So, the question often arises, okay, I I get it.
  81. 06:12I need to have an ontology to represent in a formal way what my organization is doing.
  82. 06:19How do I do it?
  83. 06:21Okay?
  84. 06:21There are a couple of ways you can approach it.
  85. 06:23You can have a top-down approach or a bottom-up approach.
  86. 06:26Top-down approach is you get the experts together and they sit down and analyze the domain, come up with the entities.
  87. 06:35What do we have?
  88. 06:35We have purchase orders, we have customers, we have customer representatives, and we're going to structure them.
  89. 06:42They have properties.
  90. 06:43These are the relationships.
  91. 06:44Okay, that's one way.
  92. 06:46And this models what we were doing back in the '80s when I was involved in expert systems.
  93. 06:51Everybody thought expert systems was the way to do AI.
  94. 06:54Symbolic AI was the way to go.
  95. 06:57Companies rose, millions of dollars were spent.
  96. 07:01Uh the the Japanese created this uh future world project in the late '80s.
  97. 07:09People in America were my my son was taking Japanese in school because of these expert systems.
  98. 07:16And but they couldn't scale.
  99. 07:19They couldn't scale, and then we went into a kind of AI winter.
  100. 07:23Where did neural networks came come from?
  101. 07:25Neural networks were put out there in the '60s, but they couldn't scale because we didn't happen to have Nvidia who was off making GPUs to make make reality of the of the video games fantastic,
  102. 07:41and then someone said, let's turn these things over to the neural networks, and of course, that's kind of why we're here now.
  103. 07:47So, the other way you can that that people are adding to or creating ontologies is is from the bottom up.
  104. 07:56For example, customer reactions.
  105. 08:01What are the things the customers are involved in?
  106. 08:03Wait.
  107. 08:04Do you these entities, these relationships, let's add this to our ontology.
  108. 08:08Let's Let's add this information to the graph.
  109. 08:11Now, as as a help, it's helpful to be aware that there are existing taxonomies that people have been working on for the last 15 to 20 years.
  110. 08:22Things like schema.org, which has a whole set of terms and relationships, so you don't have to reinvent the wheel.
  111. 08:29In fact, you it's to your advantage to use some of these ontologies.
  112. 08:34FOAF, Friend of a Friend, for modeling social networks.
  113. 08:40The Dublin Core, which was an early an early attempt to come up with terms for describing uh research papers and books and so forth.
  114. 08:50So, there's a whole series of things.
  115. 08:52In fact, Wikipedia is based on an ontology called DBpedia.
  116. 08:57So, when you do a search on Wikipedia, it's looking things up in its giant graph database.
  117. 09:02So, this stuff has been out there underlying a lot of what we already do.
  118. 09:07So, take advantage of these things that already exist.
  119. 09:12Okay.
  120. 09:13Now, what do you do when you build your ontology?
  121. 09:15Okay, so what?
  122. 09:17I know what these entities are, I know what their relationships are, they have properties.
  123. 09:22How can I do anything with them?
  124. 09:24Well, there are other augmenting technologies, auxiliary technologies.
  125. 09:29Things that we call the things like RDFS, which is a technology, and OWL, which I'll talk more about.
  126. 09:35So, these have these kind of sit over to the side of your graph.
  127. 09:40So, I'm not going to talk about on I mean ontology is a big word and it's often confusing and used in many ways, but think of it as a graph data structure.
  128. 09:48Okay?
  129. 09:50And you have the entities and relationships, but you want to apply some control over them.
  130. 09:55Or you want to be able to make inference over them.
  131. 09:58So, for example, there is uh some terms in this technology called RDFS.
  132. 10:05Domain and range.
  133. 10:07So, if I say teaches has a domain of teacher.
  134. 10:13That means if I say Bob teaches Scooter in my text, I can infer that Bob is a teacher.
  135. 10:21And if I say all teachers are persons, then this statement lets me know if I say Bob teaches Scooter, now I know Bob is a person, Bob is a teacher.
  136. 10:29What about Scooter?
  137. 10:31If I say teaches has a range of student, that means the the right side of the verb, then Scooter is a student.
  138. 10:38And now I have this extra information into my system.
  139. 10:43OWL also has a series of of of properties that allow you to make some inferences.
  140. 10:51So, a transitive property transitive property says, if Sue is an ancestor like ancestor is a transitive property.
  141. 10:59If Sue is an ancestor of Mary and Mary is an ancestor of Ann, then Sue is an ancestor of Ann.
  142. 11:07Okay?
  143. 11:08This was not initially into my graph system, but with applying these functional properties, I can then add and augment the system with this extra data.
  144. 11:19So, that's very useful.
  145. 11:21Then there's some properties called functional properties, which means only one.
  146. 11:28So, has father is a functional property.
  147. 11:32You can only have one father.
  148. 11:34You can only have one mother.
  149. 11:36That is a functional property.
  150. 11:38Okay?
  151. 11:39So, that's that can serve as a constraint.
  152. 11:42So, when if you say Bob is my Bob is Jim's father, BB is Jim's father, well, the inference here is that Bob and BB are two ways of representing the same individual because
  153. 11:59that is a functional property.
  154. 12:01Can only have one.
  155. 12:02So, these derivations and constraints that don't sit in the graph, they sit sort of on the side and they can help as we're going to see, I'm going to propose,
  156. 12:14when we deal with agents, how they can they can help us out.
  157. 12:17So, what about agents?
  158. 12:21Everybody's talking about agents now and everybody's talking about loops.
  159. 12:25Loops, loops, loops everywhere.
  160. 12:28Loops have been around for a long time.
  161. 12:31Back in the '60s, people were debating who has the best programming language?
  162. 12:35Fortran or COBOL?
  163. 12:36No, mine is better.
  164. 12:37No, mine is better.
  165. 12:38Oh, you don't know anything.
  166. 12:40You don't know what you're talking about.
  167. 12:42Bohm and Jacopini in 1966 came out and said, "Okay, there is no real difference in programming languages if they have three aspects.
  168. 12:51Sequence.
  169. 12:52I can put statement A, statement B, statement C. Fine.
  170. 12:55I have conditionals.
  171. 12:56I can have if then.
  172. 12:58And the last piece, I have a loop.
  173. 13:01If I have a loop, if I have iteration, if I take these three things, the the language is what's called Turing complete.
  174. 13:09Can do any can compute anything that a can be computed by computational devices from the work of Alan Turing.
  175. 13:19Okay?
  176. 13:20And now we're seeing this in agentic AI.
  177. 13:24Agents are now have loops.
  178. 13:25Loops give us the last piece in the equation of giving us a technology that is capable of doing anything that computational devices can do.
  179. 13:40The danger though of loops is that they can break.
  180. 13:45If you're If you're a programmer, you know, you've all go into infinite loop.
  181. 13:49Not good.
  182. 13:51Loops can drift as agents start talking to each other, things get all go off off the rails.
  183. 13:59And loops can cost you money.
  184. 14:02Token counts crank up as the loops continue.
  185. 14:06So, you don't you need to be careful, okay?
  186. 14:09But in a way we are revisiting some of the early stuff with symbolic AI.
  187. 14:14I would argue we're going back to the world of expert systems.
  188. 14:20Which is the symbolic part of the whole thing.
  189. 14:22So, I want to show you a little example using Claude agent.
  190. 14:27So, little code here.
  191. 14:29Don't get scared, but I know nobody does Python anymore, but you got to look at what the agent's giving you and you got to you got to move in and and manipulate it.
  192. 14:38So, here's a here's a loop while true, classic Python loop.
  193. 14:44Okay?
  194. 14:44And so, we have a client.
  195. 14:46So, we're actually So, the first little chunk here that you see, r e s p, the response, this is just some code where we have a model and we have
  196. 14:55uh we have a prompt, that's part of part of the messages, and we have a tool, and we're we're asking the LLM to solve this problem using a tool.
  197. 15:10Now, here's the here's the catch.
  198. 15:14LLMs can't do anything.
  199. 15:16All they can do is give us the next word with a high probability.
  200. 15:20Amazingly, we can now have these conversations it, but they can't do anything.
  201. 15:24But, we can give it a tool, and we can give it what we want, and say, "How do you think this tool can help us get what we want?"
  202. 15:36And then the LLM will set up the parameters, and come back to us, and say, "Okay, here's my response.
  203. 15:46I can't execute this tool, but I know what the input parameters are.
  204. 15:49I know what your context is.
  205. 15:53I know what your prompt is.
  206. 15:54So, here is the call that you need to make of the tool, because I can't do it.
  207. 16:00I'm the LLM.
  208. 16:01I'm just locked in this box.
  209. 16:03Okay?
  210. 16:03So, the second box the second chunk is stop reason.
  211. 16:09So, stop reason means the LLM has stopped for some reason.
  212. 16:15The The reason here is that it can't do anything, and if the reason is tool use, ah, now it's time.
  213. 16:21Let's go execute that tool.
  214. 16:23So, that second line, get tool.
  215. 16:25It takes the response, which is formulating the the parameters, and triggering the action.
  216. 16:32Okay.
  217. 16:32Now, I have this stuff in red here.
  218. 16:34This is where I think the LLMs and other uh I'm sorry, not LLMs.
  219. 16:41The ontologies and stuff can come in.
  220. 16:43So, if you look down there, after the the tool is called, it said tool runs.
  221. 16:52This is where ontologies could come in.
  222. 16:56The tool's going to give us information.
  223. 16:59We put the information in a form that our our our our validator can use, and think about the validator as operating with this these ontologies about our domain, then we can
  224. 17:16make some sense of whether the response of the LLM is reasonable.
  225. 17:23So, this is the loop.
  226. 17:24Call a tool, check the stop reason.
  227. 17:28If it's a reasonable result, then let's go with it.
  228. 17:32If it's not reasonable, go back to the LLM.
  229. 17:34Say, "Oh, this is this is not working."
  230. 17:37Or get a human in the loop.
  231. 17:39But the idea is to surround the input with checks.
  232. 17:44Now, I've got this something that you that you should be at least taking a look at if you're doing some of this coding is something called Pydantic.
  233. 17:52Pydantic is a way to specify the types of what you want the types of the parameters to be.
  234. 18:00Those of you who who do know Python, know Python is a unstructured type language.
  235. 18:06So, you can have a variable x = 20, x = hello, no problem.
  236. 18:10There's no typing.
  237. 18:12Pydantic adds typing to that.
  238. 18:14So, you want to check your types with Pydantic and then check your results with the ontology.
  239. 18:23So, Pydantic at the door, ontology at the ledger, and pure agents and by the way, your agents should try to have no side effects.
  240. 18:32That helps the whole logic.
  241. 18:34Meaning, they're not running off doing something that they're they're changing they're changing things in the database not yet.
  242. 18:40You want to run them through the ontology first and make sure that works.
  243. 18:44Okay.
  244. 18:45I only got an I've got I've got another I've just a short time.
  245. 18:48I'm going to try to show you some of the things that um that you can some logical constructs from from something called OWL, the uh the web object language for for objects.
  246. 19:01So, you have these functional properties, disjoint properties.
  247. 19:05I'll just put these you can look at the slides, but essentially the errors it can catch.
  248. 19:10Look over in the the right-hand column.
  249. 19:12A second refund on the same order is a is is a problem.
  250. 19:18But ontologies could catch it, whereas it's it's very tricky to do that in in English.
  251. 19:23A payout sent to the support desk instead of the buyer.
  252. 19:26Okay?
  253. 19:27You can catch that with an owl disjoint property where customer and support rep are two separate entities.
  254. 19:33Okay?
  255. 19:34Uh one of may a made-up value like probably shipped.
  256. 19:40You can specify you must have certain kinds of value.
  257. 19:44So, uh the status paid, shipped, or refunded, nothing else.
  258. 19:50And when you're in the pure text world, this can get this can get funky because the the LLMs are again probabilistic and um return some crazy stuff.
  259. 20:02Okay.
  260. 20:03Uh so, really what the point I want to make here is use these re- you can have a reasoner built on ontology to check keep the LLM on track,
  261. 20:15have guardrails to keep it honest.
  262. 20:17Okay?
  263. 20:18And for the guardrails, I'm referring to these concepts re- these support technologies with RDFS and owl.
  264. 20:28And my my bottom line is and nothing is a mistake, there's no win, no fail, only a make.
  265. 20:37Okay.
  266. 20:37Feel free to reach out to me coil@burkly.
  267. 20:40I've got a I've got a I've got a little website codesupreme.ai.
  268. 20:44I'm a big fan of if you're John Coltrane has a has a some jazz called uh called Love Supreme.
  269. 20:51So, I've named my site Code Supreme.
  270. 20:54And if you go there, I've got some music and it's all good.
  271. 20:57Okay.
  272. 20:57Thanks very much.
  273. 20:5820 minutes.
  274. 20:59[applause]
  275. 21:15[music]
  276. 21:17Woo!