Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prettify printed results in Tutorials #1595

Closed
tholor opened this issue Oct 14, 2021 · 0 comments · Fixed by #1694
Closed

Prettify printed results in Tutorials #1595

tholor opened this issue Oct 14, 2021 · 0 comments · Fixed by #1694
Assignees
Labels
type:documentation Improvements on the docs type:refactor Not necessarily visible to the users

Comments

@tholor
Copy link
Member

tholor commented Oct 14, 2021

In most of our tutorials, we print the results of a pipeline at some point - mostly using pprint, print_answers or print_documents.
Sometimes the printed results are very verbose and it's hard to see the most relevant information that users are actually interested in.

Example:

In Tutorial 13 we print something verbose like this:

{'documents': [{'content': "Dry Cleaning are an English post-punk band who formed in South London in 2018.[3] The band is composed of vocalist Florence Shaw, guitarist Tom Dowse, bassist Lewis Maynard and drummer Nick Buxton. They are noted for their use of spoken word primarily in lieu of sung vocals, as well as their unconventional lyrics. Their musical stylings have been compared to Wire, Magazine and Joy Division.[4] The band released their debut single, 'Magic of Meghan' in 2019. Shaw wrote the song after going through a break-up and moving out of her former partner's apartment the same day that Meghan Markle and Prince Harry announced they were engaged.[5] This was followed by the release of two EPs that year: Sweet Princess in August and Boundary Road Snacks and Drinks in October. The band were included as part of the NME 100 of 2020,[6] as well as DIY magazine's Class of 2020.[7] The band signed to 4AD in late 2020 and shared a new single, 'Scratchcard Lanyard'.[8] In February 2021, the band shared details of their debut studio album, New Long Leg. They also shared the single 'Strong Feelings'.[9] The album, which was produced by John Parish, was released on 2 April 2021.[10]", 'content_type': 'text', 'score': 0.5312093733737563, 'meta': {}, 'embedding': None, 'id': '83bc102774fd126712d6b2e67195ec79'}],
 'node_id': 'Reader',
 'params': {},
 'query_doc_list': [
                   {'docs': [{'content': "Dry Cleaning are an English post-punk band who formed in South London in 2018.[3] The band is composed of vocalist Florence Shaw, guitarist Tom Dowse, bassist Lewis Maynard and drummer Nick Buxton. They are noted for their use of spoken word primarily in lieu of sung vocals, as well as their unconventional lyrics. Their musical stylings have been compared to Wire, Magazine and Joy Division.[4] The band released their debut single, 'Magic of Meghan' in 2019. Shaw wrote the song after going through a break-up and moving out of her former partner's apartment the same day that Meghan Markle and Prince Harry announced they were engaged.[5] This was followed by the release of two EPs that year: Sweet Princess in August and Boundary Road Snacks and Drinks in October. The band were included as part of the NME 100 of 2020,[6] as well as DIY magazine's Class of 2020.[7] The band signed to 4AD in late 2020 and shared a new single, 'Scratchcard Lanyard'.[8] In February 2021, the band shared details of their debut studio album, New Long Leg. They also shared the single 'Strong Feelings'.[9] The album, which was produced by John Parish, was released on 2 April 2021.[10]", 'content_type': 'text', 'score': 0.5312093733737563, 'meta': {}, 'embedding': None, 'id': '83bc102774fd126712d6b2e67195ec79'}],
                     'queries': ' What is the name of the English post-punk '
                                'band that formed in South London in 2018?'},
                    
                    ...],
 'results': [{'answers': [Answer(answer='Dry Cleaning', type='extractive', score=0.9960232973098755, context='Dry Cleaning are an English post-punk band who formed in South London in 2018.[3] The band is composed of vocalist Florence Shaw, guitarist Tom Dowse,', offsets_in_document=[Span(start=0, end=12)], offsets_in_context=[Span(start=0, end=12)], document_id='83bc102774fd126712d6b2e67195ec79', meta={}),
                          Answer(answer='Boundary Road Snacks and Drinks', type='extractive', score=0.059282587841153145, context=' release of two EPs that year: Sweet Princess in August and Boundary Road Snacks and Drinks in October. The band were included as part of the NME 100 ', offsets_in_document=[Span(start=727, end=758)], offsets_in_context=[Span(start=60, end=91)], document_id='83bc102774fd126712d6b2e67195ec79', meta={})],
              'no_ans_gap': 12.840229034423828,
              'query': ' What is the name of the English post-punk band that '
                       'formed in South London in 2018?'},
             ...

And there are a couple of other tutorials with similar cases.
To some degree, this might be related to our recent refactoring of primitives (#1398 ) and pipeline outputs.

Let's check all tutorials and improve the prints. Couple of options:

  • Adjust print_answers / print_documents utils
  • Adjust the str representation of Document / Answer and utilize this in the tutorials
  • Use a custom print to only show certain attributes like here

CC @brandenchan

@tholor tholor added type:documentation Improvements on the docs type:refactor Not necessarily visible to the users labels Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:documentation Improvements on the docs type:refactor Not necessarily visible to the users
Projects
None yet
3 participants