Teadmiste formaliseerimine 2023

Allikas: Lambda
teadmised

Name: Knowlege representation
Code: ITI8700
Link: http://lambda.ee/Teadmiste_formaliseerimine
Lecturer: Tanel Tammet
Contact: tanel.tammet@ttu.ee, 6203457, TTÜ ICT-426
Archives of previous years: 2022.

Sisukord

NB! See on 2023 aasta arhiiv, mitte hetkel kehtivad materjalid!

Eksamitulemused

Esimene, 31 mai eksam:

Eesnime esitäht, tudengikood, eksamipunktid (0-50), kokku punktid (0-100), hinne:
O	211913	42	78	3
A	221494	42	86	4
M	221613	30	74	3	
K	211809	31	68	2
T	211539	40	81	4
R	221523	45	92	5
T	221526	44	88	4
K	211832	37	74	3
G	221346	46	97	5

Teine, 5 juuni eksam:

Eesnime esitäht, tudengikood, eksamipunktid (0-50), kokku punktid (0-100), hinne:
H	221662	30	74	3

Eksamiajad ja kohad

  • 31 mai kolmap kell 13-16, ruumis SOC-414 (sotsiaalteaduste maja)
  • 5 juuni esmasp kell 11-14, ruumis U04-103 (IV korpus, pikast koridorist)
  • 8 juuni neljap kell 12:15-15, ruumis SOC-414 (sotsiaalteaduste maja)

Eksamiks on kokku aega 2.5 tundi, aga enamik peaks saama hakkama ca 1.5 tunniga.

Eksam on kirjalik, samas ruumis/ajal toimub ka hajussüsteemide kirjalik eksam.

Vaata ka: 2023 teadmiste kursuse prakside punktid



Time, place, result

Lectures: Tuesday 13:45-15:15 room U05-103
Practical work: Tuesday 15:30-17:00 room U05-103

Teamsi link: https://teams.microsoft.com/l/team/19%3apbCAi1dcW-0ZYLt9oaEWEF0OVSCh_itNLauu6apjLII1%40thread.tacv2/conversations?groupId=ad27ac9b-7364-478f-ad03-7bafeb716af7&tenantId=3efd4d88-9b88-4fc9-b6c0-c7ca50f1db57

Plaan on teha osa loengutest kohapeal (esialgu kindlasti kohapeal) ja osa distantsilt. Loenguid salvestame ja salvestuste lingid on allpool blokkide/loengute juures.

Praksidega samamoodi: algul kindlasti kohapeal, samas üritame salvestada / üle kanda, edaspidi tõenäoliselt osa prakse distantsilt (teamsis).

Salvestuste lingid leiad allpool kas vastava loengu või praksi peatüki all.

Moodles materjale ei ole: kogu info, materjalid ja ülesanded on lambda lehel.


Practical work will give 50%, exam 50% of points, and weekly tasks additional extra up to 10%, underlying the final grade. The exam will consist of several small excercises.

To finish the course successfully, you need to

  • successfully pass three practical works
  • receive at least 1/3 of the max points at exam
  • get practice work + weekly tasks + exam at least 50% points altogehter.

Contents overview: what the course is about

The theme of the course: from SQL to natural language.

Hence the main focus of the course is on hybrid methods for knowledge representation and reasoning: symbolic AI, machine learning / neural methods and their combinations. We look at this spectrum from simple (representing and using knowledge in databases) to complex (meaning of sentences in natural language and commonsense knowledge) tasks. A closely related subject is commonsense reasoning.

The course contains the following blocks:

  • Knowledge in SQL, RDF and JSON
  • Handling simple facts and rules in symbolic AI and logic
  • General-knowledge databases
  • Natural language and question answering
  • Uncertain knowledge and hybrid systems


Links to the teams group and lecture videos

The links to saved lecture videos are and will be visible among the materials of corresponding lectures below.

NB! In case you run into trouble (cannot join or no sound etc) please write via fb messenger or email tanel.tammet at taltech.ee.


Practical work

There are three labs. They are all steps in a single project: build a simple natural-language question-answering system a la classic Watson. There is also an alternative option to do one larger practical research project instead of these three labs: details of this project have to be discussed and agreed with Tanel.

The labs have to be presented (as a demo + small overview of the software and principles) to the course teachers and all students present at labwork time, either in the auditorium or over MS teams. The labs can be prepared alone or by teams of two or three people.


Each lab is evaluated independently and gives the same number of points. NB! When you do not meet the lab deadline, you will be awarded half of the points for this lab.

First lab

2023 task for the first lab is an intro to the world of large knowledge bases and a preparation for the following labs where we will use this data to experiment with some nontrivial question answering.

Deadline: 28 February.

Second lab

Deadline: 11. April 2022.

See Details of the KR second lab in 2023

Third lab: questions in NLP

Deadline: 9. May.

The tasks for 2023:

Details under the separate pages linked to above. An intro and initial explanations will be given during the lectures, starting with the 28 March lecture.

Since the tasks are conceptually nontrivial, everybody is encouraged to use the teams group for the course to ask for help whenever you run into trouble: starting from April both teachers will monitor the teams daily and try to help you out.


Books to use

Main materials:

  • Get the basic background about classical automated reasoning from the book chapter pages 297-345 by Tanel Tammet and optionally more details from the set of course notes from Geoff Sutcliffe.
  • The book for natural language (NLP): Speech and Language Processing by Dan Jurafsky and James H. Martin. here is the 2nd edition and (suggested) here the web page for the draft 3rd edition. Recommendation: read from the beginning up to an including chapter 6: Vector Semantics and Embeddings, then skip and read a few chapters starting from 15: Logical Representations of Sentence Meaning. You do not need to understand all the details of math, for example. It is OK if you understand the main principles of representations and algorithms.

Other useful books and tools for symbolic K&R:

  • logictools.org for experimenting with classical automated reasoning
  • Symbolic reasoning themes are covered in this book with freely accessible pdf-s.
  • Similarly, the freely accessible pdf of the handbook of knowledge representation gives a detailed and thorough coverage of the subject; far more than necessary for the course.
  • You may want to get a small intro to Prolog by reading the first 100 pages of a classic Art of Prolog book: pdf is freely downloadable under the "Open Access" tab. It is not strictly necessary for the course (we will not be using Prolog) but it surely helps. Besides, the book is interesting, quite easy to read and works out a lot of interesting examples.

Other useful material for neural NLP:



Observe that a noticeable part of the course contents are not covered by these books: use the course materials and links to papers, standards and tutorials provided.

Blocks and lectures: the main content of the course

Allpool olev blokkide struktuur on sarnane, aga mitte sama, kui 2022 aastal. Transformerite (BERT, GPT) ja hübriidsüsteemide osa muutub mahukamaks.

Toimunud loengute materjalid ja salvestused osaliselt uuendatakse/muudetakse: kogu info veel mitte toimunud loengute ja prakside kohta on pärit peamiselt 2022 aastast ja on esialgne indikatsioon.

Block 1: knowledge in SQL, RDF and JSON

Lecture: Intro and background, 31. Jan

Sissejuhatuse presentatsioon:

teadmised_intro2023.pdf

Soovitav (mitte kohustuslik) kuulamine:

Lecture: Nosql, json and rdf in databases: 7. Feb

loengu salvestus teamsis

praksi salvestus teamsis

Lecture materials:

See also

The weekly homework will be about trying out small things in logic: please try out logictools from "basics" to "equality" in simple examples selectbox. Details will appear after the lecture.

Block 2: handling simple facts and rules in symbolic AI and logic

Lecture: simple rules in rdfs, logic and owl: 14 feb

Have a brief a look at this, no need to read thoroughly:

The main materials covered in the lecture:


And then have brief look (skim through) at:

Certainly read:

We will also start at looking and understanding the examples in logictools.org

More resources:

Lecture: rules in logic with provers to answer questions: Feb 21

Loengusalvestus teamsis.

We will consider the reasoning part of K&R to understand what provers do:

You may want to have a look at the additional materials - from easier to harder - from the book chapter pages 297-345 by Tanel Tammet, the the set of course notes from Geoff Sutcliffe, the implementation presentation from Stephan Schulz and the readable-and-hackable PyRes reasoner for educational use.

Lecture: what the reasoner does: 28 Feb

Loengusalvestus teamsis

We will continue with the same presentation:

along with doing/explaining experiments using logictools.

Block 3: General-knowledge databases

Lecture: looking into main large knowledge bases: 7. March

Loengusalvestus 2023

E2: you can search/investigate what kind of data is available and you can find out actual data from these databases with some work, by surfing on the web pages of the systems.

We will have a look at the goals, main content and differences between:


Block 4: natural language and question answering

Lecture: Intro to NLP, n-grams, word vectors: 14 March

Loengusalvestus

Recommended listening:

Lecture: large language models (LLM), BERT and GPT families: 21 märts

Iseõppe nädal, loengut ei toimu (õppejõud peab olema sama ajal senati istungil).

Eesmärk: saada pinnaliselt aru LLM ja transformerite (NLP masinõppe põhiasjad) peamistest ideedest. Detailid on tegelikult keerulised ja nendest arusaamine võtab hulga rohkem aega, kui meil kursuses on, sestap lepime vähesega. Samas, kui sul endal huvi, siis loomulikult on teretulnud detailsem iseõpe.

Enne järgmisse materjali süvenemist tutvu kindlasti vektorsemantikaga, mida seletasime 14 märtsi loengus.

Mida vaadata ja lugeda:

Kindlasti

Paratamatult jääb enamus detaile loengus vähearusaadavaks (kui ise ei kuluta hulga aega järele katsetamiseks), aga sellegipoolest on see tõenäoliselt kõige parem loeng transformeritest: mingi tunnetuse sellest, et mis toimub, saab.

Optsionaalselt üldisem arusaam klassikutelt:

Optsionaalselt diipim arusaam:


Block 5: uncertain knowledge and hybrid systems

We will focus on (a) uncertainty in KR (open/closed world, frame problem, probabilities, exceptions) and (b) current research on building hybrid systems

Lecture: third lab, neurosymbolic reasoning, open/closed world, planning, frame problem, blocks world: 28 March

We will first have a brief look at the 3. lab: Experiment with natural language rules, ChatGPT and ProofWriter and an alternative Use a semantic parser and a reasoner to solve questions posed in natural language.

We will then give a brief overview of the work/tasks in hybrid neurosymbolic AI.

For the main part of the lecture we consider planning and the frame problem. The standard example for these is a blocks world: some blocks are on the table and the robot arm can lift single blocks and put them on other blocks or on the table. The arm cannot lift several blocks or a tower of blocks. Then, given a position of blocks at initial situation, can the robot arm create a required new position of blocks? Can we get the steps required? For getting the steps we use the $ans predicate.

One hard issue arising is that how do we know that doing some action like lifting a block does not create side effects like stumbling existing towers, moving other blocks etc? This issue is called the frame problem and it has no easy solutions.

Importantly, the frame problem arises since normal first order logic has

  • the open world assumption E1 (must read): if we do not have (and cannot derive) a positive fact like P(a) and neither a negative fact like -P(a), we assume we simply do not know which holds.

Prolog and databases operate under the

  • closed world assumption E1 (must read): if we do not have (and cannot derive) a positive fact like P(a), we automatically assume that -P(a) must be true. For example, Prolog "negation" really means "cannot prove". One consequence of this assumption is that we cannot represent real negation and disjunction in an OK manner (Prolog does not contain these) and cannot satisfactorily speak about "true", "false" and "unknown". See also negation as failure in prolog


Please look at and read these materials about the frame problem:

These two readings are optional:

  • frame problem at the Stanford Encyclopedia of philosophy: not obligatory, but a good read to get a better understanding.
  • another classic about frame problem: read this only if you became really really interested about the whole issue: it goes quite deep, although it is not especially technical.

You may also want to have a look at the algorithmic complexity and efficient solution algorithms, regardless of how we formalize the problem: see this article.

Next, importantly, you should experiment yourself with gkc and both of the following files. Please copy and read the files and understand the encoding. At the end of the files are several queries to experiment with: instructions are also there.

In both of them the predicate holds(X,Y) is used to describe something X about the blocks world (like, one block is on another or robot holds some block) and the second argument Y describes the state we have arrived to via robot actions from the original state (like, picked up a block in the initial state and then did put the block down on top of another).



To get a simple visualization of the blocks world, have a look at this tiny video.


Reasoning with uncertainty: 4 April

Loengu sissejuhatava osa presentatsioon: Reasoning_with_uncertainty.pdf E1.

Almost all the knowledge we have is uncertain: there are many exceptions to a rule or a fact/rule holds with some vague probability. Notice that, in contrast, typical databases in companies contain facts with very high certainty, but they do not contain rule or commonsense knowledge: the latter is built into brittle software code of systems using these databases.

We will consider two different ways to tackle uncertainty:

  • Numeric methods: uncertainty is estimated with probability-like numbers of various kinds.
  • Discrete methods: no numbers used. Instead, uncertainty is described as exceptions or beliefs of people.

NB! Both of these ways are hard to actually implement, neither have they been understood very well, despite an immense amount of research and papers. For example, typical machine learning methods operate with extremely vague probability-like numbers and do not attempt to put these numbers into a real properly-theoretical-and-correct probabilities framework.

The main material for reading about numeric methods is an overview-followed-in-depth by the lecturer Numeric uncertainty: (E2 up to and including the chapter 3, see also E2 tags inside)

  • Read carefully up to and including the chapter 4 "Different ways to encode confidences in logic" and have a quick look at all the wikipedia links.
  • Skim through the later parts and look only into these subchapters which you found interesting.

Next,

  • Read the paper E2. containing intro, alorithms and experiments.
  • Look at the web page with the confer reasoner and a wealth of examples.

Next, have a brief look at a good example system doing some specific kinds of probability reasoning:

Lecture: initial reviews of GPT4 + more on 3rd pract work + semantic parsing, 11 April

Lecture recording 2023

Materials accompanying the lecture:

Additionally recommended to listen and read in this order:

Also, check out a very useful demo:


You may want to have a look at the AllenAI tutorial

Additionally you may want to read some papers about semantic parsing:

  • Read a paper about building a semantic parser in a relatively simple way.
  • Another paper about semantic parsing

There is an interesting specific method for semantic parsing, called AMR, worth having a brief look into:

There is a very good fairly deep NLP-and-commonsense series of podcasts and other interesting stuff from the Allen Institute for AI:

Lecture: research in hybrid systems: 18 aprill

Teamsi salvestus 2023

Hübriidsüsteemid: loengu käigus tehtud sissjeuhatavad märkmed



Lecture: further details for semantic parsing: 25 aprill

Loengu annab Martin: audikas pluss teamsis.

Teamsi link 2023

Loenguslaidid: Media:KR_2023_Parsing_Verrev.pdf E2


Reasoning with uncertainty: discrete reasoning options: 2. mai

Loengusalvestus teamsis 2023.


Esimest järku loogikas ei ole üldjuhul võimalik välja rehkendada, et mingi asi ei ole järelduv. Lausearvutuses samas on. Sestap on olemas selline tore valdkond nagu answer set programming, E2 kus esimest järku muutujatega valem teisendatakse lausearvutuseks, tekitades muutujatega reeglitest hästi palju konstante sisaldavaid reegleid. Siis muutuvad blokkerite arvutamised võimalikuks. Võid tahta lugeda päris head introt teemasse, mille on kirjutanud Aalto ülikooli rektor Niemelä. Samas ei ole see lausearvutuseks-teisendamine mittetriviaalsetel juhtudel võimalik. Üks paremaid süsteeme seal on DLV (DLV wikis), vaata DLV manuaali Kui sul tekib rohkem huvi, siis selle answer-set programming lähenemise jaoks on olemas terve kursus videote ja loengumaterjalidega.
Teine oluline küsimus eranditega reeglite puhul on nende prioriteedid: kui kaks reeglit üksteist blokivad, kas mõnel peaks olema kõrgem prioriteet? Näiteks, "materiaalsed asjad üldiselt ei lenda", "linnud on materiaalsed asjad", "linnud üldiselt lendavad", "pingiviinid on linnud", "pingviinid üldiselt ei lenda". Siin paistab, et taksonoomias allpool olevaid asju kirjeldavad reeglid võiks olla kõrgema prioriteediga kui ülalpool asju kirjeldavad reeglid. Samas "Nixoni kolmnurga" näites "vabariiklased ei ole patsifistid", "kveekerid on patsifistid", "Nixon korraga vabariiklane ja kveeker" oleks loomulik mõelda, et esimesed kaks default reeglit Nixoni jaoks blokeeruvadki ja me ei saa järelda, et Nixon on patsifist, ega ka seda, et ta ei ole patsifist. Prioriteetide teema kohta võib vaadata täeindavalt seda artiklit või seda sarnast artiklit.
  • Describing beliefs of various actors. This builds upon modal logic (see intro presentation to understand the basics) and the main method is (auto)epistemic logic: the logic for encoding who knows or believes what. See the long tutorial as an easily read text E2 and additionally tutorial slides Ijcai93.pdf by the same authors to accompany the long text. Read carefully, starting with the long text and also looking at slides at the side.
  • Multi-valued logics with belief degrees (a la "very unlikely", "very likely") at different intervals. We will not look into these: we'll investigate the numeric methods instead. Have a very brief look at the wikipedia.

NB! Modal beliefs and multivalued logics are not really used in any kinds of practical systems: they are hard to efficiently implement and they are not understood well enough in practical settings. However, different versions of default logics (and other systems with exceptions) are actually used, including in https://github.com/tammet/nlpsolver

Reasoning with uncertainty: combining discrete and numeric + context: 9 mai

loengusalvestus 2023

Artikkel default reasoningu kohta.

Artikkel kogu pipeline kohta: parsimine, reasoning, vastused. E2


We will look at a number of small examples using both numeric and discrete uncertainty, plus context, and will experiment with our new experimental solver in a live session.

Konsultatsioon eksamiks: 16 mai