Teadmiste formaliseerimine: erinevus redaktsioonide vahel

Allikas: Lambda
Mine navigeerimisribale Mine otsikasti
 
6. rida: 6. rida:
<td>
<td>
Name: <b>Knowlege representation</b><br>
Name: <b>Knowlege representation</b><br>
Code: <b>ITI8700</b><br><!--
Code: <b>ITI8700</b><br>
Link: http://www.lambda.ee/index.php/Teadmiste_otsing,_formaliseerimine_ja_hoidmine  or http://www.lambda.ee/index/itv0060<br>-->
Link: http://lambda.ee/Teadmiste_formaliseerimine <br>
Lecturer: Tanel Tammet<br>
Lecturer: [https://www.facebook.com/tanel.tammet Tanel Tammet] tanel.tammet@ttu.ee ICT-426<br>
Labs: Evelin Halling and Tanel Tammet<br>
Practice sessions: Riina Maigre<br>
Contact: tanel.tammet@ttu.ee, 6203457, TTÜ ICT-426<br>
Archives of previous years: [[Teadmiste formaliseerimine 2025|2025]].
Archives of previous years: [[Teadmiste otsing, formaliseerimine ja hoidmine|2015]]
[[itv0060 2014 arhiiv|2014]], [[itv0060 2013 arhiiv|2013]], [[itv0060 2012 arhiiv|2012]], [[itv0060 2011 arhiiv|2011]], [[itv0060 20010 arhiiv|2010]], [[itv0060 2009 arhiiv|2009]], [[itv0060 2008 arhiiv|2008]], [[itv0060 2007 arhiiv|2007]],  [[itv0060 2006 arhiiv|2006]], [http://cs.ttu.ee/kursused/wav4130/ older].
</td>
</td>
</tr>
</tr>
</table>
</table>


= Eksamitulemused =


== Time, place, result ==
Eksamitulemused siin:
* [[Esimene (27 mai) teadmiste eksam 2026]]
* [[Teine  (1 juuni) teadmiste eksam 2026]]
* [[Kolmas  (8 juuni) teadmiste eksam 2026]]


Lectures: Wednesdays 12:00-13:30 room U06A-229<br>
= Eksamikonsultatsioon =
Practical work: Wednesdays 14:00-15:30, room ICT-121, ICT-122<br>
Practical work will give 40% and exam 60% of points underlying the final grade.
The exam will consist of several small excercises.


The first practical work time on 30. January at 14:00 will be used as a secord conventional lecture of the day.
(a) väike salvestuse teamsi, teemaks siis eksamikorraldus, ülesanded jne:[https://livettu.sharepoint.com/:v:/r/sites/Knowledgerepresentation2026/Shared%20Documents/General/Recordings/Eksami%C3%BClevaate%20salvestus-20260520_053318UTC-Meeting%20Recording.mp4?csf=1&web=1&e=rQObCH&nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJTdHJlYW1XZWJBcHAiLCJyZWZlcnJhbFZpZXciOiJTaGFyZURpYWxvZy1MaW5rIiwicmVmZXJyYWxBcHBQbGF0Zm9ybSI6IldlYiIsInJlZmVycmFsTW9kZSI6InZpZXcifX0%3D salvestus siin], asub kursuse teamsi-salvestuste kataloogis.


Some of the last lecture times at the end of the course may be used as additional seminars/labs.
(b) Konsultatsioonide lingid siin:


== Assumed background ==
* [https://teams.microsoft.com/meet/313481263783182?p=n6Lqqc5BNDUaCUX0IJ eksamikonsultatsioon] 20. mai kell 10:30-11:00. (enne seda, kell 10:00 hajussüsteemide konsultatsioon, tolle kursuse lehel oleval lingil).
* [https://teams.microsoft.com/meet/365383768774501?p=WPjQ5sq3VKweu8doJT eksamikonsultatsioon] 25. mai kell 10:30-11:00. (enne seda, kell 10:00 hajussüsteemide konsultatsioon, tolle kursuse lehel oleval lingil).


You should have studied the course [http://lambda.ee/w/index.php?title=Tehisintellekti_ja_masin%C3%B5ppe_alused&oldid=15188 "Basics of AI and Machine Learning"] or get acquinted with the logic and probabilities parts of the course yourself.
= Eksamikorraldus ja materjalid õppimiseks =


In particular, it is useful to read these course materials and exercises: [http://lambda.ee/w/images/8/81/Chapter08-abbrev.pdf logic AIMA book], [http://lambda.ee/w/images/a/a6/Chapter07-abbrev2.pdf wumpus world in AIMA book], [http://lambda.ee/w/images/8/80/Chapter13-abbrev2.pdf uncertainty in AIMA book], [http://lambda.ee/w/images/5/5b/Chapter1415-abbrev.pdf probability models in AIMA book],
Eksamiks on kokku aega 2.5 tundi, aga enamik peaks saama hakkama ca 1.5 tunniga.
[http://lambda.ee/wiki/Iti0210lab8 prolog lab], [http://lambda.ee/wiki/Iti0210lab9 bayes lab]


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


The main focus of the course is on [https://en.wikipedia.org/wiki/Knowledge_representation knowledge representation and reasoning] (KR), on a spectrum from simple to very complex: representing and using knowledge in databases, sentences in natural language and commonsense knowledge.
Allolevad punase E1-ga on eksami jaoks kõige olulisemad materjalid, E2 veidi vähem olulised.
NB! Võrreldes varasemaga on lisaks markeeritud E2-ga need varasemalt olemas, aga markeerimata materjalid:


The overall goal of the labwork to understand issues facing a task of building a natural language question answering system a la [https://en.wikipedia.org/wiki/Watson_(computer) Watson] and to see and experiment with existing parts of the solution.
* [[Media:Llm_intro_2026.pdf|Lecture material part 1]] <font color="red">E2</font>
* [[Media:Llm_details_2026.pdf|Lecture material part 2]] <font color="red">E2</font>
* [[Media:Llm_usage_rag.pdf|Lecture material]] <font color="red">E2</font>
* [[Media:Visual Reasoning 2026.pdf|Lecture presentation]] <font color="red">E2</font>
 
Ekamil tuleb neli eraldi hinnatavat osa: kolm teemaküsimust ja üks osa paari lühiküsimusega. Spetsiifiliste süntaksite (RDF, loogikavarandid jne) osas: ühtegi täpset süntaksit/võtmesõnu ei pea teadma, aga esitus peab olema õppejõule sisuliselt arusaadav.
Millised on teemaküsimused ja millised on lühiküsimused:
 
SQL ja loogika: esitan paar tabelit ja küsin mõnda taolist küsimust:
* nende sisu võimalikult täpset esitust esimest järku loogikas või RDFs
* mõne konkreetse where- või join-päringu kirjutamist esimest järku loogikas
 
JSON-LD: annan JSON-LD jupi ja küsin selle tähendust ehk teisendust RDF kujule kolmikutena.
Reeglite esitamine: pane rdf ja/või rdfs kujule ja/või predikaatloogikale baseerudes kirja etteantud konkreetsed inimkeelsed väited.
 
Reeglite rakendamine klassikalises teoreemitõestamises: oskus teha käsitsi läbi väike resolutsioonimeetodi rakendamise näide, kui disjunktid ette antud.
 
Sõnavektorid ja N-grammid ja keelemudelite üldprintsiibid: arusaamine, oskus esitada väike näide töötamise kohta, võimalikud kasutus- või loomisstsenaariumd
 
Ebakindlate teadmiste esitamise põhimeetodid: pidevad (erinevat sorti tõenäosuste-tüüpi esitus) ja diskreetsed (eranditega süsteemid, eeskätt default logic). Siin võin tuua väikese näite ja küsida lahendust või palun ise esitada mõne pisinäite sobival kujul. Konkreetseid süntakseid teadma ei pea, piisab õppejõule arusaadavaks tegemisest.
Lühiküsimused (siit valitakse iga eksami jaoks paar):
 
Seleta paari lausega, mis asi on, vahel küsin ka näidet: freimiprobleem, open/closed world, blocks world, RAG, erinevad tõenäosuste interpretatsioonid, RDFa; mis asi on ja mida sealt umbes leida võib ja mida pigem mitte: schema.org, wordnet, conceptnet, yago, cyc; mida sa mäletad "semantiline parsimine" ja "visual reasoning" teemade kohta.
 
= Eksamipäevad ja ajad =
 
Siin on täpsustunud esimese kahe eksami ajad:
 
* 27 mai, kolmapäev, kell 11:00 (koos hajussüsteemide eksamiga). Auditoorium NRG-226.
* 1 juuni, esmaspäev: eraldi eksamiajad hajussüsteemide (11:00) ja teadmiste esitamise (14:00) jaoks. Auditoorium SOC-211a.
* 8 juuni, esmaspäev: kell 11:00 (koos hajussüsteemide eksamiga). Auditoorium ICT-315.
 
 
<!--
= <font color="red">NB! Kolmas kodutöö uuendatud</font> =
 
Vaata allpool "Third lab: questions in NLP": see on uuendatud 2026 aasta jaoks. Idee on analoogiline eelmise aasta ülesandega, aga konkretiseeritud piltide ülesandega (esimese ja teise kodutöö teemad) sobivaks.
-->
<!--
= <font color="red">NB! 23 ja 24 veebruar on puhkepäevad</font> =
Esmaspäev, 23. veebruar (ja ka teisipäev, 24. veebruar) on ülikoolis puhkepäevad ja õppetööd ei toimu.
-->
<!--
= <font color="red">NB! Materjalid hetkel uuendamisel</font> =
-->
 
= Time, place, result =
 
Lectures (Tanel): Mondays 12:00-13:30 room SOC 414<br>
Practice sessions (Riina): Tuesdays 08:00-09:30 room <s>MEK-122</s> MEK-109.
 
The lectures and sessions will be on site (physical room) plus teams. Later we may decide to do some lectures/practice sessions on teams only: this will be advertised on the page here early. Beware: recording may not always succeed.
 
Please join the [https://teams.microsoft.com/l/team/19%3A-xXLRsURTirXcCCkQN46w4wYRJaarxbl797KeThtWXY1%40thread.tacv2/conversations?groupId=30b97413-f1b1-404d-8498-b35024d1a002&tenantId=3efd4d88-9b88-4fc9-b6c0-c7ca50f1db57 teams group] of the course. The code for joining is zb3z457.
 
Weekly [https://teams.microsoft.com/meet/33688408323196?p=sd6YBPK9VZ7gRe7Zro teams link for the lecture].
 
Weekly [https://teams.microsoft.com/meet/3558703223396?p=zc4Lgecwoy1e9Yhav9 teams link for the practice session].
 
= Grading =
 
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 (a) several questions asking for the explanation of important concepts along with examples (b) some small excercises.
 
The materials below marked with the red <font color="red">E1</font> are the main materials for the exam (10 of these on the page), while <font color="red">E2</font> materials (20 on the page) will also come up, but less and/or in a simpler form.
 
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: <i>from SQL to natural language</i>.
 
Hence the main focus of the course is on hybrid methods for
[https://en.wikipedia.org/wiki/Knowledge_representation knowledge representation and reasoning]: [https://en.wikipedia.org/wiki/Symbolic_artificial_intelligence symbolic AI], [https://en.wikipedia.org/wiki/Machine_learning machine learning / neural methods] and their [https://en.wikipedia.org/wiki/Neuro-symbolic_AI neurosymbolic 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 [https://en.wikipedia.org/wiki/Commonsense_reasoning commonsense reasoning].


The course contains the following blocks:
The course contains the following blocks:


* Background and basics. Representing and using simple facts and rules.
* Knowledge in SQL, RDF and JSON
* Knowledge conveyed by natural sentences: both statistical methods like word2vec and logic-based methods.
* Handling simple facts and rules in symbolic AI and logic
* General-knowledge databases: wikidata, wordnet, yago, conceptnet, nell, cyc.
* General-knowledge databases
* Reasoners and question answering systems.
* Natural language and question answering
* Context, time, location, events, causality.
* Uncertain knowledge and hybrid systems
* Different kinds and dimensions of uncertain knowledge.
 
* Indexes and search.
= Weekly tasks =
 
The small weekly tasks are in addition to the practical work: their goal is to practice with the stuff presented at the last lecture.
 
== The first weekly task ==
 
Ülesanne on eksperimenteerida veidi [http://logictools.org logictools.org] saidiga ja teha ise läbi loengus toodud näited SQL data ja päringute esitamisest loogikas. Tähtaeg 17. veebruar.
 
Konkreetselt tee järgmist:
* Eksperimenteeri veidi [http://logictools.org logictools.org] "simple examples" valikuboksi näidetega basic ... equality, loe nende selgitusi ja püüa aru saada tõestustest.
* Loe seejuures predikaatloogika väikest seletust [http://logictools.org/about.html#basic_syntax about lehel] kuni lausearvutuseni (seda pole enam otse vaja lugeda).  
* Kirjuta ise valmis näide vastavalt kursuse materjalile [[Media:Kr_lect_1b_2024.pdf| Background: relations of sql and logic]] lk pealkirjaga "SQL join as logical rule", kus on toodud ühe client tabeliga ja client ning cars tabelitega näide sql päringute teisendamisest loogikasse (üks lihtne select ja üks join):
<pre>
client table: id name balance
1 john 100
2 pete -200
 
cars table: id model owner
1 ford 1
2 opel 2
3 saab 2
 
select client.name, client.balance
from client where balance<0
 
select client.name, cars.model from client, cars
where client.id=cars.owner
</pre>
 
Tee need näited reaalselt valmis nii, et logictools.org sööb nad sisse ja annab ootuspärase vastuse. Seejuures on sul vaja kasutada $ans predikaati, nagu "answers" näites toodud. Kui tahad mitut vastust (ei ole kohustuslik), siis vaata ka "multiple answers" näidet.
 
* Saada näite-sisendid ja genereeritud tõestused õppejõule emailiga (riina.maigre at taltech.ee ja cc tanel.tammet at taltech.ee). Kui jääd nendega hätta, siis kirjuta, mida proovisid, too oma näitetekst ja selgita, mille juures hätta jäid (see on ka arvestatav tulemus): kirjuta aadressile riina.maigre at taltech.ee või tanel.tammet at taltech.ee ja pane pealkirja sisse mh sõna "formaliseerimine", et kirja kergesti üles leiaks.
 
* Kasuta kindlasti oma taltech.ee aadressi, sest muidu võib kiri lõpetada rämpspostis!
 
Soovitused:
* 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).
* Aritmeetika jaoks vaata help teksti Arithmetic peatükki.
* Väiksem-tingimuse jaoks vaata complex examples valikuboksis "arithmetic" näidet.
 
 
== The second weekly task ==
 
Selle ülesande mõte on veidi praktiseerida JSON-LD esitusega. Sinu konkreetne ülesanne on võtta oma esimene nädalaülesanne ja esitada needsamad andmed (ja soovitavalt ka reeglid) JSON-LD kujul.
 
Vaata alustuseks json-ld näiteid [https://logictools.org/json.html logictoolsi json-tabi alt]. NB! Enamus näiteid "example" valikuboksist ei ole konventsionaalne json-ld, aga mitmed on.
 
<!--
= The first weekly task =
 
Ülesanne on eksperimenteerida veidi [http://logictools.org logictools.org] saidiga ja teha ise läbi loengus toodud näited SQL data ja päringute esitamisest loogikas. Tähtaeg 25. veebruar.
 
Konkreetselt tee järgmist:
* Eksperimenteeri veidi [http://logictools.org logictools.org] "simple examples" valikuboksi näidetega basic ... equality, loe nende selgitusi ja püüa aru saada tõestustest.  
* Loe seejuures predikaatloogika väikest seletust [http://logictools.org/about.html#basic_syntax about lehel] kuni lausearvutuseni (seda pole enam otse vaja lugeda).
* Kirjuta ise valmis näide vastavalt kursuse materjali [[Media:Kr_lect_1b_2024.pdf| Background: relations of sql and logic]] lk pealkirjaga "SQL join as logical rule", kus on toodud ühe client tabeliga ja client ning cars tabelitega näide sql päringute teisendamisest loogikasse (üks lihtne select ja üks join). Tee need näited reaalselt valmis nii, et logictools.org sööb nad sisse ja annab ootuspärase vastuse. Seejuures on sul vaja kasutada $ans predikaati, nagu "answers" näites toodud. Kui tahad mitut vastust (ei ole kohustuslik), siis vaata ka "multiple answers" näidet.
* Saada näite-sisendid ja genereeritud tõestused õppejõule emailiga (riina.maigre at taltech.ee ja cc tanel.tammet at taltech.ee). Kui jääd nendega hätta, siis kirjuta, mida proovisid, too oma näitetekst ja selgita, mille juures hätta jäid (see on ka arvestatav tulemus): kirjuta aadressile riina.maigre at taltech.ee või tanel.tammet at taltech.ee ja pane pealkirja sisse mh sõna "formaliseerimine", et kirja kergesti üles leiaks.
* Kasuta saatmiseks kindlasti taltech.ee aadressi, sest muidu võib kiri minna rämpspostiks!
 
Soovitused:
* 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).
* Aritmeetika jaoks vaata help teksti Arithmetic peatükki.
* Väiksem-tingimuse jaoks vaata complex examples valikuboksis "arithmetic" näidet.
-->
 
= Practical work =
 
 
There are three labs.
 
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 ==
 
The [[KR 2026 homework part 1|2026 task for the first lab]] is about encoding nontrivial information in various ways (standard logic, rdf, json-ld) and writing simple logical rules for answering questions.
 
Deadline: 10. March.
 
== Second lab ==
 
The [[KR 2026 homework part 2|2026 task for the second lab]] is about using a VLM (visual language model) to get a structured description from an image which would fit with the pre-existing simple world model.
 
Deadline: 7. April
 
== Third lab: questions in NLP ==
 
This is the task for 2026:


Check out [http://www.lisperati.com/tellstuff/ this description] of the whole KR area.
[[Experiment with neurosymbolic reasoning: LLM as a parser plus a symbolic reasoner for images: 2026]]  


Some books to use:
Deadline: 12. May


* Recommended for NLP: Speech and Language Processing by Dan Jurafsky and James H. Martin. [https://github.com/rain1024/slp2-pdf/blob/master/complete-book-pdf/slp2.pdf here is the 2nd edition] and [https://web.stanford.edu/~jurafsky/slp3/ here the web page for the draft 3rd edition]
<!--
* Ca half of the course themes are covered in [http://www.sciencedirect.com/science/book/9781558609327 this book] with freely accessible pdf-s.
This is an example from 2025, not the task for 2026:
* The freely accesible pdf of the [http://ii.fmph.uniba.sk/kri/KRhandbook.pdf handbook if knowledge representation] gives a detailed and thorough coverage of the subject; far more than necessary for the course.
[[Experiment with neurosymbolic reasoning: LLM as a parser plus a symbolic reasoner: 2025]]
-->
<!-- * [[Use a semantic parser and a reasoner to solve questions posed in natural language: 2025]] -->
<!-- We will do live experimenting for the third lab at the April 22 lecture and will then add more interesting parts to the notes above. -->
<!--
NB! The task description above has just been updated (at 13. April) with the example code and files developed and presented during the [https://livettu.sharepoint.com/:v:/r/sites/Knowledgerepresentation2025/Shared%20Documents/General/Recordings/Knowledge%20representation%202025%20lectures-20250422_140202-Meeting%20Recording.mp4?csf=1&web=1&e=McaLE9&nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJTdHJlYW1XZWJBcHAiLCJyZWZlcnJhbFZpZXciOiJTaGFyZURpYWxvZy1MaW5rIiwicmVmZXJyYWxBcHBQbGF0Zm9ybSI6IldlYiIsInJlZmVycmFsTW9kZSI6InZpZXcifX0%3D 22. April lecture.]
-->
 
= Books to use =
 
Main materials:
 
* Get the basic background about classical automated reasoning from the [[Media:Loogikaopik.pdf|book chapter pages 297-345]] by Tanel Tammet and optionally more details from  [http://lambda.ee/w/images/0/06/Geoffreasoningnotes.pdf the set of course notes] from Geoff Sutcliffe.
* <b>The</b> book for natural language (NLP): Speech and Language Processing by Dan Jurafsky and James H. Martin. <!-- [https://github.com/rain1024/slp2-pdf/blob/master/complete-book-pdf/slp2.pdf here is the 2nd edition] and (suggested) --> [https://web.stanford.edu/~jurafsky/slp3/ the web page for the draft 3rd edition]. Recommendation: read from the beginning up to an including chapter 6: Vector Semantics and Embeddings, then read [https://web.stanford.edu/~jurafsky/slp3/20.pdf chapter 6 about extracting information] and the appendix chapter [https://web.stanford.edu/~jurafsky/slp3/H.pdf Logical Representations of Sentence Meaning].
 
Other useful books and tools for symbolic K&R:
 
* [https://logictools.org logictools.org] for experimenting with classical automated reasoning
* Symbolic reasoning themes are covered in [http://www.sciencedirect.com/science/book/9781558609327 this book] with (hopefully) freely accessible pdf-s via Taltech. See also [https://www.cs.toronto.edu/~hector/PublicKRSlides.pdf slides] for the book.
* Similarly, the freely accessible pdf of the [https://dai.fmph.uniba.sk/~sefranek/kri/handbook/handbook_of_kr.pdf handbook of knowledge representation] <!-- http://ii.fmph.uniba.sk/kri/KRhandbook.pdf  --> 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 [http://cdn.preterhuman.net/texts/computing/programming/Prolog/The%20Art%20of%20Prolog%20%202nd%20Ed%20-%20Leon%20Sterling%20,%20Ehud%20Shapiro.pdf Art of Prolog] book. 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:
 
* Andrej Karpathy [https://github.com/karpathy/nanoGPT nanoGPT] and [https://github.com/karpathy/nn-zero-to-hero neural networks zero to hero course]
<!-- * [https://dugas.ch/artificial_curiosity/GPT_architecture.html GPT architecture] -->
<!--
<!--
* Interesting to browse: [http://www.aaai.org/Library/KR/kr12contents.php recent conference proceedings]
* Interesting to browse: [http://www.aaai.org/Library/KR/kr12contents.php recent conference proceedings]
66. rida: 260. rida:
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.
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.


== Practical work ==
= Blocks and lectures: the main content of the course =
 
The details and materials of lectures in the future are from 2025 and will be revised/extended. The materials of the current or passed lectures are up to date.
 
 
== Block 1: knowledge in SQL, RDF and JSON ==
 
=== Lecture: Intro and background: 2. February ===
 
Intro presentation:
 
[[Media:teadmised_intro2026.pdf|teadmised_intro2026.pdf]]
 
Recommended non-obligatory listening: [https://lexfridman.com/francois-chollet-2 Francois Chollet], [https://lexfridman.com/yann-lecun-2 Yann LeCun], [https://lexfridman.com/gary-marcus Gary Marcus], [https://lexfridman.com/demis-hassabis Demis Hassabis], [https://lexfridman.com/ilya-sutskever Ilya Sutskever], [https://lexfridman.com/ben-goertzel Ben Goertzel] <!--, [https://towardsdatascience.com/language-models-symbolic-learning-and-the-road-to-agi-75725985cdf7 Tim Rocktäschel] -->,
 
=== Lecture: Nosql, json and rdf in databases: 9. February  ===
 
Lecture materials:
* We cover [[Media:Kr_lect_1b_2024.pdf| Background: relations of sql and logic]] <font color="red">E1</font>
 
* and start with [[Media:Kr_lect_2b_2024.pdf| schemaless databases, RDF and RDFS]] <font color="red">E1</font> (also important for practice work)
See also
* Json in Postgresql: [https://www.postgresql.org/docs/current/datatype-json.html json datatype] and [https://www.postgresql.org/docs/current/functions-json.html functions for json]
 
The weekly homework will be about trying out small things in logic: please try out [http://logictools.org/ 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 + reasoner: 16. February ===
 
* Main lecture material: [[Media:Kr_lect_2b.ppt| schemaless databases, RDF and RDFS]]
<!--
* [https://livettu.sharepoint.com/:v:/s/Knowledgerepresentation2023/EflyEjMnTMxKji6nxhy1ErUBvaUg1I749ZjrOtNYrHUynQ?e=cBfYNu 2023 Loengusalvestuse link].
-->
[[Rdf example developed during lecture]]<font color="red">E2</font>
 
Have a brief a look at this, no need to read thoroughly:
 
* Official w3c [https://www.w3.org/TR/rdf11-primer/ rdf and rdfs primer] <font color="red">E2</font>
 
The main materials covered in the lecture:
* [https://json-ld.org/ json-ld] (check out [https://json-ld.org/playground/ playground examples]) <font color="red">E1</font> currently most popular triple representation language on top of json. see also [https://en.wikipedia.org/wiki/JSON-LD wikipedia] and [https://www.w3.org/TR/json-ld11/ w3c standard]: for the latter, read [https://www.w3.org/TR/json-ld/#basic-concepts the basic concepts chapter] <font color="red">E2</font>.
* [https://www.w3.org/TR/rdfa-primer/ rdfa] <font color="red">E2</font> triple markup language suited for html, see also [https://en.wikipedia.org/wiki/RDFa wikipedia]
* [http://schema.org schema.org] (<font color="red">E2</font> you can surf on the schema.org site and understand/find answers there)) we looked at in the last lecture: property markup vocabulary suggested by Google, Microsoft and others.
 
 
And then have brief look (skim through) at:
* Official w3c [https://www.w3.org/TR/2012/REC-owl2-primer-20121211/ owl primer] but it is better to look at this [https://www.semantic-web-book.org/w/images/b/b0/KI09-OWL-Rules-1.pdf intro presentation] and continue with [https://www.semantic-web-book.org/w/images/5/5e/KI09-OWL-Rules-2.pdf the owl rules presentation]
* [https://www.stardog.com/tutorials/sparql/ sparql tutorial] and [https://en.wikipedia.org/wiki/SPARQL wikipedia take] on sparql.
 
Certainly read:
* Hea jutt [https://twobithistory.org/2018/05/27/semantic-web.html Whatever Happened to the Semantic Web?]
 
We will also start at looking and understanding the examples in [http://logictools.org logictools.org]
 
More resources:
 
* [https://en.wikipedia.org/wiki/List_of_SPARQL_implementations sparql implementations] in wikipedia
* [https://www.w3.org/RDF/ various rdf tools] listed at the bottom of the page
 
What the reasoner does:
 
We will consider the reasoning part of K&R to understand what provers do:
* [[Media:Kr_lect_4.pdf| rules, logic, provers]] <font color="red">E1</font>
* [http://logictools.org/ logictools] system running gkc reasoner in the browser: try out the "simple" and "complex" examples, read explanatory texts and the [http://logictools.org/about.html#basic_syntax manual about predicate logic]
* Have a look at the [https://github.com/tammet/gkc gkc] github repo, including precompiled binaries for command line in the [https://github.com/tammet/gkc/releases/tag/v0.6.0 release 0.6.0] and the [https://github.com/tammet/gkc/tree/v0.6.0/Examples tutorial Examples/Readme.md].
<!-- * [[Reasoner examples with gkc 2020]] <font color="red">E2</font> -->
* [[Travel examples from lecture 2021]]
 
You may want to have a look at the additional materials - from easier to harder - from the
* [[Media:Loogikaopik.pdf|book chapter pages 297-345]] and optional extras, 346-382; by Tanel Tammet.
* [http://lambda.ee/w/images/0/06/Geoffreasoningnotes.pdf the set of course notes] from Geoff Sutcliffe,
* [https://resources.mpi-inf.mpg.de/departments/rg1/conferences/vtsa09/slides/schulz.pdf the implementation presentation] from Stephan Schulz
* [https://fmv.jku.at/rerise14/rerise14-fo-slides.pdf 5-lecture prover course] from the authors of [https://vprover.github.io/ Vampire]
* and the readable-and-hackable [https://github.com/eprover/PyRes PyRes reasoner] for educational use.
 
=== Lecture: DPP ontology development. 2. March ===
 
Loengu annab Riina. Digital Product Passport (DPP)
kui näide praktilisest ontoloogia/sõnastiku arendamisest [https://cirpassproject.eu/dpp-in-a-nutshell/ CIRPASS] projektis.
 
[https://dpp.vocabulary-hub.eu/ Hetkeseisu algusleht].
 
[https://cirpass2.eu/ CIRPASS-2]
 
[https://si-digital-framework.org/SI/units?lang=en Ühikute ontoloogia]
 
[https://www.w3.org/TR/shacl/ SHACL]
 
[https://untp.unece.org/docs/specification/DigitalProductPassport/ UNTP DPP]
 
 
 
<!--
 
=== Lecture: what the reasoner does: märtsi algul ===
-->
<!--
<font color="red">NB!</font>This lecture will be the following recording from 2024 pluss self-study reading and experiments only, not in the lecture room:
-->
<!--
 
[http://turing.cs.ttu.ee/~tanel.tammet/reasoning_engines_recording_2024.mp4 Recording]
-->
 
=== Lecture: Next homework and looking into main large knowledge bases: 9. March  ===
 
We will first present the next homework.
 
Then we will continue with existing large knowledge bases.
 
Slides:[[Media:ITI8700_05_Large_KB.pdf|lecture slides]] <font color="red">E2</font>, a tool to explore Wordnet taxonomies can be found here: https://github.com/martinve/wntool
 
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.
 
About knowlege base creation using LLMs: have a look at [https://arxiv.org/html/2411.04920v1 this paper].
 
We will have a look at the goals, main content and differences between:
 
* [https://wordnet.princeton.edu/ wordnet] see [http://tptp.cs.miami.edu/cgi-bin/SeeTPTP?Category=Axioms&File=NLP001+0.ax tptp axioms]
* [https://www.dbpedia.org/ dbpedia], see also [http://mappings.dbpedia.org/server/ontology/classes/ classes] and [http://mappings.dbpedia.org/index.php/Main_Page dbpedia wiki]
* [https://en.wikipedia.org/wiki/Wikidata wikidata]
* [https://www.mpi-inf.mpg.de/departments/databases-and-information-systems/research/yago-naga/yago/ yago old page] and [https://yago-knowledge.org/ new page]
* [https://babelnet.org/ babelnet] described in [https://en.wikipedia.org/wiki/BabelNet wikipedia]
* [http://conceptnet5.media.mit.edu/ conceptnet] described in [https://en.wikipedia.org/wiki/Open_Mind_Common_Sense wikipedia]
* [http://rtw.ml.cmu.edu/ nell website] (sometimes down) and in [https://en.wikipedia.org/wiki/Never-Ending_Language_Learning wiki] and [https://cacm.acm.org/magazines/2018/5/227193-never-ending-learning/fulltext a good paper]. 
* [https://framenet.icsi.berkeley.edu framenet] described in [https://en.wikipedia.org/wiki/FrameNet wikipedia], see [https://framenet2.icsi.berkeley.edu/fnReports/data/lu/lu9791.xml example]
* [https://cyc.com cyc] but just read [https://en.wikipedia.org/wiki/Cyc wikipedia] and see [https://www.cyc.com/wp-content/uploads/2019/09/Cyc-Technology-Overview.pdf whitepaper] also [http://tptp.cs.miami.edu/cgi-bin/SeeTPTP?Category=Axioms&File=CSR002+1.ax tptp small random selection of axioms]
* [https://www.ontologyportal.org/ sumo] and [https://adimen.ehu.eus/web/adimenSUMO adimen-sumo], see [https://en.wikipedia.org/wiki/Suggested_Upper_Merged_Ontology sumo in wikipedia] and [http://tptp.cs.miami.edu/cgi-bin/SeeTPTP?Category=Axioms&File=CSR003+0.ax tptp axioms]
* [https://www.tptp.org/ tptp]: a large set of axioms and problems in logic usable for automated reasoners
* [http://schema.org schema.org]: property markup vocabulary suggested by Google, Microsoft and others.
* [https://reference.wolfram.com/language/guide/KnowledgeRepresentationAndAccess.html Wolfram alpha stuff]
 
<!--
=== Lecture: Allen Ai research systems and Google, Facebook annotation systems  ===
 
[https://livettu.sharepoint.com/:v:/r/sites/Knowledgerepresentation2022/Shared%20Documents/General/Recordings/Teadmiste%20loengu%20eelsalvestus%2015%20jaanuariks-20220314_154224-Meeting%20Recording.mp4?csf=1&web=1&e=3grCku Link salvestusele].
 
Examples from [https://allenai.org/ Allen Ai] research:
* [https://macaw.apps.allenai.org/ Macaw demo]: a predictor like GPT-3
* [https://proofwriter.apps.allenai.org/ Proofwriter demo]: a hybrid system (rules + predictor)  (see the [https://arxiv.org/pdf/2012.13048.pdf paper])
* [https://rule-reasoning.apps.allenai.org/ Rule Taker demo]: an earlier version of the Proofwriter above
* [https://mosaic.allenai.org/ Mosaic] commonsense reasoning
** [https://mosaic.allenai.org/projects/mosaic-commonsense-benchmarks SWAG benchmark dataset]
** [https://allenai.org/data/atomic Atomic data]
** [https://mosaic.allenai.org/projects/commonsense-knowledge-graphs Atomic graph explorer]
** [https://arxiv.org/pdf/1811.00146.pdf Atomic paper]
 
 
Google, Facebook annotation systems:
* [https://developers.google.com/search/docs/guides/intro-structured-data Google structured data] <font color="red">E2</font> on the webpage. See also [https://en.wikipedia.org/wiki/Knowledge_Graph Google knowledge graph] <font color="red">E2</font> in wikipedia.
* [https://developers.facebook.com/docs/sharing/webmasters/ Facebook Open Graph markup] on the webpage. See also https://ogp.me/ and the [https://en.wikipedia.org/wiki/Facebook_Graph_Search history of NLP-based ogp search]
 
As a background, recall:
* [https://json-ld.org/ json-ld] (check out [https://json-ld.org/playground/ playground examples]) <font color="red">E1</font> currently most popular triple representation language on top of json. see also [https://en.wikipedia.org/wiki/JSON-LD wikipedia] and [https://www.w3.org/TR/json-ld11/ w3c standard]: for the latter, read [https://www.w3.org/TR/json-ld/#basic-concepts the basic concepts chapter] <font color="red">E2</font>.
* [https://www.w3.org/TR/rdfa-primer/ rdfa] <font color="red">E2</font> triple markup language suited for html, see also [https://en.wikipedia.org/wiki/RDFa wikipedia]
* [http://schema.org schema.org] (<font color="red">E2</font> you can surf on the schema.org site and understand/find answers there)) we looked at in the last lecture: property markup vocabulary suggested by Google, Microsoft and others.
-->
 
== Block 3: natural language and question answering ==
 
=== Lecture: Intro to NLP, n-grams, word vectors: 16 March ===
 
<!--
[https://livettu.sharepoint.com/:v:/r/sites/Knowledgerepresentation2024/Shared%20Documents/General/Recordings/Teadmiste%20loeng%205%20m%C3%A4rts-20240305_120418-Meeting%20Recording.mp4?csf=1&web=1&e=cWEU8A&nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJTdHJlYW1XZWJBcHAiLCJyZWZlcnJhbFZpZXciOiJTaGFyZURpYWxvZy1MaW5rIiwicmVmZXJyYWxBcHBQbGF0Zm9ybSI6IldlYiIsInJlZmVycmFsTW9kZSI6InZpZXcifX0%3D Loengusalvestus teamsis]
-->
<!--
[https://livettu.sharepoint.com/:v:/s/Knowledgerepresentation2023/Ea7HdMQxBcBGlSqBi18ZC2cBg7HU371GuQOVkdvkDjnyVg?e=PNaowE Loengusalvestus]
-->
 
* These three wikipages give useful introductory details:[https://en.wikipedia.org/wiki/Natural_language_processing Natural language processing], [https://en.wikipedia.org/wiki/Knowledge_extraction Knowledge extraction], [https://en.wikipedia.org/wiki/Natural_language_understanding Natural language understanding].
* Tanel Alumäe keelemudelitesse [http://lambda.ee/w/images/1/13/Keelemudelid.pdf sissejuhatavad slaidid] <font color="red">E1</font> ja [https://echo360.org.uk/media/e4323062-3442-46fb-9124-e7b9e7d00006/public loengusalvestus]
* Väga hea õpik: [https://web.stanford.edu/~jurafsky/slp3/ 3. variant].
** Vektorsemantikast arusaamiseks loe 3. variandi [https://web.stanford.edu/~jurafsky/slp3/3.pdf ptk 3. N-gram Language Models] <font color="red">E2</font> ja siis [https://web.stanford.edu/~jurafsky/slp3/5.pdf chapter 5: Embeddings] <font color="red">E2</font>. Vaata [https://web.stanford.edu/~jurafsky/slp3/ sisukorrast] ka slaide nende kohta.
* Google [https://books.google.com/ngrams/info ngrams] ja [https://storage.googleapis.com/books/ngrams/books/datasetsv3.html reaalne data].
* [https://nlp.stanford.edu/projects/glove/ GloVE]: a relatively simple vector representation
<!--
* [https://beta.openai.com/ GPT-3 API beta] publicly available without a waiting period. There is also a playground on the web.
-->
* Kui tahad katsetada toore Wikipedia dataga, siis saab loengus vaadatud töödeldud variante siit (tarballid sisaldavad datat, selgitavat README-d ja tarkvara selle ise ehitamiseks): [http://turing.cs.ttu.ee/~tanel.tammet/wikicompact.tar.gz  a compacted pure-text version of full wikipedia], [http://turing.cs.ttu.ee/~tanel.tammet/wikilemma.tar.gz A lemmatized version of wikipedia texts], [http://turing.cs.ttu.ee/~tanel.tammet/wikicooccurrence.tar.gz Several co-occurrence matrices and lists of top-co-occurring words for wikipedia]
<!--
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:
* Intro to the relevant parts of the whole NLP field: [[Media:Kr_lect_3a.pdf| nlp and watson]]: <font color="red">E1</font> you may skip the watson part and read it from the following book chapter instead. These three wikipages give also useful details, but are not really necessary to read: [https://en.wikipedia.org/wiki/Natural_language_processing Natural language processing], [https://en.wikipedia.org/wiki/Knowledge_extraction Knowledge extraction], [https://en.wikipedia.org/wiki/Natural_language_understanding Natural language understanding].
* In case you have not studied machine learning techniques for natural language processing, read the initial parts of the [https://web.stanford.edu/~jurafsky/slp3/6.pdf chapter 6: Vector Semantics and Embeddings] <font color="red">E2</font> from the Jurafsky and Martin book: this is a good background for the next two chapters 25 and 26, but not strictly necessary: we will look more into vector semantics during the next week anyway.
* Read from the Jurafsky and Martin book: [https://web.stanford.edu/~jurafsky/slp3/23.pdf chapter 23: Question Answering] <font color="red">E2</font>
* Read from the Jurafsky and Martin book: [https://web.stanford.edu/~jurafsky/slp3/24.pdf chapter 24: Dialogue Systems and Chatbots] <font color="red">E2</font>and the supporting slides [https://web.stanford.edu/~jurafsky/slp3/slides/convagents1.pdf for conversational agents]
-->
<!--
Recommended listening:
 
* A cool 14-minute philosophy podcast episode to listen: [https://nigelwarburton.typepad.com/philosophy_bites//2015/03/jonathan-webber-on-deceiving-with-words.html Jonathan Webber on Deception With Words] plus a [http://traffic.libsyn.com/philosophybites/Jonathan_Webber_on_Deception_With_Words.mp3 a direct audio link (may expire at some point)]
* A bit old (i.e. few new episodes) [https://soundcloud.com/nlp-highlights NLP highlights] podcast series from the [https://allenai.org/ Allen institute for AI]. Makes sense to start from the very first ones and pick these which have a title looking interesting to you. World-leading stuff and quite understandable.
-->
* Loengus tehtud [[katse Glove vektoritega]] [https://medium.com/analytics-vidhya/basics-of-using-pre-trained-glove-vectors-in-python-d38905f356db selle jutu] järgi.
 
=== Lecture: large language models (LLM) 23 March ===
 
* [[Media:Llm_intro_2026.pdf|Lecture material part 1]] <font color="red">E2</font>
* [[Media:Llm_details_2026.pdf|Lecture material part 2]] <font color="red">E2</font>
 
<!--
[https://livettu.sharepoint.com/:v:/r/sites/Knowledgerepresentation2024/Shared%20Documents/General/Recordings/New%20channel%20meeting-20240312_120339-Meeting%20Recording.mp4?csf=1&web=1&e=j8fZj2&nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJTdHJlYW1XZWJBcHAiLCJyZWZlcnJhbFZpZXciOiJTaGFyZURpYWxvZy1MaW5rIiwicmVmZXJyYWxBcHBQbGF0Zm9ybSI6IldlYiIsInJlZmVycmFsTW9kZSI6InZpZXcifX0%3D loengusalvestus koos teise praksi ülesannetega]
-->
 
Eesmärk: saada <i>pinnaliselt</i> 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 11 märtsi loengus.
 
Mida vaadata ja lugeda:
 
Eriti soovitav
 
* [https://www.youtube.com/watch?v=kCc8FmEb1nY Andrej Karpathy progemisega-koos loeng]: vaata see süvenemisega läbi! Vt ka [https://en.wikipedia.org/wiki/Andrej_Karpathy Karpathy].
 
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.
 
Pikemaks lugemiseks:
* [https://jalammar.github.io/visualizing-neural-machine-translation-mechanics-of-seq2seq-models-with-attention/ visualizing neural machine translation] and then [https://jalammar.github.io/illustrated-transformer/ the illustrated transformer]
* [https://web.stanford.edu/~jurafsky/slp3/7.pdf Jurafsky & Martin book: neural networks] and the [https://web.stanford.edu/~jurafsky/slp3/slides/7_NN_Apr_28_2021.pdf slides]. Alternative: [http://www.cs.cmu.edu/afs/cs.cmu.edu/project/theo-20/www/mlbook/ch4.pdf CMU Mitchell course: neural networks basics]
* [https://web.stanford.edu/~jurafsky/slp3/9.pdf Jurafsky & Martin: chapter 9, transformers ]
<!-- * [https://web.stanford.edu/~jurafsky/slp3/10.pdf Jurafsky & Martin: chapter 10, transformers and LLMs] -->
<!-- * [https://dugas.ch/artificial_curiosity/GPT_architecture.html GPT arhitektuuri üldseletus]: eriti head intuitsiooni ei maksa loota :) -->


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


The labs have to be presented to the course teachers and all students present at labwork time.
Optsionaalselt üldisem arusaam klassikutelt:


The labs can be prepared alone or by teams of two people. The first lab task will be given on 6. February.
* [https://lexfridman.com/yann-lecun-3 Jann LeCun: värske episood Lex Fridmani podcastist]
* [https://writings.stephenwolfram.com/2023/02/what-is-chatgpt-doing-and-why-does-it-work/ Wolframi pikk jutt] lugemiseks koos närvivõrkudega üldisema taustaga
* [https://rodneybrooks.com/what-will-transformers-transform/ Rodney Brooksi] ennustused transformerite kohta


First, read the explanation of the [[KR 2019 homework: overall task|overall task]]. The following labs are steps on the path to the end goal.
Optsionaalselt diipim arusaam:  


=== First lab ===
* [https://github.com/karpathy/nanoGPT nanoGPT]: [Karpathy reaalne näitekood GPT ise-ehitamiseks (otse eelmise loenguga seotud) : seda saab ilma suuremate pingutusteta käima linuxil ja macil, windowsil tekib aga suuremaid probleeme (proovisin ise linuxil järgi).
* [https://karpathy.ai/zero-to-hero.html Taustaks: Karpathy terve loenguseeria], kui sul tekib sügavam huvi
* [https://web.stanford.edu/~jurafsky/slp3/10.pdf Jurafsky & Martin ptk 10 Large Language Models] kui tahad ise juurde lugeda.
* Good free (?) book:  [https://www.manning.com/books/build-a-large-language-model-from-scratch Build a Large Language Model (From Scratch)]
* [https://course.fast.ai/ väga detailne ja mahukas videoloengutega deep learningu kursus], mh [https://course.fast.ai/Resources/book.html raamat].


=== Lecture: RAG usage pattern / context engineering for LLMs : 30 March ===


Deadline: <b>14. March</b> (after this there will be a penalty).
[[Media:Llm_usage_rag.pdf|Lecture material]]: this is focused on RAG and written in 2024 and spring 2025: good tool use, good reasoning and more autonomy like claude code and openclaw are not covered in this overview.  


If you manage to fullfill the task earlier, start doing the second lab.
<b>"Context Engineering"</b> became a popular phrase in 2025: essentially it means "fancy RAG", i.e. significant effort put towards creating a really good set of additional information (prompt additions: "context") for each user query/prompt. It can also mean approaches for storing such additional information on the fly in special files which
are then used RAG-like as extra input in addition to user dialog.For example, claude code [https://code.claude.com/docs/en/memory memory principles] and [https://blog.dailydoseofds.com/p/anatomy-of-the-claude-folder memory folder structure], openclaw [https://lumadock.com/tutorials/openclaw-memory-explained memory].


Please read about [[KR 2019 homework part 1: overall task|the task for the first lab]]
Useful reading in addition to pointers in the lecture material:
* [https://pixelplex.io/blog/llm-applications/ application landscape overview]
<!-- * early taxonomy [https://arxiv.org/pdf/2311.05288.pdf of real business use] -->
* RAG focus: [https://eugeneyan.com/writing/llm-patterns/ LLM improvement for applications] and a basic overview of [https://www.databricks.com/glossary/retrieval-augmented-generation-rag customizing llms]
* Old finetuning example: [https://www.anyscale.com/blog/fine-tuning-llama-2-a-comprehensive-case-study-for-tailoring-models-to-unique-applications Finetuning llama 2]
* RAG:
** [https://colabdoge.medium.com/what-is-rag-retrieval-augmented-generation-b0afc5dd5e79 simplest RAG intro] <font color="red">E1</font>
** [https://direct.mit.edu/tacl/article/doi/10.1162/tacl_a_00530/114590/Improving-the-Domain-Adaptation-of-Retrieval more rag details]: a good architecture picture, may skip the improvements part after that
** [https://medium.com/@evertongomede/understanding-sequence-to-sequence-seq2seq-models-and-their-significance-d2f0fd5f6f7f encoder/decoder] and [https://en.wikipedia.org/wiki/Seq2seq Seq2seq] as a generalization of [https://en.wikipedia.org/wiki/Word2vec word2vec] and [https://openai.com/blog/new-and-improved-embedding-model openai embedding model api]
** [https://en.wikipedia.org/wiki/Vector_database vector database] <font color="red">E2</font> as a useful tool
** [https://www.promptingguide.ai/research/rag different kinds of rag] <font color="red">E2</font> based on [https://arxiv.org/abs/2312.10997 paper]
<!--
** [https://python.langchain.com/docs/expression_language/cookbook/retrieval rag by langchain]
** [https://proceedings.neurips.cc/paper/2020/hash/6b493230205f780e1bc26945df7481e5-Abstract.html a fancy rag paper]
-->
<!-- ** [https://getalign.com/ example estonian startup using a kind of rag] -->


=== Second lab ===
== Block 4: hybrid systems and uncertain knowledge ==


The task in the second lab is actually answering simple questions from the input text, using a small set of rules you write and a reasoner.
We will focus on (a) world modeling and uncertainty in KR (open/closed world, frame problem, probabilities, exceptions) and (b) current research on building hybrid systems
 
=== Lecture: issues in formalizing commonsense reasoning: open/closed world, frame problem, uncertainties: 6. April ===
 
<!--
<i>First, some results/challenges in neurosymbolic reasoning.</i>
 
* [https://arxiv.org/pdf/2301.13379.pdf generating computation tasks]
* [https://github.com/tammet/llmlog our current experiments in reasoning with LLM]
* [https://onlinelibrary.wiley.com/doi/full/10.1111/cogs.13432 neurosymbolic Bongard]
* [https://arcprize.org/ arcprize]. See also [https://liusida.github.io/ARC/ ARC v1 for humans], [https://www.youtube.com/watch?v=jSAT_RuJ_Cg MLST about the state of v1 solvers], [https://www.youtube.com/watch?v=M3b59lZYBW8 MLST video introducing ARC v2]
* [https://deepmind.google/discover/blog/alphageometry-an-olympiad-level-ai-system-for-geometry/ alphageometry]
* [https://arxiv.org/pdf/2402.01817.pdf a position paper on hybrid systems] <font color="red">E2</font>
-->
<!--
<!--
The task in the second lab is to
* [https://arxiv.org/pdf/2302.07842.pdf a large survey of tool use]
* disambiguate ambivalent words like "it", "he" and
* download, process and make usable some large data- and rulesets.
* experiment with a reasoner.
-->
-->
<!--
<!--
See [[details for KR lab 2]].
See also an [https://adamkarvonen.github.io/machine_learning/2024/01/03/chess-world-models.html interesting recent piece about learning chess]
 
We will first give a brief overview / reminder of the work/tasks in hybrid neurosymbolic AI.
 
We will then consider the issues regarding the world model and the output we expect from
the neural part / LLM, along with some demonstrations of semantic parsing with and without the use of LLM.
-->
 
 
<b><i>First, open/closed world, world states, frame problem</i></b>
 
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 <b>frame problem</b> and it has no easy solutions.
 
Importantly, the frame problem arises since normal first order logic has
* the <i>open world assumption</i>: 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
* [https://en.wikipedia.org/wiki/Closed-world_assumption closed world assumption] <font color="red">E1</font> (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 [https://cliplab.org/~vocal/public_info/seminar_notes/node52.html negation as failure] in prolog
 
 
Please look at and read these materials about the frame problem:
<!--
* [https://www.youtube.com/watch?v=JzlsvFN_5HI tiny video] of the Boston Dynamics robot failing: looks like a frame problem in the blocks world :)
-->
-->
* [https://people.cs.pitt.edu/~milos/courses/cs2740/Lectures/class14.pdf overview presentation]: <font color="red">E1</font> must read.
* [https://folk.idi.ntnu.no/gamback/teaching/TDT4138/dennett84.pdf a classic AI philosophy paper] about the frame problem: must read the first three pages (rest is optional).
* [https://en.wikipedia.org/wiki/Frame_problem wikipedia about frame problem]: <font color="red">E2</font>  skim it through (no need to read all the details) to get a rough idea about different approaches to the frame problem. None of these are really good.
These two readings are optional:
* [https://plato.stanford.edu/entries/frame-problem/ frame problem] at the Stanford Encyclopedia of philosophy: not obligatory, but a good read to get a better understanding.
* [http://www-formal.stanford.edu/leora/fp.pdf 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: [https://www.sciencedirect.com/science/article/pii/S0004370200000795/pdf?md5=31cd36929c848ce418180ff94abf4800&pid=1-s2.0-S0004370200000795-main.pdf 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. The simplest way to experiment is to use https://logictools.org/ . There is already a <b>blocks world</b> example available.
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).
* [[Simple axiomatization of the blocks world]]: <font color="red">E2</font> please also read through the comments explaining the axiomatization and queries!
* [[More complex blocks world axiomatization]] taken from the [http://www.tptp.org/ TPTP] problem set for first order logic, concretely by concatenanting and commenting axiom sets [[PLA001-0.ax]], [[PLA001-1.ax]] and queries [[PLA004-1.p]], [[PLA005-1.p]], [[PLA019-1.p]]
To get a simple visualization of the blocks world, have a look at this [https://www.youtube.com/watch?v=gbIPicRoIgQ tiny video].
<b><i>Second, uncertainty</i></b>
Loengu sissejuhatava osa presentatsioon: [[Media:Reasoning_with_uncertainty.pdf|Reasoning_with_uncertainty.pdf]] <font color="red">E1</font>.
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]]: (<font color="red">E2</font> up to and including the chapter 3, see also <font color="red">E2</font> tags inside)
* <b>Read carefully</b> up to and including the chapter 4 "Different ways to encode confidences in logic" and have a quick look at all the wikipedia links. In particular, [https://en.wikipedia.org/wiki/Bayesian_inference Wiki on Bayesian inference] and [https://math.mit.edu/~dav/05.dir/class11-prep.pdf this]
* Skim through the later parts and look only into these subchapters which you found interesting.
Next,
* Read [https://link.springer.com/chapter/10.1007/978-3-030-79876-5_29 the paper] <font color="red">E2</font> about confidences. containing intro, algorithms and experiments. Then look at the [http://logictools.org/confer/ web page] with the confer reasoner and a wealth of examples.
* Read [https://link.springer.com/chapter/10.1007/978-3-031-10769-6_18 the paper] <font color="red">E2</font> about exceptions (default logic). containing intro, alorithms and experiments. Then look at the [http://logictools.org/gk/ web page] with the gk reasoner and a wealth of examples.
Next, have a brief look at a good example system doing some specific kinds of probability reasoning:
* [https://dtai.cs.kuleuven.be/problog/ Problog] start with a [https://dtai.cs.kuleuven.be/problog/tutorial.html tutorial] <font color="red">E2</font>
* Try out some examples via browser from the [https://dtai.cs.kuleuven.be/problog/tutorial.html tutorial]
=== Lecture: research in neurosymbolic reasoning: 13 April ===
[[Media:Research_in_Neurosymbolic_Reasoning.pdf|lecture slides]]
The lecture will be given by our PhD student [https://aire-edih.eu/meeskond/otto-mattas/ Otto Mättas].
=== Lecture: semantic parsing with LLMs and with UDP: 20 April ===
The focus of the lecture is on [https://en.wikipedia.org/wiki/Semantic_parsing semantic parsing].
For a quick intro we will use Martin's slides from 2024 [[Media:KR_2024_Parsing_01.pdf|semantic parsing]] <font color="red">E2</font>.
The rest of the lecture will explain stuff in [https://github.com/tammet/nlpsolver nlpsolver]. See the [[Media:Nlpsolver_presentation.pdf|nlpsolver presentation]].
Useful background:
About important concepts in parsing:
* [https://en.wikipedia.org/wiki/Part_of_speech Part-Of-Speech (POS)] and [https://en.wikipedia.org/wiki/Part-of-speech_tagging POS tagging]
* [https://web.stanford.edu/~jurafsky/slp3/18.pdf Jurafsky&Martin: Constituency Parsing]
* [https://web.stanford.edu/~jurafsky/slp3/19.pdf Jurafsky&Martin: Dependency Parsing]
Some important toolkits and representation schemes:
* [https://spacy.io spacy], [[a small spacy UD parsing example]]
* [https://stanfordnlp.github.io/stanza/ stanza]
* [https://universaldependencies.org/ universal dependencies]
Some draft parsing papers:
* [[Media:concepts_draft_paper.pdf|concepts, based on UD]]
* [[Media:pipeline_draft_paper.pdf|pipeline, based on UD]]
* [[Media:llm_parser_draft_paper.pdf|experiments with LLM usage]]
=== Lecture: we explore some recent papers in neurosymbolic reasoning: 27 April  ===
A reading session: we will read and attempt to understand together some case studies.
* Google DeepMind paper [https://www.nature.com/articles/s41586-023-06747-5 Solving olympiad geometry without human demonstrations]
* Google DeepMind paper [https://www.nature.com/articles/s41586-025-09833-y Olympiad-level formal mathematical reasoning with reinforcement learning]
* [https://arxiv.org/abs/2502.13834 Proving Olympiad Inequalities by Synergizing LLMs and Symbolic Reasoning]
* [https://arxiv.org/abs/2511.11751 Concept-RuleNet: Grounded Multi-Agent Neurosymbolic Reasoning in Vision Language Models]
* [https://proceedings.neurips.cc/paper_files/paper/2023/file/79fea214543ba263952ac3f4e5452b14-Paper-Conference.pdf What’s Left?Concept Grounding with Logic-Enhanced Foundation Models]
=== Lecture: visual reasoning: 4. May  ===
The lecture will be given by our postdoc researcher [https://vaishnavmohit.github.io/ Mohit Vaishnav].
[[Media:Visual Reasoning 2026.pdf|Lecture presentation]] <font color="red">E2</font>
Related preprints:
* [https://arxiv.org/pdf/2501.13620 Cognitive paradigms for evaluating vlms on visual reasoning task]
* [https://arxiv.org/pdf/2604.21346 Symbolic Grounding Reveals Representational Bottlenecks in Abstract Visual Reasoning]
=== Lecture: we continue exploring recent papers in neurosymbolic reasoning: 11 May  ===
We look at some of the more interesting papers from each subarea (maybe not all the papers):
Logic focus:
* Neuro-Symbolic Concepts https://arxiv.org/pdf/2505.06191
* Sound and Complete Neurosymbolic Reasoning with LLM-Grounded Interpretations https://arxiv.org/pdf/2507.09751
Visual reasoning:
* MuSLR: Multimodal Symbolic Logical Reasoning https://arxiv.org/pdf/2509.25851
* Can VLMs Reason Robustly? A Neuro-Symbolic Investigation https://arxiv.org/pdf/2603.23867
Planning:
* LLMs as Planning Formalizers: A Survey for Leveraging Large Language Models to Construct Automated Planning Models https://arxiv.org/pdf/2503.18971
* Planning in the Dark: LLM-Symbolic Planning Pipeline without Experts https://arxiv.org/pdf/2409.15915 or newer https://ojs.aaai.org/index.php/AAAI/article/view/34855/37010
* Fast and Accurate Task Planning using Neuro-Symbolic Language Models and Multi-level Goal Decomposition https://arxiv.org/pdf/2409.19250
* See also PDDL https://fareskalaboud.github.io/LearnPDDL/ https://homepages.inf.ed.ac.uk/mfourman/tools/propplan/pddl.pdf
Text-to-SQL:
* SPIDER 2.0: EVALUATING LANGUAGE MODELS ON REAL-WORLD ENTERPRISE TEXT-TO-SQL WORKFLOWS https://arxiv.org/pdf/2411.07763
* CHASE-SQL: Multi-Path Reasoning and Preference Optimized Candidate Selection in Text-to-SQL https://arxiv.org/pdf/2410.01943


=== Third lab ===
=== Consultation for the exam: 18 May  ===


The third lab is <b>optional</b> and will simply give as many points as lab 1 or 2 towards the final result and the grade: practical work 60% and exam 40%.


The task in the third lab is the open-world scenario of answering questions based on wikipedia and using large downloaded rule sets a la yago, wordnet etc with a reasoner.


It is a plus to be able to give uncertain answers (likely, unlikely) and handle fuzzy properties like boy, girl, grownup, rich etc.
<!--
[[Media:Research_in_Neurosymbolic_Reasoning.pdf|lecture slides]]


The lecture will be given by our PhD student [https://aire-edih.eu/meeskond/otto-mattas/ Otto Mättas].
-->
<!--
<!--
=== Lab ideas ===
=== Lecture: visual reasoning  ===
 
The lecture will be given by our postdoc researcher Mohit Vaishnav. You may want to have a look at his [https://vaishnavmohit.github.io/phd_thesis/ thesis] from 2023.


* [[KR lab idea by Priit Järv]]
=== Lecture: third lab live experiments ===


Student ideas are also welcome: have to agree with Tanel first.
We will do live experiments for the third lab.
 
Previous plan was: continue with uncertainty, numeric confidences and probabilities.
 
A [[Media:Confidences_cade28_d.pdf |presentation]] of our [https://link.springer.com/chapter/10.1007/978-3-030-79876-5_29 paper] about implementing numeric confidences. Here are [https://logictools.org/confer/ examples], a binary, etc.
-->
-->
<!--
=== Lecture: continuing with uncertain knowledge ===


== Lecture block 1: basics and representing simple facts. ==
Wider background: [https://en.wikipedia.org/wiki/Non-monotonic_logic non-monotonic logic]


A [[Media:Ijcar_2022_tammet.pdf|presentation]] <font color="red">E2</font> of our [https://link.springer.com/chapter/10.1007/978-3-031-10769-6_18 paper] about implementing [https://en.wikipedia.org/wiki/Default_logic default logic] <font color="red">E1</font>. Here are [https://logictools.org/gk/ examples], a binary, etc.


=== Lectures 1 and 2: Overview of the course. Background and basics: SQL, logic, NLP ===
Additionally, we look at non-montonic logic using [https://swish.swi-prolog.org/example/scasp.swinb s(CASP)] and [https://www.dlvsystem.it/dlvsite/ dlv]. Both are examples of [https://en.wikipedia.org/wiki/Answer_set_programming Answer set programming (ASP)] and related to [https://en.wikipedia.org/wiki/Datalog datalog]. For ASP, have a look at [https://acris.aalto.fi/ws/portalfiles/portal/30223846/SCI_Janhunen_Niemela_The_Answer_Set_Programming.pdf this intro], written by [https://www.aalto.fi/en/people/ilkka-niemela Ilkka Niemelä] who is currently the [https://www.aalto.fi/en/aalto-university/governance-president president (rehtori) of the Aalto University]
-->


Lecture materials:
<!--
* [[Media:Kr_lect_1b.ppt| intro, sql, logic, NLP]]
=== Lecture: Semantic parsing  ===


The focus of the lecture is on [https://en.wikipedia.org/wiki/Semantic_parsing semantic parsing].


=== Lecture 2: RDF and RDFS (and OWL) ===
Here are Martin's slides from 2024 [[Media:KR_2024_Parsing_01.pdf]] <font color="red">E2</font>.


Lecture materials:
We will look at both (a) classic paradigms of semantic parsing (as on the slides), (b) using LLMs and alternative modern paradigms for semantic parsing.
* [[Media:Kr_lect_2b.ppt| schemaless databases, RDF and RDFS]]
* [[Nosql links and notes]]


About important concepts in parsing:
* [https://en.wikipedia.org/wiki/Part_of_speech Part-Of-Speech (POS)] and [https://en.wikipedia.org/wiki/Part-of-speech_tagging POS tagging]
* [https://web.stanford.edu/~jurafsky/slp3/18.pdf Jurafsky&Martin: Constituency Parsing]
* [https://web.stanford.edu/~jurafsky/slp3/19.pdf Jurafsky&Martin: Dependency Parsing]


=== Lecture 3: Intro to homework and NLP ===
Some important toolkits and representation schemes:
* [https://spacy.io spacy], [[a small spacy UD parsing example]]
* [https://stanfordnlp.github.io/stanza/ stanza]
* [https://universaldependencies.org/ universal dependencies]


Lecture materials:
Some draft parsing papers:
* [[Media:Kr_lect_3a.pdf| nlp and watson]]
* [[Media:concepts_draft_paper.pdf|concepts, based on UD]]
* Jurafsky and Manning book: [https://web.stanford.edu/~jurafsky/slp3/slides/convagents1.pdf conversational agents]
* [[Media:pipeline_draft_paper.pdf|pipeline, based on UD]]
* start reading the Jurafsky and Manning book (see links above)
* [[Media:llm_parser_draft_paper.pdf|experiments with LLM usage]]
-->
<!--
=== Semantic parsing continued  ===


Lecture will be given by Martin Verrev on teams only (not the lecture room).


=== Lecture 4: vector representation of words ===
Loenguslaidid (lisatud linkidega): [[Media:KR_2024_Parsing_02.pdf]] <font color="red">E2</font>
-->


Lecture materials:
<!--
* First, [http://lineardigressions.com/episodes/2017/4/23/feature-processing-for-text-analytics text vectorization episode] from the [http://lineardigressions.com/ linear digressions] podcast.
=== Topics in neurosymbolic reasoning and consultation for the exam  ===
* Second, [http://lineardigressions.com/episodes/2018/12/30/re-release-word2vec word2vec episode] from the [http://lineardigressions.com/ linear digressions] podcast.
-->
<!--
Some papers to explore:


* https://ceur-ws.org/Vol-3432/
* https://ceur-ws.org/Vol-3432/paper5.pdf
* https://ceur-ws.org/Vol-3432/paper8.pdf
* https://aclanthology.org/2023.emnlp-main.313.pdf
* https://ojs.aaai.org/index.php/AAAI/article/view/29938/31639
* https://arxiv.org/pdf/2404.12698
* https://proceedings.neurips.cc/paper_files/paper/2023/file/79fea214543ba263952ac3f4e5452b14-Paper-Conference.pdf
* https://proceedings.neurips.cc/paper_files/paper/2023/file/ba90e56a74fd77d0ddec033dc199f0fa-Paper-Conference.pdf
-->




[[Category:Kursus]]
[[Category:Kursus]]

Viimane redaktsioon: 12. juuni 2026, kell 22:19

teadmised
teadmised

Name: Knowlege representation
Code: ITI8700
Link: http://lambda.ee/Teadmiste_formaliseerimine
Lecturer: Tanel Tammet tanel.tammet@ttu.ee ICT-426
Practice sessions: Riina Maigre
Archives of previous years: 2025.

Eksamitulemused

Eksamitulemused siin:

Eksamikonsultatsioon

(a) väike salvestuse teamsi, teemaks siis eksamikorraldus, ülesanded jne:salvestus siin, asub kursuse teamsi-salvestuste kataloogis.

(b) Konsultatsioonide lingid siin:

  • eksamikonsultatsioon 20. mai kell 10:30-11:00. (enne seda, kell 10:00 hajussüsteemide konsultatsioon, tolle kursuse lehel oleval lingil).
  • eksamikonsultatsioon 25. mai kell 10:30-11:00. (enne seda, kell 10:00 hajussüsteemide konsultatsioon, tolle kursuse lehel oleval lingil).

Eksamikorraldus ja materjalid õppimiseks

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.

Allolevad punase E1-ga on eksami jaoks kõige olulisemad materjalid, E2 veidi vähem olulised. NB! Võrreldes varasemaga on lisaks markeeritud E2-ga need varasemalt olemas, aga markeerimata materjalid:

Ekamil tuleb neli eraldi hinnatavat osa: kolm teemaküsimust ja üks osa paari lühiküsimusega. Spetsiifiliste süntaksite (RDF, loogikavarandid jne) osas: ühtegi täpset süntaksit/võtmesõnu ei pea teadma, aga esitus peab olema õppejõule sisuliselt arusaadav. Millised on teemaküsimused ja millised on lühiküsimused:

SQL ja loogika: esitan paar tabelit ja küsin mõnda taolist küsimust:

  • nende sisu võimalikult täpset esitust esimest järku loogikas või RDFs
  • mõne konkreetse where- või join-päringu kirjutamist esimest järku loogikas

JSON-LD: annan JSON-LD jupi ja küsin selle tähendust ehk teisendust RDF kujule kolmikutena.

Reeglite esitamine: pane rdf ja/või rdfs kujule ja/või predikaatloogikale baseerudes kirja etteantud konkreetsed inimkeelsed väited.

Reeglite rakendamine klassikalises teoreemitõestamises: oskus teha käsitsi läbi väike resolutsioonimeetodi rakendamise näide, kui disjunktid ette antud.

Sõnavektorid ja N-grammid ja keelemudelite üldprintsiibid: arusaamine, oskus esitada väike näide töötamise kohta, võimalikud kasutus- või loomisstsenaariumd

Ebakindlate teadmiste esitamise põhimeetodid: pidevad (erinevat sorti tõenäosuste-tüüpi esitus) ja diskreetsed (eranditega süsteemid, eeskätt default logic). Siin võin tuua väikese näite ja küsida lahendust või palun ise esitada mõne pisinäite sobival kujul. Konkreetseid süntakseid teadma ei pea, piisab õppejõule arusaadavaks tegemisest.

Lühiküsimused (siit valitakse iga eksami jaoks paar):

Seleta paari lausega, mis asi on, vahel küsin ka näidet: freimiprobleem, open/closed world, blocks world, RAG, erinevad tõenäosuste interpretatsioonid, RDFa; mis asi on ja mida sealt umbes leida võib ja mida pigem mitte: schema.org, wordnet, conceptnet, yago, cyc; mida sa mäletad "semantiline parsimine" ja "visual reasoning" teemade kohta.

Eksamipäevad ja ajad

Siin on täpsustunud esimese kahe eksami ajad:

  • 27 mai, kolmapäev, kell 11:00 (koos hajussüsteemide eksamiga). Auditoorium NRG-226.
  • 1 juuni, esmaspäev: eraldi eksamiajad hajussüsteemide (11:00) ja teadmiste esitamise (14:00) jaoks. Auditoorium SOC-211a.
  • 8 juuni, esmaspäev: kell 11:00 (koos hajussüsteemide eksamiga). Auditoorium ICT-315.


Time, place, result

Lectures (Tanel): Mondays 12:00-13:30 room SOC 414
Practice sessions (Riina): Tuesdays 08:00-09:30 room MEK-122 MEK-109.

The lectures and sessions will be on site (physical room) plus teams. Later we may decide to do some lectures/practice sessions on teams only: this will be advertised on the page here early. Beware: recording may not always succeed.

Please join the teams group of the course. The code for joining is zb3z457.

Weekly teams link for the lecture.

Weekly teams link for the practice session.

Grading

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 (a) several questions asking for the explanation of important concepts along with examples (b) some small excercises.

The materials below marked with the red E1 are the main materials for the exam (10 of these on the page), while E2 materials (20 on the page) will also come up, but less and/or in a simpler form.

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 neurosymbolic 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

Weekly tasks

The small weekly tasks are in addition to the practical work: their goal is to practice with the stuff presented at the last lecture.

The first weekly task

Ülesanne on eksperimenteerida veidi logictools.org saidiga ja teha ise läbi loengus toodud näited SQL data ja päringute esitamisest loogikas. Tähtaeg 17. veebruar.

Konkreetselt tee järgmist:

  • Eksperimenteeri veidi logictools.org "simple examples" valikuboksi näidetega basic ... equality, loe nende selgitusi ja püüa aru saada tõestustest.
  • Loe seejuures predikaatloogika väikest seletust about lehel kuni lausearvutuseni (seda pole enam otse vaja lugeda).
  • Kirjuta ise valmis näide vastavalt kursuse materjalile Background: relations of sql and logic lk pealkirjaga "SQL join as logical rule", kus on toodud ühe client tabeliga ja client ning cars tabelitega näide sql päringute teisendamisest loogikasse (üks lihtne select ja üks join):
client table: id name balance
1 john 100 
2 pete -200

cars table: id model owner
1 ford 1
2 opel 2
3 saab 2

select client.name, client.balance
from client where balance<0

select client.name, cars.model from client, cars
where client.id=cars.owner

Tee need näited reaalselt valmis nii, et logictools.org sööb nad sisse ja annab ootuspärase vastuse. Seejuures on sul vaja kasutada $ans predikaati, nagu "answers" näites toodud. Kui tahad mitut vastust (ei ole kohustuslik), siis vaata ka "multiple answers" näidet.

  • Saada näite-sisendid ja genereeritud tõestused õppejõule emailiga (riina.maigre at taltech.ee ja cc tanel.tammet at taltech.ee). Kui jääd nendega hätta, siis kirjuta, mida proovisid, too oma näitetekst ja selgita, mille juures hätta jäid (see on ka arvestatav tulemus): kirjuta aadressile riina.maigre at taltech.ee või tanel.tammet at taltech.ee ja pane pealkirja sisse mh sõna "formaliseerimine", et kirja kergesti üles leiaks.
  • Kasuta kindlasti oma taltech.ee aadressi, sest muidu võib kiri lõpetada rämpspostis!

Soovitused:

  • 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).
  • Aritmeetika jaoks vaata help teksti Arithmetic peatükki.
  • Väiksem-tingimuse jaoks vaata complex examples valikuboksis "arithmetic" näidet.


The second weekly task

Selle ülesande mõte on veidi praktiseerida JSON-LD esitusega. Sinu konkreetne ülesanne on võtta oma esimene nädalaülesanne ja esitada needsamad andmed (ja soovitavalt ka reeglid) JSON-LD kujul.

Vaata alustuseks json-ld näiteid logictoolsi json-tabi alt. NB! Enamus näiteid "example" valikuboksist ei ole konventsionaalne json-ld, aga mitmed on.


Practical work

There are three labs.

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

The 2026 task for the first lab is about encoding nontrivial information in various ways (standard logic, rdf, json-ld) and writing simple logical rules for answering questions.

Deadline: 10. March.

Second lab

The 2026 task for the second lab is about using a VLM (visual language model) to get a structured description from an image which would fit with the pre-existing simple world model.

Deadline: 7. April

Third lab: questions in NLP

This is the task for 2026:

Experiment with neurosymbolic reasoning: LLM as a parser plus a symbolic reasoner for images: 2026

Deadline: 12. May


Books to use

Main materials:

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 (hopefully) freely accessible pdf-s via Taltech. See also slides for the book.
  • 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. 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

The details and materials of lectures in the future are from 2025 and will be revised/extended. The materials of the current or passed lectures are up to date.


Block 1: knowledge in SQL, RDF and JSON

Lecture: Intro and background: 2. February

Intro presentation:

teadmised_intro2026.pdf

Recommended non-obligatory listening: Francois Chollet, Yann LeCun, Gary Marcus, Demis Hassabis, Ilya Sutskever, Ben Goertzel ,

Lecture: Nosql, json and rdf in databases: 9. February

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 + reasoner: 16. February

Rdf example developed during lectureE2

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:

What the reasoner does:

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

Lecture: DPP ontology development. 2. March

Loengu annab Riina. Digital Product Passport (DPP) kui näide praktilisest ontoloogia/sõnastiku arendamisest CIRPASS projektis.

Hetkeseisu algusleht.

CIRPASS-2

Ühikute ontoloogia

SHACL

UNTP DPP



Lecture: Next homework and looking into main large knowledge bases: 9. March

We will first present the next homework.

Then we will continue with existing large knowledge bases.

Slides:lecture slides E2, a tool to explore Wordnet taxonomies can be found here: https://github.com/martinve/wntool

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.

About knowlege base creation using LLMs: have a look at this paper.

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


Block 3: natural language and question answering

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

Lecture: large language models (LLM) 23 March


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 11 märtsi loengus.

Mida vaadata ja lugeda:

Eriti soovitav

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.

Pikemaks lugemiseks:


Optsionaalselt üldisem arusaam klassikutelt:

Optsionaalselt diipim arusaam:

Lecture: RAG usage pattern / context engineering for LLMs : 30 March

Lecture material: this is focused on RAG and written in 2024 and spring 2025: good tool use, good reasoning and more autonomy like claude code and openclaw are not covered in this overview.

"Context Engineering" became a popular phrase in 2025: essentially it means "fancy RAG", i.e. significant effort put towards creating a really good set of additional information (prompt additions: "context") for each user query/prompt. It can also mean approaches for storing such additional information on the fly in special files which are then used RAG-like as extra input in addition to user dialog.For example, claude code memory principles and memory folder structure, openclaw memory.

Useful reading in addition to pointers in the lecture material:

Block 4: hybrid systems and uncertain knowledge

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

Lecture: issues in formalizing commonsense reasoning: open/closed world, frame problem, uncertainties: 6. April

First, open/closed world, world states, 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: 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. The simplest way to experiment is to use https://logictools.org/ . There is already a blocks world example available.

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.


Second, uncertainty


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. In particular, Wiki on Bayesian inference and this
  • Skim through the later parts and look only into these subchapters which you found interesting.

Next,

  • Read the paper E2 about confidences. containing intro, algorithms and experiments. Then look at the web page with the confer reasoner and a wealth of examples.
  • Read the paper E2 about exceptions (default logic). containing intro, alorithms and experiments. Then look at the web page with the gk reasoner and a wealth of examples.

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

Lecture: research in neurosymbolic reasoning: 13 April

lecture slides

The lecture will be given by our PhD student Otto Mättas.

Lecture: semantic parsing with LLMs and with UDP: 20 April

The focus of the lecture is on semantic parsing.

For a quick intro we will use Martin's slides from 2024 semantic parsing E2.

The rest of the lecture will explain stuff in nlpsolver. See the nlpsolver presentation.

Useful background:

About important concepts in parsing:

Some important toolkits and representation schemes:

Some draft parsing papers:


Lecture: we explore some recent papers in neurosymbolic reasoning: 27 April

A reading session: we will read and attempt to understand together some case studies.

Lecture: visual reasoning: 4. May

The lecture will be given by our postdoc researcher Mohit Vaishnav.

Lecture presentation E2

Related preprints:

Lecture: we continue exploring recent papers in neurosymbolic reasoning: 11 May

We look at some of the more interesting papers from each subarea (maybe not all the papers):

Logic focus:

Visual reasoning:

Planning:

Text-to-SQL:

Consultation for the exam: 18 May