learning context-free grammars - université de...

108
1 Learning context-free grammars Colin de la Higuera University of Nantes

Upload: vothuy

Post on 15-Dec-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

1

Learning context-free grammars

Colin de la HigueraUniversity

of Nantes

Page 2: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

2

AcknowledgementsLaurent Miclet, Jose Oncina and Tim Oates for previous versions of these slides.Rafael Carrasco, Paco Casacuberta, Rémi Eyraud, Philippe Ezequel, Henning Fernau, Thierry Murgue, Franck Thollard, Enrique Vidal, Frédéric Tantini,...List is necessarily incomplete. Excuses to those that have been forgotten.

http://pagesperso.lina.univ-nantes.fr/~cdlh/slides/

Chapter 15

Page 3: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

3

Outline

1.

Context-free grammars2.

Paradigms and theorems

3.

Some heuristics4.

Applications

5.

Conclusions

Page 4: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

4

1. Context free grammars

Page 5: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

5

What is a context free grammar?A 4-tuple (Σ, S, V, P) such that:

Σ is the alphabetV is a finite set of non terminalsS is the start symbolP ∈ V × (V∪Σ)* is a finite set of rules

Page 6: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

6

Example

The Dyck1

grammar(Σ, S, V, P)Σ = {a, b}V = {S}P = {S → aSbS, S → λ }

Page 7: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

7

Derivations and derivation trees

S → aSbS→ aaSbSbS→ aabSbS→ aabbS→ aabb

a

a

b

b

S

SS

S

S

λ

λ

λ

Page 8: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

8

Why learn context free grammars (CFG)?

More expressive than regular grammars: all regular languages are context-freenext step up on the Chomsky hierarchyallows to define more precise and expressive structure

Page 9: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

9

Tree Grammars

Similar to CFG

but the rules have the shape:

A →a

B C …

Page 10: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

10

Example

Let P = { S → a, S →

, S →

}

+

a *

a a

+

S *

S S

+

S S

S

+

S S

*

S S

Page 11: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

11

Skeletons and tree grammars

Any context free grammar can be transformed into a tree grammar that produces skeletons

A tree automaton:

S →

λ

S → σ

a S b S

S → σ

S →

aSbS

Page 12: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

12

Theory

It is made harder by the hardness of various problems over CF

grammars:ExpansivenessAmbiguityUndecidability of the equivalence problem

Présentateur
Commentaires de présentation
No se a que te refieres con que aprender de solo muestras positivas es “hard”. Si te refieres a aprendr CFG es imposible!!
Page 13: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

13

Expansiveness

T0 → T1

T1

+...T1 → T2

T2

+...

Tn

→ a

LG

(T0

)={a2n}

String

a2n is probable

but

very long. What about complexity?

Page 14: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

14

Ambiguity

S → S*S, S → a, S → b

Where does a*b*b come from?Do we really want to learn languages?

Page 15: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

15

Equivalence problem revisited

When trying to learn a grammar, are we not attempting to find some normal form?Does that not seem difficult when the equivalence problem is undecidable?

Page 16: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

16

Practical issues: parsing

CYK, complexity: O(n3)

Earley, complexity: O(n3)

Valiant, complexity: O(n2.81)

Page 17: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

17

2. Paradigms and results

Page 18: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

18

Identification in the limitThe examples are provided in sequenceFor each new example the learning algorithm must provide a hypothesisSuccess if the sequence of hypotheses converges

Présentateur
Commentaires de présentation
Añadir un dibujo
Page 19: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

19

Learning from positives examples

It is impossible to identify in the limit any super-finite class of language from positive examples only (Gold, 67)A super-finite class of languages includes:

all the finite languages and at least an infinite language

Page 20: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

20

What can we do?

Use of some additional help:negative dataaccess to oraclesknowledge of the structurebelief there is a structured distribution

Avoid super-finite classes of languagesCombinations of both ideas

Page 21: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

21

Can we learn in the limit context-free

languages from …Complexity does not matter!

Page 22: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

22

... positive examples?

NO (Gold, 67)the class of context free languages is super-finite

Page 23: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

23

... positive and negative examples?

YES (Gold, 67)by an enumeration procedure:

1.

order all the CFG in a list2.

search the list and return the first grammar consistent with the data

Complexity is O(⏐V⏐⏐P⏐⏐V⏐

)

Page 24: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

24

... skeletons of positive examples?

NO, as a consequence of (Gold, 67)the class of the tree languages that represent skeletons is super-finite

YES, (Sakakibara, 92)

if the skeletons come from a reversiblecontext free grammar (normal form)

Page 25: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

25

Important!

In the first case we want to identify a grammar that matches a set of treesIn the second case we will need trees that conform to the unknown grammar

Crucial question… what are we learning? Grammars or languages?

Page 26: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

26

Reversible context free languages

Deterministic bottom-up / top-downA → α and B → α ⇒ A=BA → αBβ and A → αCβ ⇒ B=CAlgorithm

Build the grammar that only accepts the sampleMerge pair of non terminals that violate some of the previous rules

Page 27: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

27

... queries?

Not well known!The most used queries are:

Membership queriesEquivalence queries

Note that an equivalence query might be non computable.

Queries are usually introduced to deal with complexity issues…

Présentateur
Commentaires de présentation
¿Donde?
Page 28: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

28

Polynomial identification

There are several definitions:(Pitt, 89) and (Yokomori, 91)

Polynomial update timePolynomial number of hypothesis changesPolynomial number of implicit prediction errors (Yokomori)

In polynomial time and data (cdlh, 97)Polynomial update timePolynomial characteristic sample

Page 29: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

29

Can we learn polynomially in the limit context free

languages from …

Page 30: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

30

... positive and negative examples?

NO,if usual cryptographic rules apply(Pitt and Warmuth, 88)

In the polynomial time and data

framework, context-free and linear*

languages are not

identifiable (cdlh, 97)

* the rules have the shape: A → vBw, A → v

Page 31: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

31

… positive skeletons?

YES,provided that the grammar is written in reversible normal form (Sakakibara, 92)even though the regular languages are not identifiable from positive skeletons!!!

Page 32: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

32

... positive and negative skeletons?

YES,it is a special case of learning tree grammars from positive and negative examples (García

& Oncina, 93 )

Page 33: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

33

... positive skeletons and negative examples?

YESwith a slight modification of the previous algorithm

Page 34: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

34

... the knowledge that the distribution is given by a stochastic context-free grammar?

There is not even a sensible definition of what this can beThe number of examples should be very large in order to have information about the existence of a rule with a very low probability

Page 35: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

35

... And if we have the grammar also?

Not known! There are some heuristics...

Expectation maximizationInside-Outside

Page 36: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

36

… queries?

YES, provided the grammar is written in reversible normal form

(Sakakibara, 90) NO,

in general

Page 37: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

37

Can we learn polynomially in the limit some

subclasses of context-free languages from …

Page 38: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

38

... positive examples?Subclasses of even linear languages(Takada, 88), (Sempere

& García, 94),

(Mäkinen,96)Rules with shape A → aBb + a +λThe trick is to transform A → aBb into A →[ab]B, then we have a regular language

Very simple grammars (Yokomori, 91)Rules with shape A → a + aB + aBCGlobally deterministic in “a ”

Page 39: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

39

... positive and negative examples?

Even Linear Languages (Takada, 88), (Mäkinen, 96), (Sempere

& García, 94)

Same trick as in the previous slideLinear Deterministic Languages (de la Higuera

& Oncina, 02)

Rules of shape A → aBv +λA → aBv rules deterministic in a

Page 40: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

40

... positive skeletons?

Some classes transposed from regular languages to tree languages and then to context free

k-testable tree languages (Knuutila, 93)(Fernau, 02)(Ishizaka, 89)(Yokomori, 91)

Présentateur
Commentaires de présentation
Habría que mencionar cuales son las calses que identifican Fernau, Ishizaka y Yokomori.
Page 41: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

41

... a distribution?

Stochastic Deterministic Linear Languages(de la Higuera

& Oncina, 03)

Identification of the structurePolynomial update time

Présentateur
Commentaires de présentation
¿Porqué no hace bien la guionización?
Page 42: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

42

... Queries?

Simple Deterministic Languages(Ishizaka, 89)

Grammar:rules with shape A → a + aB + aBCdeterministic in “a”

Queries:membership queriesextended equivalence queries

Page 43: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

43

Can we PAC learn context free

languages from …

Page 44: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

44

… positive and negative examples?

NO,If usual cryptographic rules apply:(Kearns & Valiant, 94)

Page 45: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

45

… positive examples?

NO,a consequence of the previous result

Page 46: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

46

… positive skeletons?

NO,because regular languages cannot be learned …

Présentateur
Commentaires de présentation
¿Estas seguro de esto? En el caso de cadenas no pasa si restringimos el típo de esqueletos.
Page 47: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

47

… positive skeletons and negative examples?

probably NO,if usual cryptographic rules applyIt should be a direct consequence of (Kearns & Valiant, 94)

Page 48: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

48

3 “Pragmatic” Learning

Many different ideas:Incremental learningMDL principleGenetic/evolutionary algorithmsReversing the parserTree automata learningMerging

Page 49: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

49

3.1 SEQUITUR

(http://sequitur.info/)(Neville Manning & Witten, 97)

Idea: construct a CF grammar from a very long string w, such that L(G)={w}

No generalizationLinear time (+/-)Good compression rates

Page 50: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

50

Principle

The grammar with respect to

the string:Each rule has to be used at least twiceThere can be no sub-string of length 2 that appears twice

Page 51: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

51

Examples

S→abcdbc

S→AbAabA →aa

S →aAdAA →bc

S→aabaaab

S→AaAA →aab

Page 52: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

52

abcabdabcabd

Page 53: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

53

In the beginning, God created the heavens and the earth.

And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.

And God said, Let there be light: and there was light. And God saw the light, that it was good: and God

divided the light from the darkness. And God called the light Day, and the darkness he

called Night. And the evening and the morning were the first day.

And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.

And God made the firmament, and divided the waters which were under the firmament from the waters which were above the firmament: and it was so.

And God called the firmament Heaven. And the evening and the morning were the second day.

Page 54: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

54

Page 55: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

55

appending a symbol to rule Susing an existing rulecreating a new ruleand deleting a rule

Sequitur options

Page 56: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

56

Results

On text:2.82 bpccompress 3.46 bpcgzip 3.25 bpcPPMC 2.52 bpc

Page 57: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

57

3.2 Using a simplicity bias (Langley & Stromsten, 00)

Based on algorithm GRIDS (Wolff, 82)

Main characteristics:MDL principleNot characterizableNot tested on large benchmarks

Page 58: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

58

Two learning operatorsCreation of non terminals and rules

NP →ART ADJ NOUNNP →ART ADJ ADJ NOUN

NP →ART AP1NP →ART ADJ AP1AP1 → ADJ NOUN

Page 59: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

59

Merging two non terminalsNP →ART AP1NP →ART AP2AP1 → ADJ NOUNAP2 → ADJ AP1

NP →ART AP1AP1 → ADJ NOUNAP1 → ADJ AP1

Page 60: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

60

Scoring function: MDL principle: ⎪G⎪+Σw∈T ⎪d(w)⎪Algorithm:

find best merge that improves current grammarif no such merge exists, find best creationhalt when no improvement

Page 61: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

61

Results

On subsets of English grammars (15 rules, 8 non terminals, 9 terminals): 120 sentences to convergeon (ab)*: all (15) strings of length ≤ 30on Dyck1: all (65) strings of length ≤ 12

Page 62: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

62

3.3 Context free grammar induction with genetic/ evolutionary algorithms

(Wyard, 91)(Dupont, 94)(Kammeyer & Belew, 96)(Sakakibara & Kondo, 99)(Sakakibara & Muramatsu, 00)

Page 63: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

63

Main issue

Encoding a context free grammar as a string such that after crossovers and mutations the string is still a grammar...Some ideas:

Fill up with junk dna: (Kammeyer & Belew, 96)A grammar is a partition. Encode the partition

Page 64: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

64

{1,2,6}{3}{4,5}{7,9}{8} 112331454

112341454{1,2,6}{3}{4}{5,7,9}{8}

Page 65: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

65

3.4 Reversible CFGs

Definition:

A context-free grammar is reversible if the following two conditions hold.

Page 66: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

66

The First Condition

Regular grammarsIf there exist productions of the form A aB and A aC then B = C.

Context-free grammarsIf there exist productions of the form A aBb and A aCb then B = C.

Page 67: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

67

The Second Condition

Regular grammarsIf there exist productions of the form A a and B a and there exists a string v that is a k-leader of both Aand B then A = B

Context-free grammarsIf there exist productions of the form A a and B a then A = B

Page 68: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

68

Sakakibara’s K-RI Algorithm

Given: a sample of strings S in the language of some reversible context-free grammar and their unlabeled derivation trees

Identify: the smallest reversible context-free language containing S

Page 69: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

69

Labeled Derivation Trees

Sa A

bAba

Page 70: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

70

Unlabeled Derivation Trees

?a ?

b?ba

Page 71: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

71

Labelling UDTs

Sa N1

bN2

ba

Page 72: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

72

Converting to Productions

Sa N1

bN2

ba

S a N1

N1 N2 bN2 a b

Page 73: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

73

Sakakibara’s RC Algorithm

G ←

empty context-free grammarfor each UDT in sample

assign non-terminal N to root nodeassign unique NT names to all other nodesconvert to list of productions and add to G

while G violates either condition for reversibility

merge any pair of non-terminals causing a violation

return G

Page 74: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

74

An Example?

a

b

λ

b

b

λ

b

?

a

a

b

λ

?

?

?

?

?

?

?

?

?

λ

?

Page 75: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

75

S

a N5

b N6

λ

S

b N7

b N8

λ

S

b N4

λ

S

a N1

a N2

b N3

λ

Page 76: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

76

S a N1

N1 a N2

N2 b N3

N3 λ

S a N5

N5 b N6

N6 λ

S b N7

N7 b N8

N8 λS b N4

N4 λ

Page 77: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

77

S a N1

N1 a N2

N2 b N3

N3 λ

S a N5

N5 b N6

N6 λ

S b N7

N7 b N8

N8 λS b N4

N4 λ

Page 78: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

78

S a N1

N1 a N2

N2 b N3

N3 λ

S a N5

N5 b N3

S b N7

N7 b N3S b N3

Page 79: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

79

S a N1

N1 a N2

N2 b N3

N3 λ

S a N5

N5 b N3

S b N7

N7 b N3S b N3

Page 80: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

80

S a N1

N1 a N2

N2 b N3

N3 λ

S a N5

N5 b N3

S b N3

N3 b N3

Page 81: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

81

S a SS b N3

N3 b N3

N3 λ

L(G) = a*b+

Page 82: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

82

S a SS b N3

N3 b N3

N3 λ

L(G) = a*b+

Page 83: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

83

S a SS b SS λ

L(G) = {a, b}*

Page 84: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

84

Claim 1

Given a set of strings S from a zero- reversible regular language, RC(S) =

K-RL(S)

Page 85: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

85

K-Reversible Context-Free Grammars

Definition:

The k-ancestors of non- terminal A are the non-terminals that

can derive a string containing A in exactly k stepsDefinition:

The k-contexts of non-

terminal A are the strings that can be derived from the k-ancestors of A in k

steps augmented with their unlabeled derivation trees

Page 86: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

86

Definition:

A context-free grammar is k- reversible if the following two conditions

hold1)

If there exist productions of the form A aBb and A aCb then B = C

2)

If there exist productions of the form A a and B a and there exists a string b that is a k-context of both Aand B then A = B

K-Reversible Context-Free Grammars

Page 87: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

87

The KRCFG AlgorithmG = empty context-free grammarfor each UDT in sample

assign non-terminal S to root nodeassign unique NT names to all other nodesconvert to list of productions and add to G

while G violates either condition for k- reversibility

merge any pair of non-terminals causing a violation

return G

Page 88: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

88

Analysis

Theorem 1:

KRCFG performs the least amount of generalization (i.e. merging) required to ensure that the grammar it returns is k-

reversible

Complexity:

O(m k+c1

* n k+c2)• m = number of productions in original grammar• n = number of non-terminals in original grammar• c1

, c2

are small

Page 89: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

89

4 Applications

Computational BiologyProgram synthesis, ILP, compiler constructionLanguage models, speech & NLPDocument structure, XML

Page 90: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

90

4.1 Secondary structure predictions

Why: find the secondary structureConcept: a CF grammarData: long tagged strings over a small alphabet: (RNA)Difficulties:

only positive data : restrict to a subclass of CF grammars, or use stochastic CFgrammars

Bibliography: Sakakibara et al. 94, Abe & Mamitsuka 94

Page 91: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

91

Page 92: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

92

Combining stochastic CFGs and n-grams over RNA sequences (Salvador & Benedi 2002)

CFGs to learn the structure and long term dependenciesbigrams for the local relations (non structured part)Sakakibara’s algorithm (minimum reversible consistent CFG)Probablity estimation (inside-outside)

Page 93: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

93

4.2 Inductive logic programming

Why: learn recursive programsConcept: tree automata and grammarsInput: a transformation of examples and background knowledge into strings (SLDrefutations, or terms)

Page 94: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

94

Difficulties:getting the first order information into strings/treesregular grammars are very restrictednumeric datapost-transformation into a logic program

Bibliography: Merlin, GIFT (Böstrom, 95 & 96, Bernard & cdlh, 99)

Page 95: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

96

GIFT architecture of the system

ObservationsObservationsEE++ EE--

Background Background knowledgeknowledge

Set of Set of termsterms

ExpertExpert(Set of rules)(Set of rules)

Tree Tree automatonautomaton

Logic ProgramLogic Programstack(Arg1) :-

start(Arg1,X), p7(Arg1,X).

start(X,X).p7(Arg1,[X|L]) :-

p3(Arg1,X), p6(Arg1,L).

p7(Arg1,[X|L]) :-p5(Arg1,X),p6(Arg1,L).

p7(Arg1,[X|L]) :-p3(Arg1,X),p7(Arg1,L).

p3(Arg1,Obj) :-

shape(Obj,square).p5(Arg1,Obj) :-

shape(Obj,triangle).

p6(Arg1,[]).

Set Set of typed termsof typed terms

Page 96: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

97

4.3 Natural Language Processing

Page 97: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

98

System EMILE (version 4.1.6, 2003) Marco Vervoort / Pieter Adriaans

Entity Modeling Intelligent Learning EngineA context/expression pair is a sentence split into 3 parts: John (makes) tea.

makes is an expressionJohn (.) tea is a context.

Identifying contexts, expressions is what EMILE is about. How? Through clustering algorithms

Page 98: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

99

An examplethe fox jumped. the dog jumped.the quick brown fox jumped.the lazy dog jumped.the fox jumped over the dog.the dog jumped over the fox.the quick brown fox jumped over the dog.the lazy dog jumped over the fox.the fox jumped over the lazy dog.the dog jumped over the quick brown fox.the lazy dog jumped over the quick brown fox.

Page 99: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

100

Result of Emile

[0] [18] dog jumped .[0] the [4] jumped .[0] [18] dog jumped over the [4] .[0] the [4] jumped over [18] dog .[4] fox[4] quick brown [4] [18] the [18] the lazy

Page 100: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

101

System ABL

(van Zaanen, 00…)

Uses alignments for grammar constructionSystem for unsupervised learning

Page 101: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

102

4.4 Structured documents: XML

Extract XML schema (Chiidlovski

200x)

<book><part><chapter><sect1/><sect1><orderedlist

numeration="arabic">

<listitem/><f:fragbody/></orderedlist></sect1></chapter></part></book>

Page 102: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

103

DTDCopied from http://www.vervet.com/

<!DOCTYPE NEWSPAPER [<!ELEMENT NEWSPAPER (ARTICLE+)> <!ELEMENT ARTICLE (HEADLINE,BYLINE,LEAD,BODY,NOTES)> <!ELEMENT HEADLINE (#PCDATA)> <!ELEMENT BYLINE (#PCDATA)> <!ELEMENT LEAD (#PCDATA)> <!ELEMENT BODY (#PCDATA)> <!ELEMENT NOTES (#PCDATA)><!ATTLIST ARTICLE AUTHOR CDATA #REQUIRED> <!ATTLIST ARTICLE EDITOR CDATA #IMPLIED> <!ATTLIST ARTICLE DATE CDATA #IMPLIED> <!ATTLIST ARTICLE EDITION CDATA #IMPLIED><!ENTITY NEWSPAPER "Vervet

Logic Times">

<!ENTITY PUBLISHER "Vervet

Logic Press"> <!ENTITY COPYRIGHT "Copyright 1998 Vervet

Logic Press">]>

Page 103: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

104

5 Conclusion

Theoretical hardness of the polynomial time learning issuesdeterminism and linearity seem to play a strong partalgorithms and heuristics are based on very clever ideasnot enough comparable work

Page 104: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

105

Perspectives

TasksBenchmarksPrototypesClearly identifiable open problems

Bottlenecks

Page 105: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

106

Benchmarks, some features that one expects...

Small/large/very large alphabets (2, <20, x0 000)All grammars/simple grammars Languages or grammars (normal forms?)Size

of data setof grammars

No help (only positive data)/some help:SkeletonsPartial structureDistribution

Noise/no noiseRecognition/tolerance

Page 106: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

107

Prototypes

Avoid having a repetition of the DFA/stochastic DFA situation: no fixed RPNI/Alergia arounddistribution of implementations is a necessitydistributing your algorithm means extra references!!!

Page 107: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

108

Open problems (1)Limits of learning from polynomial data? Comparison between modelsA plausible model for polynomial identification with probability 1 or something related to this…Find a problem solvable on strings for DFA but not solvable on skeletons for CFGs/tree automata

Page 108: Learning context-free grammars - Université de Nantespagesperso.lina.univ-nantes.fr/~cdlh/Downloads/Context_free_Zadar.pdf · No se a que te refieres con que aprender de solo muestras

109

Open problems (2)Provide an algorithm for the case of learning a stochastic CF grammar from stringsIntegrate the categorical grammars into the pictureLearn deterministic linear grammars (i.e.one turn deterministic push-down automata)