You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@opennlp.apache.org by Rupert Westenthaler <ru...@gmail.com> on 2012/05/21 13:49:51 UTC

POS Tagger Probability changes between OpenNLP 1.5.1 and 1.5.2

Hi,

While debugging why POS tags are recently ignored by the Apache
Stanbol Enhancer I noticed that the reason where that with openNLP
1.5.2 the probabilities returned by the POS tagger have changed.

Previously typical probabilities of POS tags where  > 0.9+ for most of
the tokens. Because of that a configuration that ignores POS tags <
0.8 looked like a reasonable default. However with OpenNLP 1.5.2
probabilities are much lowers. At first it looks even like 1.5.2
returns now the uncertainty ('1-{probability}') instead of the
probability, but after looking a little bit into the source this seams
also unlikely to me.

I have already searched the Documentation and recent Jira Issues, but
I could not find anything related.

As an example the results for an single Sentence analyzed using
OpenNLP 1.5.1 and 1.5.2.

Sentence:

    A nice travel to the biggest volcano of Mexico.

Tokens are as expected

With openNLP 1.5.1 I get the following top Sequence when calling
POSTaggerME#topKSequences(tokens):

-0.0011259470521596032 [DT, JJ, NN, TO, DT, JJS, NN, IN, NNP, .]

Detailed Probabilities:

[1.0, 1.0, 0.9999999952604672, 0.9999999999971082, 1.0,
0.9988748880601196, 0.9999999702598833, 1.0, 0.9999999999989716,
0.9999998327848956]

Switching to openNLP 1.5.2 results in

-30.89400016135042 [DT, JJ, NN, TO, DT, JJS, NN, IN, NNP, .]

Detailed Probabilities:

[0.05013598125548828, 0.053016102976047086, 0.04032588713661259,
0.03995389549856565, 0.04685198986899964, 0.03659501930208113,
0.04132356969119329, 0.06434037591280849, 0.046311143933396866,
0.04233395769746884]


Is this a Bug or an intentional change. If the later it would be great
if someone could provide a link to the documentation.

best
Rupert Westenthaler


p.s:

with OpenNLP 1.5.1 I refer to

    opennlp-tools-1.5.1-incubating.jar
    opennlp-maxent-3.0.1-incubating.jar

with OpenNLP 1.5.2 I refer to

    opennlp-tools-1.5.2-incubating.jar
    opennlp-maxent-3.0.2-incubating.jar

In both cases the "en-pos-maxent.bin" as available via openly.sf.org is used

-- 
| Rupert Westenthaler             rupert.westenthaler@gmail.com
| Bodenlehenstraße 11                             ++43-699-11108907
| A-5500 Bischofshofen

Re: POS Tagger Probability changes between OpenNLP 1.5.1 and 1.5.2

Posted by Jörn Kottmann <ko...@gmail.com>.
This is very likely linked to this issue:
https://issues.apache.org/jira/browse/OPENNLP-154

We changed the way the perceptron is normalizing the probabilities.

Jörn

On 05/22/2012 04:46 PM, Jörn Kottmann wrote:
> On 05/22/2012 04:34 PM, Jeyendran Balakrishnan wrote:
>> Hi Rupert, are you sure you are loading a model from 
>> "en--pos-perceptron.bin", but passing it to a POSTaggerME tagger?
>> Unless it is a typo in your email, that could be the problem (ie 
>> passing a perceptron model to a maxent classifier)...
>
> OpenNLP is auto detecting the model which is passed in, but that would 
> easily explain
> why the probs are different, e.g using maxent first and then the 
> perceptron model.
> But he mentioned in an earlier mail that he used the *same* model on 
> both tests.
> I will debug this tonight.
>
> Jörn


Re: POS Tagger Probability changes between OpenNLP 1.5.1 and 1.5.2

Posted by Rupert Westenthaler <ru...@gmail.com>.
Hi

I definitely used the "en-pos-perceptron.bin" in both cases.

However when switch to the "en-pos-maxent.bin" with 1.5.2 I do get
results that I would expect. So it seams the described issue only
affects the perceptron model.

Here the detailed results for the maxent model.

Sentence:

    A nice travel to the biggest volcano of Mexico.

POSTaggerME#topKSequences(tokens) with openNLP 1.5.2 and "en-pos-maxent.bin"

    -0.19092493831060522 [DT, JJ, NN, TO, DT, JJS, NN, IN, NNP, .]

Detailed Probabilities:

[0.9574457453640682, 0.988073661574357, 0.9962495810301972,
0.9709960280930423, 0.978828016790525, 0.9730651680770073,
0.9857216847007988, 0.9886882554359132, 0.9889536036052374,
0.9834568956230735]

On Tue, May 22, 2012 at 4:46 PM, Jörn Kottmann <ko...@gmail.com> wrote:
> On 05/22/2012 04:34 PM, Jeyendran Balakrishnan wrote:
>>
>> Hi Rupert, are you sure you are loading a model from
>> "en--pos-perceptron.bin", but passing it to a POSTaggerME tagger?
>> Unless it is a typo in your email, that could be the problem (ie passing a
>> perceptron model to a maxent classifier)...
>
>
> OpenNLP is auto detecting the model which is passed in, but that would
> easily explain
> why the probs are different, e.g using maxent first and then the perceptron
> model.
> But he mentioned in an earlier mail that he used the *same* model on both
> tests.
> I will debug this tonight.
>
> Jörn



-- 
| Rupert Westenthaler             rupert.westenthaler@gmail.com
| Bodenlehenstraße 11                             ++43-699-11108907
| A-5500 Bischofshofen

Re: POS Tagger Probability changes between OpenNLP 1.5.1 and 1.5.2

Posted by Jörn Kottmann <ko...@gmail.com>.
On 05/22/2012 04:34 PM, Jeyendran Balakrishnan wrote:
> Hi Rupert, are you sure you are loading a model from "en--pos-perceptron.bin", but passing it to a POSTaggerME tagger?
> Unless it is a typo in your email, that could be the problem (ie passing a perceptron model to a maxent classifier)...

OpenNLP is auto detecting the model which is passed in, but that would 
easily explain
why the probs are different, e.g using maxent first and then the 
perceptron model.
But he mentioned in an earlier mail that he used the *same* model on 
both tests.
I will debug this tonight.

Jörn

RE: POS Tagger Probability changes between OpenNLP 1.5.1 and 1.5.2

Posted by Jeyendran Balakrishnan <jp...@personaltube.com>.
Hi Rupert, are you sure you are loading a model from "en--pos-perceptron.bin", but passing it to a POSTaggerME tagger? 
Unless it is a typo in your email, that could be the problem (ie passing a perceptron model to a maxent classifier)...

Cheers,
Jeyendran


-----Original Message-----
From: Rupert Westenthaler [mailto:rupert.westenthaler@gmail.com] 
Sent: Tuesday, May 22, 2012 5:01 AM
To: dev@opennlp.apache.org; jp@personaltube.com
Subject: Re: POS Tagger Probability changes between OpenNLP 1.5.1 and 1.5.2

Hi

Maybe it has to do with the fact that I use topKSequences(String[]
sentence) instead.

basically I use

String sentence = "A nice travel to the biggest volcano of Mexico."
Span[] tokenSpans = tokenizer().tokenizePos(sentence);
String[] tokens = new String[tokenSpans.length]; POSModel model; //loaded from "en--pos-perceptron.bin"
POSTaggerME tagger = new POSTaggerME(posModel) for(int ti = 0; ti<tokenSpans.length;ti++) {
    tokens[ti] = tokenSpans[ti].getCoveredText(sentence).toString();
}
Sequence[] posSequences = tagger.topKSequences(tokens);

The source can be found at [1] (line 440 - 460)

I can not easily switch between 1.5.1 and 1.5.2 in Stanbol as Stanbol now uses 1.5.2 as OSGI bundle (what is not possible with 1.5.1). So I used an older version of Stanbol for comparing. However the affected code has not changed since than.

best
Rupert

[1] http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/opennlp/src/main/java/org/apache/stanbol/commons/opennlp/TextAnalyzer.java

On Tue, May 22, 2012 at 10:06 AM, Jeyendran Balakrishnan <jp...@personaltube.com> wrote:
> FWIW, I'm using the POS tagger in 1.5.2, and getting probabilities of between 0.5 to 1 for most tags [tested on a few hundred sentences].
> I use tagger.tag(String[] tokens) to get the POS tags, and tagger.probs() immediately afterwards to get the probabilities.
>
> Cheers,
> Jeyendran
>
>
> -----Original Message-----
> From: Jörn Kottmann [mailto:kottmann@gmail.com]
> Sent: Tuesday, May 22, 2012 12:48 AM
> To: dev@opennlp.apache.org
> Subject: Re: POS Tagger Probability changes between OpenNLP 1.5.1 and 
> 1.5.2
>
> Hello,
>
> that looks strange to me, I don't really know which changes caused this.
> Did you run both tests on the same machine?
>
> I will try to reproduce your results.
>
> Thanks for reporting this!
>
> Jörn
>
> On 05/21/2012 01:49 PM, Rupert Westenthaler wrote:
>> Hi,
>>
>> While debugging why POS tags are recently ignored by the Apache 
>> Stanbol Enhancer I noticed that the reason where that with openNLP
>> 1.5.2 the probabilities returned by the POS tagger have changed.
>>
>> Previously typical probabilities of POS tags where>  0.9+ for most of 
>> the tokens. Because of that a configuration that ignores POS tags<
>> 0.8 looked like a reasonable default. However with OpenNLP 1.5.2 
>> probabilities are much lowers. At first it looks even like 1.5.2 
>> returns now the uncertainty ('1-{probability}') instead of the 
>> probability, but after looking a little bit into the source this 
>> seams also unlikely to me.
>>
>> I have already searched the Documentation and recent Jira Issues, but 
>> I could not find anything related.
>>
>> As an example the results for an single Sentence analyzed using 
>> OpenNLP 1.5.1 and 1.5.2.
>>
>> Sentence:
>>
>>      A nice travel to the biggest volcano of Mexico.
>>
>> Tokens are as expected
>>
>> With openNLP 1.5.1 I get the following top Sequence when calling
>> POSTaggerME#topKSequences(tokens):
>>
>> -0.0011259470521596032 [DT, JJ, NN, TO, DT, JJS, NN, IN, NNP, .]
>>
>> Detailed Probabilities:
>>
>> [1.0, 1.0, 0.9999999952604672, 0.9999999999971082, 1.0, 
>> 0.9988748880601196, 0.9999999702598833, 1.0, 0.9999999999989716, 
>> 0.9999998327848956]
>>
>> Switching to openNLP 1.5.2 results in
>>
>> -30.89400016135042 [DT, JJ, NN, TO, DT, JJS, NN, IN, NNP, .]
>>
>> Detailed Probabilities:
>>
>> [0.05013598125548828, 0.053016102976047086, 0.04032588713661259, 
>> 0.03995389549856565, 0.04685198986899964, 0.03659501930208113, 
>> 0.04132356969119329, 0.06434037591280849, 0.046311143933396866, 
>> 0.04233395769746884]
>>
>>
>> Is this a Bug or an intentional change. If the later it would be 
>> great if someone could provide a link to the documentation.
>>
>> best
>> Rupert Westenthaler
>>
>>
>> p.s:
>>
>> with OpenNLP 1.5.1 I refer to
>>
>>      opennlp-tools-1.5.1-incubating.jar
>>      opennlp-maxent-3.0.1-incubating.jar
>>
>> with OpenNLP 1.5.2 I refer to
>>
>>      opennlp-tools-1.5.2-incubating.jar
>>      opennlp-maxent-3.0.2-incubating.jar
>>
>> In both cases the "en-pos-maxent.bin" as available via openly.sf.org 
>> is used
>>
>
>



-- 
| Rupert Westenthaler             rupert.westenthaler@gmail.com 
| Bodenlehenstraße 11                             ++43-699-11108907
| A-5500 Bischofshofen


Re: POS Tagger Probability changes between OpenNLP 1.5.1 and 1.5.2

Posted by Rupert Westenthaler <ru...@gmail.com>.
Hi

Maybe it has to do with the fact that I use topKSequences(String[]
sentence) instead.

basically I use

String sentence = "A nice travel to the biggest volcano of Mexico."
Span[] tokenSpans = tokenizer().tokenizePos(sentence);
String[] tokens = new String[tokenSpans.length];
POSModel model; //loaded from "en--pos-perceptron.bin"
POSTaggerME tagger = new POSTaggerME(posModel)
for(int ti = 0; ti<tokenSpans.length;ti++) {
    tokens[ti] = tokenSpans[ti].getCoveredText(sentence).toString();
}
Sequence[] posSequences = tagger.topKSequences(tokens);

The source can be found at [1] (line 440 - 460)

I can not easily switch between 1.5.1 and 1.5.2 in Stanbol as Stanbol
now uses 1.5.2 as OSGI bundle (what is not possible with 1.5.1). So I
used an older version of Stanbol for comparing. However the affected
code has not changed since than.

best
Rupert

[1] http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/opennlp/src/main/java/org/apache/stanbol/commons/opennlp/TextAnalyzer.java

On Tue, May 22, 2012 at 10:06 AM, Jeyendran Balakrishnan
<jp...@personaltube.com> wrote:
> FWIW, I'm using the POS tagger in 1.5.2, and getting probabilities of between 0.5 to 1 for most tags [tested on a few hundred sentences].
> I use tagger.tag(String[] tokens) to get the POS tags, and tagger.probs() immediately afterwards to get the probabilities.
>
> Cheers,
> Jeyendran
>
>
> -----Original Message-----
> From: Jörn Kottmann [mailto:kottmann@gmail.com]
> Sent: Tuesday, May 22, 2012 12:48 AM
> To: dev@opennlp.apache.org
> Subject: Re: POS Tagger Probability changes between OpenNLP 1.5.1 and 1.5.2
>
> Hello,
>
> that looks strange to me, I don't really know which changes caused this.
> Did you run both tests on the same machine?
>
> I will try to reproduce your results.
>
> Thanks for reporting this!
>
> Jörn
>
> On 05/21/2012 01:49 PM, Rupert Westenthaler wrote:
>> Hi,
>>
>> While debugging why POS tags are recently ignored by the Apache
>> Stanbol Enhancer I noticed that the reason where that with openNLP
>> 1.5.2 the probabilities returned by the POS tagger have changed.
>>
>> Previously typical probabilities of POS tags where>  0.9+ for most of
>> the tokens. Because of that a configuration that ignores POS tags<
>> 0.8 looked like a reasonable default. However with OpenNLP 1.5.2
>> probabilities are much lowers. At first it looks even like 1.5.2
>> returns now the uncertainty ('1-{probability}') instead of the
>> probability, but after looking a little bit into the source this seams
>> also unlikely to me.
>>
>> I have already searched the Documentation and recent Jira Issues, but
>> I could not find anything related.
>>
>> As an example the results for an single Sentence analyzed using
>> OpenNLP 1.5.1 and 1.5.2.
>>
>> Sentence:
>>
>>      A nice travel to the biggest volcano of Mexico.
>>
>> Tokens are as expected
>>
>> With openNLP 1.5.1 I get the following top Sequence when calling
>> POSTaggerME#topKSequences(tokens):
>>
>> -0.0011259470521596032 [DT, JJ, NN, TO, DT, JJS, NN, IN, NNP, .]
>>
>> Detailed Probabilities:
>>
>> [1.0, 1.0, 0.9999999952604672, 0.9999999999971082, 1.0,
>> 0.9988748880601196, 0.9999999702598833, 1.0, 0.9999999999989716,
>> 0.9999998327848956]
>>
>> Switching to openNLP 1.5.2 results in
>>
>> -30.89400016135042 [DT, JJ, NN, TO, DT, JJS, NN, IN, NNP, .]
>>
>> Detailed Probabilities:
>>
>> [0.05013598125548828, 0.053016102976047086, 0.04032588713661259,
>> 0.03995389549856565, 0.04685198986899964, 0.03659501930208113,
>> 0.04132356969119329, 0.06434037591280849, 0.046311143933396866,
>> 0.04233395769746884]
>>
>>
>> Is this a Bug or an intentional change. If the later it would be great
>> if someone could provide a link to the documentation.
>>
>> best
>> Rupert Westenthaler
>>
>>
>> p.s:
>>
>> with OpenNLP 1.5.1 I refer to
>>
>>      opennlp-tools-1.5.1-incubating.jar
>>      opennlp-maxent-3.0.1-incubating.jar
>>
>> with OpenNLP 1.5.2 I refer to
>>
>>      opennlp-tools-1.5.2-incubating.jar
>>      opennlp-maxent-3.0.2-incubating.jar
>>
>> In both cases the "en-pos-maxent.bin" as available via openly.sf.org
>> is used
>>
>
>



-- 
| Rupert Westenthaler             rupert.westenthaler@gmail.com
| Bodenlehenstraße 11                             ++43-699-11108907
| A-5500 Bischofshofen

RE: POS Tagger Probability changes between OpenNLP 1.5.1 and 1.5.2

Posted by Jeyendran Balakrishnan <jp...@personaltube.com>.
FWIW, I'm using the POS tagger in 1.5.2, and getting probabilities of between 0.5 to 1 for most tags [tested on a few hundred sentences].
I use tagger.tag(String[] tokens) to get the POS tags, and tagger.probs() immediately afterwards to get the probabilities.

Cheers,
Jeyendran


-----Original Message-----
From: Jörn Kottmann [mailto:kottmann@gmail.com] 
Sent: Tuesday, May 22, 2012 12:48 AM
To: dev@opennlp.apache.org
Subject: Re: POS Tagger Probability changes between OpenNLP 1.5.1 and 1.5.2

Hello,

that looks strange to me, I don't really know which changes caused this.
Did you run both tests on the same machine?

I will try to reproduce your results.

Thanks for reporting this!

Jörn

On 05/21/2012 01:49 PM, Rupert Westenthaler wrote:
> Hi,
>
> While debugging why POS tags are recently ignored by the Apache 
> Stanbol Enhancer I noticed that the reason where that with openNLP
> 1.5.2 the probabilities returned by the POS tagger have changed.
>
> Previously typical probabilities of POS tags where>  0.9+ for most of 
> the tokens. Because of that a configuration that ignores POS tags<
> 0.8 looked like a reasonable default. However with OpenNLP 1.5.2 
> probabilities are much lowers. At first it looks even like 1.5.2 
> returns now the uncertainty ('1-{probability}') instead of the 
> probability, but after looking a little bit into the source this seams 
> also unlikely to me.
>
> I have already searched the Documentation and recent Jira Issues, but 
> I could not find anything related.
>
> As an example the results for an single Sentence analyzed using 
> OpenNLP 1.5.1 and 1.5.2.
>
> Sentence:
>
>      A nice travel to the biggest volcano of Mexico.
>
> Tokens are as expected
>
> With openNLP 1.5.1 I get the following top Sequence when calling
> POSTaggerME#topKSequences(tokens):
>
> -0.0011259470521596032 [DT, JJ, NN, TO, DT, JJS, NN, IN, NNP, .]
>
> Detailed Probabilities:
>
> [1.0, 1.0, 0.9999999952604672, 0.9999999999971082, 1.0, 
> 0.9988748880601196, 0.9999999702598833, 1.0, 0.9999999999989716, 
> 0.9999998327848956]
>
> Switching to openNLP 1.5.2 results in
>
> -30.89400016135042 [DT, JJ, NN, TO, DT, JJS, NN, IN, NNP, .]
>
> Detailed Probabilities:
>
> [0.05013598125548828, 0.053016102976047086, 0.04032588713661259, 
> 0.03995389549856565, 0.04685198986899964, 0.03659501930208113, 
> 0.04132356969119329, 0.06434037591280849, 0.046311143933396866, 
> 0.04233395769746884]
>
>
> Is this a Bug or an intentional change. If the later it would be great 
> if someone could provide a link to the documentation.
>
> best
> Rupert Westenthaler
>
>
> p.s:
>
> with OpenNLP 1.5.1 I refer to
>
>      opennlp-tools-1.5.1-incubating.jar
>      opennlp-maxent-3.0.1-incubating.jar
>
> with OpenNLP 1.5.2 I refer to
>
>      opennlp-tools-1.5.2-incubating.jar
>      opennlp-maxent-3.0.2-incubating.jar
>
> In both cases the "en-pos-maxent.bin" as available via openly.sf.org 
> is used
>



Re: POS Tagger Probability changes between OpenNLP 1.5.1 and 1.5.2

Posted by Jörn Kottmann <ko...@gmail.com>.
Hello,

that looks strange to me, I don't really know which
changes caused this.
Did you run both tests on the same machine?

I will try to reproduce your results.

Thanks for reporting this!

Jörn

On 05/21/2012 01:49 PM, Rupert Westenthaler wrote:
> Hi,
>
> While debugging why POS tags are recently ignored by the Apache
> Stanbol Enhancer I noticed that the reason where that with openNLP
> 1.5.2 the probabilities returned by the POS tagger have changed.
>
> Previously typical probabilities of POS tags where>  0.9+ for most of
> the tokens. Because of that a configuration that ignores POS tags<
> 0.8 looked like a reasonable default. However with OpenNLP 1.5.2
> probabilities are much lowers. At first it looks even like 1.5.2
> returns now the uncertainty ('1-{probability}') instead of the
> probability, but after looking a little bit into the source this seams
> also unlikely to me.
>
> I have already searched the Documentation and recent Jira Issues, but
> I could not find anything related.
>
> As an example the results for an single Sentence analyzed using
> OpenNLP 1.5.1 and 1.5.2.
>
> Sentence:
>
>      A nice travel to the biggest volcano of Mexico.
>
> Tokens are as expected
>
> With openNLP 1.5.1 I get the following top Sequence when calling
> POSTaggerME#topKSequences(tokens):
>
> -0.0011259470521596032 [DT, JJ, NN, TO, DT, JJS, NN, IN, NNP, .]
>
> Detailed Probabilities:
>
> [1.0, 1.0, 0.9999999952604672, 0.9999999999971082, 1.0,
> 0.9988748880601196, 0.9999999702598833, 1.0, 0.9999999999989716,
> 0.9999998327848956]
>
> Switching to openNLP 1.5.2 results in
>
> -30.89400016135042 [DT, JJ, NN, TO, DT, JJS, NN, IN, NNP, .]
>
> Detailed Probabilities:
>
> [0.05013598125548828, 0.053016102976047086, 0.04032588713661259,
> 0.03995389549856565, 0.04685198986899964, 0.03659501930208113,
> 0.04132356969119329, 0.06434037591280849, 0.046311143933396866,
> 0.04233395769746884]
>
>
> Is this a Bug or an intentional change. If the later it would be great
> if someone could provide a link to the documentation.
>
> best
> Rupert Westenthaler
>
>
> p.s:
>
> with OpenNLP 1.5.1 I refer to
>
>      opennlp-tools-1.5.1-incubating.jar
>      opennlp-maxent-3.0.1-incubating.jar
>
> with OpenNLP 1.5.2 I refer to
>
>      opennlp-tools-1.5.2-incubating.jar
>      opennlp-maxent-3.0.2-incubating.jar
>
> In both cases the "en-pos-maxent.bin" as available via openly.sf.org is used
>