Preparers Summarize Text Operation Examples
Examples of using preparers with the SummarizeText operation in AI Accelerator.
Model creation (Required)
Required for Primitive single execution as well as Preparer bulk execution.
-- Create the model. It must support the decode_text and decode_text_batch operations. SELECT aidb.create_model('model__1952', 't5_local');
Primitive
-- Keyword arguments SELECT * FROM aidb.summarize_text( input => 'I don''t want a babysitter. I am eleven years old. My babysitter is only three years older than I am," she loudly yelled to her Mom. Now, she really wished she had somebody with her as she heard the clicking, scratching noises outside of the living room window. "This is silly. It''s probably the storm," the girl said. She regretted watching the horror show she had been tuned into for the last half hour. As she searched for the remote to turn off the vampire movie, the front door blew open with a thunderous noise. Carla whirled around to see a dark image.', options => '{"model": "model__1952"}' ); -- Positional arguments SELECT * FROM aidb.summarize_text( 'There are times when the night sky glows with bands of color. The bands may begin as cloud shapes and then spread into a great arc across the entire sky. They may fall in folds like a curtain drawn across the heavens. The lights usually grow brighter, then suddenly dim. During this time the sky glows with pale yellow, pink, green, violet, blue, and red. These lights are called the Aurora Borealis. Some people call them the Northern Lights. Scientists have been watching them for hundreds of years. They are not quite sure what causes them. In ancient times Long Beach City College WRSC Page 2 of 2 people were afraid of the Lights. They imagined that they saw fiery dragons in the sky. Some even concluded that the heavens were on fire.', '{"model": "model__1952"}' );
Preparer with table data source
-- Create source test table CREATE TABLE source_table__1952 ( id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, content TEXT NOT NULL ); INSERT INTO source_table__1952 VALUES (1, 'I don''t want a babysitter. I am eleven years old. My babysitter is only three years older than I am," she loudly yelled to her Mom. Now, she really wished she had somebody with her as she heard the clicking, scratching noises outside of the living room window. "This is silly. It''s probably the storm," the girl said. She regretted watching the horror show she had been tuned into for the last half hour. As she searched for the remote to turn off the vampire movie, the front door blew open with a thunderous noise. Carla whirled around to see a dark image.'), (2, 'There are times when the night sky glows with bands of color. The bands may begin as cloud shapes and then spread into a great arc across the entire sky. They may fall in folds like a curtain drawn across the heavens. The lights usually grow brighter, then suddenly dim. During this time the sky glows with pale yellow, pink, green, violet, blue, and red. These lights are called the Aurora Borealis. Some people call them the Northern Lights. Scientists have been watching them for hundreds of years. They are not quite sure what causes them. In ancient times Long Beach City College WRSC Page 2 of 2 people were afraid of the Lights. They imagined that they saw fiery dragons in the sky. Some even concluded that the heavens were on fire.'); SELECT aidb.create_preparer_for_table( name => 'preparer__1952', operation => 'SummarizeText', source_table => 'source_table__1952', source_data_column => 'content', destination_table => 'summarized_data__1952', destination_data_column => 'summaries', source_key_column => 'id', destination_key_column => 'id', options => '{"model": "model__1952"}'::JSONB -- Configuration for the SummarizeText operation ); SELECT aidb.bulk_data_preparation('preparer__1952'); SELECT * FROM summarized_data__1952;
Model compatibility
The AI accelerator data preparation pipeline validates the options at creation-time, including the model compatibility with the language adapter. These are the errors returned in that case:
-- This model does not support the language adapter SELECT aidb.create_model('bert_model__1952', 'bert_local');
-- Single execution fails SELECT * FROM aidb.summarize_text('bert_model__1952', 'Hello world');
Output
ERROR: The requested adapter is not supported by the model provider: bert_local
-- Preparer creation fails SELECT aidb.create_preparer_for_table( name => 'preparer_name', operation => 'SummarizeText', source_table => 'source_table__1952', source_data_column => 'content', destination_table => 'summarized_data__1952', destination_data_column => 'summaries', options => '{"model": "bert_model__1952"}'::JSONB -- Incompatible model );
Output
ERROR: Failed to create preparer: The requested adapter is not supported by the model provider: bert_local
Could this page be better? Report a problem or suggest an addition!