Teadmiste formaliseerimine 2021

Allikas: Lambda
teadmised

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

Sisukord

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

Eksam ja tulemused

Siin on kursuse tulemused esimese kõigi kolme eksami järel:

Teadmiste formaliseerimise tulemused 2021

Eksamid teeme praeguse plaani järgi füüsiliselt kohapeal. Eksamiaegu on traditsiooniliselt kolm. Kui mõni tudeng on nakatunud või on muu tõendatud põhjus, miks ei saa kohale tulla, teeme erandina lisaks kaugtööna kombineeritud kirjalik/suulise eksami neile, kes seda vajavad.

Kursuse algusepoole antud kohustuslikud ülesanded lähevad arvesse plusspunktidena, mitte miinustena: õppejõud teeb neist enne eksameid kokkuvõtte ja kui oled kõik antud tööd teinud, saad kuni 10 lisapunkti.

Kõik kolm eksamit toimuvad IT kolledzhi auditooriumis ICO-314:

  • 18 mai kell 14:00
  • 25 mai kell 14:00
  • 2. juuni kell 11:00

Eksamiks on kokku aega 2.5 tundi, aga tõenäoliselt saate hakkama ca 1.5 tunniga.

Millised küsimused eksamil tulevad ja kuidas eksamiks õppida:

  • Allpool on tähisega E1 põhimaterjalid ja E2 lisamaterjalid eksamiks õppimiseks: nendest materjalidest võib tulla küsimusi stiilis "seleta lühidalt, mis asi on X või kuidas Y töötab või milleks on Z hea kasutada". Viimaste loengute - 29 aprill ja 6 mai - kohta küsimusi ei tule.
  • Osad eksamiküsimused on väikesed ülesanded kohapeal paberil lahendamiseks. Mis sorti ülesanded:
    • Relatsioonilise andmebaasi tabelite esitamine "harilikul" predikaatloogika kujul, RDF kujul ja JSON-LD kujul.
    • Teisenduste tegemine nelja eelmises punktis antud esituse vahel.
    • Eelmises punktis toodud esitusest päringute tegemine loogikavalemi abil (SQL lause teisendamine)
    • Inimkeelse teksti baasil lihtsate reeglite kirjutamine eelmistes punktides toodud faktide juurde,
    • Sarnaselt eranditega reeglite kirjutamine (default logic).
    • Inimkeelse teksti baasil tõenäosustega faktide/reeglite esitamine: kas fuzzy või "klassikaliste" põhimõtete järgi.
    • Eelmiste punktide baasil väikese järelduskäigu läbitegemine.

NB! Muutsime kolmanda praksi mittekohustuslikuks: tema edukas esitamine annab hulga lisapunkte, aga ei ole eksamile pääsemiseks kohustuslik. Esimesed kaks on endiselt kohustuslikud.

Time, place, result

Lectures: Thursday 14:00-15:30 initially online, later (if all goes well) room U06-229
Practical work: Thursday 16:00-17:30 initially online, later (if all goes well) same room U06-229
Practical work will give 40%, weekly tasks 10% and exam 50% of points underlying the final grade. The exam will consist of several small excercises.

To finish the course successfully, you need to

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

NB! The last (third) practice work has been changed to non-obligatory: when you pass that, you will get a corresponding proportion of extra points.

Links and web pages for lectures, practice, grades

Please join the teams site for the course, for this you may need the team code: ifm14d1

The links to saved lecture videos are 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.

There is also a site for grades registration code 4bFHBTrq. For some time there will be no grades there.

Weekly tasks

These are small tasks you have to report weekly, either by email or by uploading your material.

Kolmanda nädala ülesanne (11. veebruari loengu järel) on eksperimenteerida veidi rdf andme-esituse ja rdfs reeglitega, tehes eelmisele nädalale sarnaselt läbi väikesed harjutused logictools.org saidiga: põhimõtteliselt samad andmed ja samad päringud esitada seekord rdf stiilis kolmikutena.

Konkreetselt tee järgmist:

  • Vaata 11. nädala loengumaterjalide näidet kahe tabeli esitamiseks rdf kujul
  • Vii eelmisel nädalal ehitatud loogika-põhine kahe tabeli esitus teistsuguseks - rdfle baseeruvale - loogikakujule, ehk kõik andmed on esitatud kolmikutena kujul rdf(identifikaator,omadusenimi,omaduseväärtus). Taustaks: eelmise nädala ülesanne oli Background: sql, logic, NLP lehekülgedel 20-22 oleva kahe andmebaasi-tabeli teisendamise peale.
  • Kirjuta uuesti samad päringud loogikakujul, mis eelmine nädal, aga seekord rdf kolmikutena esitatud andmete peale. Taustaks: eelnevalt viidatud materjalis oli üks lihtne SQL select ja üks join, mis tuli siis loogikapäringuteks teha.
  • Lisa täiendavalt taksonoomiareegel vastavalt loengumaterjalis schemaless databases, RDF and RDFS lk 22 ja 23 toodule, ning lisa kolmikud, mis koos selle reegliga ütlevad, et "persons" are "livingthings" ja "cars" on "products".
  • Tee üks oma eeltoodud loogikakujul päringutest ümber nii, et otsitaks mitte "persons"e või "cars"e vaid "livingthings"e või "products"e.
  • Tee need päringunäited koos andmetega logictools.org abil läbi ja saada õppejõule sisendid ja väljundid emailiga. Kui millegagi hätta jääd, saada jällegi sisendandmed, mis valmis said, ja kirjelda, millega hätta jäid. See on ka ok tulemus.

NB! Eelmise nädala soovitused kehtivad endiselt:

  • Negatiivset arvu sa logictoolsi vaikimisi süntaksiga otse sisestada ei saa: -200 interpreteeritakse kui loogilise eituse rakendamist 200-le. Kaks head võimalust negatiivse arvu sisestamiseks on kas kirjutada 0-200 või $difference(0,200).
  • Väiksem-tingimuse jaoks vaata complex examples valikuboksis "arithmetic" näidet.

Practical work

There are three labs. They are all steps in a single project: build a simple natural-language question-answering system a la Watson.

The labs have to be presented to the course teachers and all students present at labwork time.

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.

The third lab was updated for 2021 at 1. April.


First lab

Please read about the task for the first lab.

Deadline: 1.04.2021. But, the second lab will start 1. March and the third 1. April. Please get the basic things of the previous labs working for these deadlines: later labs build on the previous ones.

Second lab

The task in the second lab is to

  • write a small set of additonal, nontrivial rules for geography not present in Yago or Wordnet,
  • actually answering simple questions using logic and rules with the help of a reasoner.

See Details of the KR second lab in 2021

Third lab: numeric confidences or questions in NLP

You have two different choices for the third lab:

Details under the separate pages linked to above. A brief intro will be given during the lecture at 1. April, to be continued with more explanations, suggestions and help at the lecture at 8. April.

Contents

The main focus of the course is on knowledge representation and reasoning (KR), a part of symbolic AI, on a spectrum from simple (representing and using knowledge in databases) to complex (meaning of sentences in natural language and commonsense knowledge).

The course contains the following blocks:

  • Representing knowledge in the SQL and document databases and hybrids.
  • Representing and using simple facts and rules in symbolic AI and logic.
  • General-knowledge databases: wikidata, wordnet, yago, conceptnet, nell, cyc.
  • Knowledge conveyed by natural sentences: both statistical methods like word2vec and logic-based methods.
  • More about reasoners and question answering systems.
  • Confidence and relevance.
  • Context, time, location, events, causality.

Check out this description of the whole KR area.

See also Media:Knowledge_Representation_Intro.pptx

Commonsense rules development

Books to use

  • Ca half of the course themes are covered in this book with freely accessible pdf-s.
  • 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.
  • Recommended background for NLP: Speech and Language Processing by Dan Jurafsky and James H. Martin. here is the 2nd edition and here the web page for the draft 3rd edition
  • Get the background about automated reasoning from the book chapter pages 297-345 by Tanel Tammet and optionally more details from tge the set of course notes from Geoff Sutcliffe.
  • 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.


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.

Block 1: knowledge in the SQL and document databases and hybrids.

Lecture: Intro and background, 28. Jan

The first lecture should be visible here.

Lecture materials:

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

The lecture should be visible here.

Lecture materials:

as logic"

These materials will be taken up in the next lecture:

See also

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

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

Lecture: simple rules in rdfs, logic and owl. 11. Feb

Link to lecture recording.

Have a brief a look of these, no need to read thoroughly:

More resources:

Lecture: rules in logic with provers to answer questions, 18. Feb

Link to the video

These should be looked at in parallel:

Lecture: what the reasoner does, 25. Feb

Link to the video

We will look in detail into the same presentation:

and will explain details of the second practice work.

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.

Block 3: General-knowledge databases

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

Link to video

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:

Lecture: Big annotation systems. 11. March.

Link to the video

First, big annotation systems:

Importantly, see also:

Block 4: natural language and question answering

Lecture: Intro to NLP. 18 March

Link loenguvideole

A lot of reading this week. The main material is in the following chapters 23 and 24 of the Jurafsky and Manning book, the rest is relevant overviews/background. Lecture materials for the week:

Not obligatory, but highly recommended:

Lecture: vector representation of words. 25 March

Iseõpe, mitte loeng: 25. märtsil videoloengut ei toimu. Vektorsemantika kohta on kursuse selle nädala blokis viidatud väga kvaliteetset kuulamist ja lugemist, mis on kindlasti parem, kui oleks õppejõu loeng antud teemal. Seega toimub see nädal iseõpe viidatud materjalidega. Nädala eesmärk on konkreetne: sul on vaja aru saada vektorsemantikast, ehk, mis see on, kuidas sõnavektoreid moodustatakse ja kuidas neid kasutada saab.

Now, you may have had a course on NLP and machine learning, in which case you should already know a lot about vector semantics. If so, consider yourself lucky :) and just skim through the following materials to check whether there are any new things or old friends for you. If not so, consider yourself extra lucky: you have come to the core of machine-learning-based NLP, and this is both pretty cool and quite understandable at the same time! Most of the machine-learning-based NLP is built on top of the ideas of vector representation of words.

As a continuation of the lecture from the last week, please have a look and try out

  • Allen NLP demos for a number of core NLP techniques: highly recommended for experimentation.

Obligatory study materials:

Additional supporting non-obligatory materials from (roughly) easier to more complex:

If you want to get a deeper understanding and look at longer lectures while doing that, there is a wealth of good word vector lecture videos available, for example, from the Stanford NLP course

However, I'd recommend to use the obligatory and supporting materials above first and only - optionally - spend time with the longer lectures after that.

Also interesting to look and read:

Block 5: Conceptually complex issues in KR&R

We will focus on several conceptually complex issues in KR: open/closed world, frame problem, reasoning with uncertainty, semantic parsing of NLP, context etc.

All of these are critical for commonsense reasoning and none have really good answers or implementations so far.

Lecture at intro to lab 3 and planning, frame problem, open/closed world and the blocks world. 1. April.

Link to the saved video of the lecture

We will first have a brief look at the 3. lab: Add and use numeric confidences in rules and/or convert English questions to logical queries.

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.

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


Reasoning with uncertainty, with focus on numeric methods: 8. April

Loenguvideo.

Loengu sissejuhatava osa presentatsioon: Reasoning_with_uncertainty.pdf E2.

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 is an overview-followed-in-depth by the lecturer Numeric uncertainty: (E1 up to and including the chapter 4, 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 recently submitted paper:

  • The paper containing intro, alorithms and experiments.
  • Look at the early 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: semantic parsing and further details for the third practical work. 15. April.

Link to the lecture video by Martin Verrev

Please first listen and read in this order:

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:



Reasoning with uncertainty: discrete reasoning options: 22 april

This week is devoted to discrete methods. It is a self study week without a lecture. Please read the materials described below slowly and carefully: the E1 materials are what I expect you to know well at the exam and the E2 materials are what you should know a bit at the exam.

Experimentation with the DLV system is recommended!

Roughly said, there are three kinds of discrete methods:

  • Exceptions to rules. The main method is called default logic. E1 Read carefully!. Another, less popular method is circumscription (skim through, careful reading not needed). The main classical example for default logic is "birds normally fly": bird(X) & [we fail to prove -flies(X)] => flies(X). In other words, a rule is blocked, if we manage to prove that a negation of the rule-derived fact can be proved. Say we have
    • bird(tweety)
    • penguin(pengu)
    • (bird(X) & [we fail to prove -flies(X)]) => flies(X)
    • penguin(X) => -flies(X)
Then we can derive -flies(pengu) and flies(tweety) but we cannot derive flies(pengu), since it is blocked by -flies(pengu) which we could derive. In the wikipedia page above the "justification P" really means "we fail to prove -P".
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 tutorialit ja DLV manuaali Chapter 4. Queries: siin on näha erinevaid default reasoningu variante. 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 E2 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 E1 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! None of these methods are really used in any kinds of practical systems: they are hard to efficiently implement and they are not understood well enough in practical settings.


Reasoning with uncertainty: combining discrete and numeric: 29 april

link loenguvideole

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

  • What is our approach to using default rules?
  • How do we handle numeric uncertainty and default rules together?
  • What works OK and what is problematic?
  • What are some important practical issues to be solved?
  • Some ideas for building a knowledge base with uncertainties.

See also draft notes for our approach to reasoning with defaults

Context and relevance: 6 May

link loengusalvestusele

Märkmed konteksti teemal

Consultation for exam: 13 May

Teamsi link