• Aucun résultat trouvé

Finding Optimal Probabilistic Generators for XML Collections

N/A
N/A
Protected

Academic year: 2022

Partager "Finding Optimal Probabilistic Generators for XML Collections"

Copied!
21
0
0

Texte intégral

(1)

Finding Optimal Probabilistic Generators for XML Collections

Serge Abiteboul, Yael Amsterdamer, Daniel Deutch, Tova Milo, Pierre Senellart

BDA 2011

(2)

Adding probabilities to an XML Schema

• The Web is full of semi-structured documents

• Given a collection of XML documents, we would like to have a schema the documents conform to.

– E.g., DTD or XSD

– Restricts the structure, mostly parent-child node relations (using regular expressions)

• The schema may be very general (e.g., xhtml, RSS)

• We want to add probabilities to 'guide' the schema

– Optimal probabilities – maximize the likelihood of a corpus

Motivation

(3)

Implementation Idea: XML Editor Auto-Completion

• Based on previous document versions / corpus of user

documents / corpus of example documents –

• Suggest nodes / sub-trees / node values to the user

• For example:

Challenges:

– Allow editing in every part of the document

– What kind of completion to suggest?

– Finding the top-k best completions

Motivation

<MyPapers>

<Paper>

<title>Provenance Minimization</title>

<author>Yael A.</author>

<author>Daniel D.</author>

<author>Tova M.</author>

<author>Val T.</author>

</Paper>

<Paper>

<title>Provenance for Aggregates</title>

<author>Yael A.</author>

<author>Daniel D./author>

<author>Val T.</author>

</Paper>

<Paper>

<title> </title>

<author> </author>

<author> </author>

<author> </author>

(4)

Many Other Usages for a Probabilistic Schema

Testing – e.g., generating many XML messages to simulate network load and test system performance.

Explaining – e.g., the probabilistic schema for DBLP shows which types of publications are rarely used, which kinds of attributes are not filled for BibTex, etc.

Querying – e.g., finding the probability that a paper has more than 3 authors.

– e.g., finding the top-k best completions to a partial document.

Schema Evaluation – how well a given schema describes a given corpus.

Motivation

(5)

Our solution - An Outline

Preliminaries – Tree Automata

Generators for Schemas without Constraints

Restart Generators

Continuation-Test Generators Leaf Values

Adding Constraints

(6)

Using a Tree Automaton for Schema Verification

Preliminari es

q

0

b q

1

q

2

a c

$

An XML document is

modeled as an ordered tree.

Document d 0 :

The children of a-labeled node are accepted by

DFA A a

Automaton A r : (L(A

r

) = a*bc*$)

This is done for every inner node in a fixed order (BF-LTR)

abcd 532 abcd

$

r

a b c

(7)

Using the Schema as a (Probabilistic) Generator

• Each transition is assigned a probability

• We assume independent choices, thus the document probability is the product of all t-probs.

• Thus, PR( d )=p a ∙ p a ∙ p b ∙ p $

• The schema and generator ignore leaf values (for now!) Without

Constraints

b

a c

$ $

p a p c p b p $

q

0

q

1

q

2

r

a a b

(8)

An Algorithm for Probabilities Learning

Without Constraints

b

a c

$

$

The frequency each transition is chosen during the corpus verification process is recorded.

(q

0

, a) (q

0

, b) (q

1

, c) (q

1

, $)

1 1 1

1 q 0 q 1 q 2

r

a b c

(9)

An Algorithm for Probabilities Learning (Cont.)

This is repeated for every node in every corpus document.

We set the probability of each transition to be its relative frequency.

Without Constraints

(q

0

, a) 1 (q

0

, b) 1 (q

1

, c) 1 (q

1

, $) 1

/2 /2 /2 /2

These probabilities maximize the likelihood of generating the corpus – optimal generator

(similar result in PCFGs)

(10)

Our Results

• Relative frequencies make optimal probabilities.

• Optimal probability learning and document generation can be done efficiently.

• Additional non-trivial result:

Generation terminates with probability 1.

– Guaranteed because of the choice of probabilities according to the corpus.

Without

Constraints

(11)

Integrity Constraints

• We want to allow the use of the following constraints in the schema:

Key Constraint: the leaves of a-labeled leaves have unique values (unary key)

Inclusion Constraint: the values of a-labeled

leaves are contained in those of b-labeled leaves – Domain Constraint: the values of a-labeled leaves

belong to some (finite or infinite) domain

Adding

Constraints

(12)

Restart Generators

• A naïve idea:

– Use a probabilistic generator to generate a document

– Check if it has a value assignment valid w.r.t. the constraints – If not, 'restart' and try again until a valid document is

generated

Good news: Checking the existence of a valid assignment is in PTIME

Bad news: number of restarts can be unboundedly large in an optimal generator

– A different quality measure for restart generators?

Adding

Constraints

(13)

Continuation-test Generators

• Never make choices that lead to a 'dead end', thus always generate a valid document.

• We use a binary test to check if a choice has a continuation.

• Add to the schema of d

0

the constraints:

c is included in ac is unique

• The generation process:

Adding Constraints

b

a c

$ $

p a p c

p p

q

0

q

1

q

2

r

a b c

Pr( d ) = p a ∙ p b ∙ p c ∙1

Perform a continuation-test before taking the

transition

Implies |

c|≤|a|

(14)

Algorithm for Learning

Probabilities with Constraints

• The probabilities are again relative frequencies, but –

only in cases where there was an alternative choice.

• The learned generator will generate as many c-s as a-s Adding

Constraints

(q

0

, a) 1 (q

0

, b) 1 (q

1

, c) 1 (q

1

, $) 0

/2 /2 /1

/1 (q

1

, $) was chosen

only when (q

1

, c)

was not available.

(15)

Our Results

• The algorithm learns an optimal continuation-test generator, for automata with binary choices.

– Extensions to non-binary are discussed in the paper

Bad News: Continuation-test is NP-Complete

– But only in the size of the schema; it is polynomial in the document size (not so bad?)

– Based on schema satisfiability test [David et al. 2011]

More Bad News: probability of termination may be arbitrarily small!

– Even for simple, non-recursive schemas

– Can be handled by adding a constraint on the document size.

– Sub-classes of schemas that guarantee termination?

Adding

Constraints

(16)

Suggested Algorithm

• We start with a valid document skeleton

• Order labels by inclusion constraints (e.g., c, b, a)

• Choose a leaf from the 'smallest' (most included) label, and including leaves

• Draw a value (from the domain) according to a given distribution.

• Use PTIME test to verify validity, if not revert the step

Leaf Values

$

r

a b c

abcd

abcd efg

(17)

Possible improvement to the basic algorithm

• Annotate the leaves with 'old' or 'new'

• For 'old' a-labeled leaves choose values already chosen for some a-labeled leaf

• For 'new' choose a value unused by a-labeled leaves yet

• Annotations can be learned from the corpus, and generated:

Offline – after the document generation, using a PTIME validity testOnline – during document generation, using a continuation test.

– Both methods are incomparable in terms of quality

Leaf Values

new old new $

r

a a b

(18)

Ideas for Experimental Study on Probabilistic generators

• How many schemas in practice may require continuation tests?

• How many have termination probability < 1?

• Continuation test is expensive, but how expensive is it in practice?

• 'Competition' between restart and continuation-test generators

• More?

Implementati

on

(19)

Thank You!

Thank You!

Questions, Ideas?...

Références

Documents relatifs

is a Choquet simplex and any two distinct extremal points ofjf^ are disjoint measures (see [i], Lemma 2).. This concludes the proof

Let M be a compact complex manifold with a Hermitian metric, T a holomorphic foliation by curves with isolated singularities, such that at each singular point the foliation is

In order to obtain maximal yield of pruned leaves, a single objective optimal control problem was first formulated based on the functional-structural plant growth model GreenLab

Cette intégration à bas âge dans l’espace se fait par le lien familial qui existe entre les travailleurs et/ou entre leurs parents qui sont propriétaires des

There is a deformation retraction from Ub to Ub,R obtained by making points flow in the positive or negative imaginary direction until reaching Ub,R.. The fact that v

— Let G 1 be the graph with only isolated vertices, then the most distant graph to it is the bipartite graph with n/2 disconnected edges if α &lt; 1, the set of all graphs without

Notre méthode dans ce travail c'est établir un pont qui relatif le visuel. avec le non visuel cherchant

In this paper, we will describe our progress towards building a digital col- lection of the Smithsonian’s type specimens, developing recognition algorithms that can match an image of