Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.57k stars 2.79k forks source link

Results from Abstractive Summary on language studio portal and python sdk are different #27683

Closed csaras84 closed 1 year ago

csaras84 commented 1 year ago

I'm using Azure Abstractive Summarization to summarize a bunch of captions. I'm using Python SDK sample from here: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/textanalytics/azure-ai-textanalytics/samples/sample_abstract_summary.py

I have a story with 10 sentences and no matter what max_sentence_count we provide, with the python sdk I'm getting just a single same sentence as result, while the same yields a different result on the language studio portal 'try it out' option.

Does the language studio 'try it out' option use a different api than the one used by sdk client? Why is my SDK result different from that of the language studio portal try out?

Original input: document = ["a man looking at another man. a man in a suit. a man looking at another man. a man looking at another man. a stone structure with carvings. a stone structure with a cross. a man in a suit opening a door. a person opening a door. a man in a suit. a man in a suit"]

Result from SDK: Summaries abstracted: a man in a suit opening a door.

Result from language studio 'try it out': a man in a suit looking at another man. a man looking at a stone structure with carvings. a man opening a door.

azure-sdk commented 1 year ago

Label prediction was below confidence level 0.6 for Model:ServiceLabels: 'Cognitive - Text Analytics:0.41821828,Azure.Core:0.07173236,Docs:0.05387793'

kristapratico commented 1 year ago

@csaras84 it looks like the Language studio sets the sentence count to 3 by default. If you want to match the behavior in the Python client library, you can do this by setting the sentence_count (not max_sentence_count) in the AbstractSummaryAction:

document = ["a man looking at another man. a man in a suit. a man looking at another man. a man looking at another man. a stone structure with carvings. a stone structure with a cross. a man in a suit opening a door. a person opening a door. a man in a suit. a man in a suit"]
poller = text_analytics_client.begin_analyze_actions(
    document,
    actions=[
        AbstractSummaryAction(sentence_count=3),
    ],
)

I tested this and see the same result between Language studio and Python client library. Let me know if I can help with anything else.

csaras84 commented 1 year ago

@csaras84 it looks like the Language studio sets the sentence count to 3 by default. If you want to match the behavior in the Python client library, you can do this by setting the sentence_count (not max_sentence_count) in the AbstractSummaryAction:

document = ["a man looking at another man. a man in a suit. a man looking at another man. a man looking at another man. a stone structure with carvings. a stone structure with a cross. a man in a suit opening a door. a person opening a door. a man in a suit. a man in a suit"]
poller = text_analytics_client.begin_analyze_actions(
    document,
    actions=[
        AbstractSummaryAction(sentence_count=3),
    ],
)

I tested this and see the same result between Language studio and Python client library. Let me know if I can help with anything else.

That sentence_count works like a charm. Thanks for the quick turnaround. I'm closing this thread.