Improvements to the Explanation class

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Improvements to the Explanation class

Sambhav Kothari (BLOOMBERG/ LONDON)
Hello,

Currently the Explanation class has a toHtml and toString method, but it doesn't seem to have any method to output the explanation as a NamedList. Part of the reason is that NamedList is a Solr only concept and it cannot exist in lucene. But this leads to utility functions like (https://github.com/apache/lucene-solr/blob/1d85cd783863f75cea133fb9c452302214165a4d/solr/core/src/java/org/apache/solr/response/transform/ExplainAugmenterFactory.java#L115 and https://github.com/apache/lucene-solr/blob/1d85cd783863f75cea133fb9c452302214165a4d/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java#L400-L466

which assume a particular structure about explanations. Explanation should instead have a toMap method which returns a Map of key-value pairs which can then be converted to a NamedList in Solr.

This can be exceptionally useful if we have a class inheriting from Explanation that adds more attributes. For example for Learning to Rank model explanations we can have a ModelExplanation class which adds doc-specific feature scores and other machine learning model explanations to the output.

It also allows the ExplainAugmenter and other classes to have a more generic way of getting an Explanation's data in a structured format. The way it currently does so is very ugly - https://github.com/apache/lucene-solr/blob/1d85cd783863f75cea133fb9c452302214165a4d/solr/core/src/java/org/apache/solr/response/transform/ExplainAugmenterFactory.java#L115

Just wanted to discuss this on the mailing list before creating Jira tickets.

Thanks,
Sam
Reply | Threaded
Open this post in threaded view
|

Re: Improvements to the Explanation class

Vadim Gindin
Hi all,

I think it is a good idea. I have a similar situation and I had to store
additional data (features values) as a string and parse it further. So I'd
be glad if your proposal will be implemented.

Regards,
Vadim Gindin

On Fri, Jan 11, 2019 at 7:17 PM Sambhav Kothari (BLOOMBERG/ LONDON) <
[hidden email]> wrote:

> Hello,
>
> Currently the Explanation class has a toHtml and toString method, but it
> doesn't seem to have any method to output the explanation as a NamedList.
> Part of the reason is that NamedList is a Solr only concept and it cannot
> exist in lucene. But this leads to utility functions like (
> https://github.com/apache/lucene-solr/blob/1d85cd783863f75cea133fb9c452302214165a4d/solr/core/src/java/org/apache/solr/response/transform/ExplainAugmenterFactory.java#L115
> and
> https://github.com/apache/lucene-solr/blob/1d85cd783863f75cea133fb9c452302214165a4d/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java#L400-L466
>
> which assume a particular structure about explanations. Explanation should
> instead have a toMap method which returns a Map of key-value pairs which
> can then be converted to a NamedList in Solr.
>
> This can be exceptionally useful if we have a class inheriting from
> Explanation that adds more attributes. For example for Learning to Rank
> model explanations we can have a ModelExplanation class which adds
> doc-specific feature scores and other machine learning model explanations
> to the output.
>
> It also allows the ExplainAugmenter and other classes to have a more
> generic way of getting an Explanation's data in a structured format. The
> way it currently does so is very ugly -
> https://github.com/apache/lucene-solr/blob/1d85cd783863f75cea133fb9c452302214165a4d/solr/core/src/java/org/apache/solr/response/transform/ExplainAugmenterFactory.java#L115
>
> Just wanted to discuss this on the mailing list before creating Jira
> tickets.
>
> Thanks,
> Sam