Hugging Faceパイプラインの推測署名¶
Snowflake Model Registryは、単一のタスクを含むHugging Faceパイプラインの署名を以下のリストから自動的に推測します。
conversational
fill-mask
question-answering
summarization
table-question-answering
text2text-generation
text-classification
(エイリアスsentiment-analysis
)text-generation
token-classification
(エイリアスner
)translation
translation_xx_to_yy
zero-shot-classification
このトピックでは、必要な入力と期待される出力の説明と例を含め、これらのタイプの Hugging Face パイプラインの署名について説明します。すべての入出力はSnowpark DataFramesです。
レジストリのHugging Faceパイプラインのログに関する一般的なガイダンスについては、 Hugging Faceパイプライン をご参照ください。
会話型パイプライン¶
タスクが 会話型 のパイプラインには、次の入出力があります。
入力¶
user_inputs
: ユーザーの以前の入力と現在の入力を表す文字列のリスト。リストの最後のものが最新の入力です。generated_responses
: モデルの過去の応答を表す文字列のリスト。
例:
---------------------------------------------------------------------------
|"user_inputs" |"generated_responses" |
---------------------------------------------------------------------------
|[ |[ |
| "Do you speak French?", | "Yes I do." |
| "Do you know how to say Snowflake in French?" |] |
|] | |
---------------------------------------------------------------------------
出力¶
generated_responses
: モデルの以前の応答と現在の応答を表す文字列のリスト。リストの最後のものが最新の応答です。
例:
-------------------------
|"generated_responses" |
-------------------------
|[ |
| "Yes I do.", |
| "I speak French." |
|] |
-------------------------
フィル・マスク・パイプライン¶
タスクが「 fill-mask 」であるパイプラインには、以下の入出力があります。
入力¶
inputs
:入力するマスクがある文字列。
例:
--------------------------------------------------
|"inputs" |
--------------------------------------------------
|LynYuu is the [MASK] of the Grand Duchy of Yu. |
--------------------------------------------------
出力¶
outputs
:score
、token
、token_str
、sequence
のようなキーを含む、結果オブジェクトのリストの JSON 表現を含む文字列。詳細については、 FillMaskPipeline をご参照ください。
例:
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|"outputs" |
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|[{"score": 0.9066258072853088, "token": 3007, "token_str": "capital", "sequence": "lynyuu is the capital of the grand duchy of yu."}, {"score": 0.08162177354097366, "token": 2835, "token_str": "seat", "sequence": "lynyuu is the seat of the grand duchy of yu."}, {"score": 0.0012052370002493262, "token": 4075, "token_str": "headquarters", "sequence": "lynyuu is the headquarters of the grand duchy of yu."}, {"score": 0.0006560495239682496, "token": 2171, "token_str": "name", "sequence": "lynyuu is the name of the grand duchy of yu."}, {"score": 0.0005427763098850846, "token": 3200, "token_str"... |
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
トークン分類¶
タスクが「ner」または「 token-classification 」のパイプラインは、以下の入力と出力を持ちます。
入力¶
inputs
:分類されるトークンを含む文字列。
例:
------------------------------------------------
|"inputs" |
------------------------------------------------
|My name is Izumi and I live in Tokyo, Japan. |
------------------------------------------------
出力¶
outputs
:entity
、score
、index
、word
、name
、start
、end
のようなキーを含む、結果オブジェクトのリストの JSON 表現を含む文字列。詳細については、 TokenClassificationPipeline をご参照ください。
例:
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|"outputs" |
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|[{"entity": "PRON", "score": 0.9994392991065979, "index": 1, "word": "my", "start": 0, "end": 2}, {"entity": "NOUN", "score": 0.9968984127044678, "index": 2, "word": "name", "start": 3, "end": 7}, {"entity": "AUX", "score": 0.9937735199928284, "index": 3, "word": "is", "start": 8, "end": 10}, {"entity": "PROPN", "score": 0.9928083419799805, "index": 4, "word": "i", "start": 11, "end": 12}, {"entity": "PROPN", "score": 0.997334361076355, "index": 5, "word": "##zumi", "start": 12, "end": 16}, {"entity": "CCONJ", "score": 0.999173104763031, "index": 6, "word": "and", "start": 17, "end": 20}, {... |
質問応答(単一出力)¶
タスクが「 question-answering 」であるパイプラインは、 top_k
が未設定または1に設定されている場合、次の入力と出力を持ちます。
入力¶
question
:回答が必要な質問を含む文字列。context
:回答を含む文字列。
例:
-----------------------------------------------------------------------------------
|"question" |"context" |
-----------------------------------------------------------------------------------
|What did Doris want to do? |Doris is a cheerful mermaid from the ocean dept... |
-----------------------------------------------------------------------------------
出力¶
score
:0.0~1.0までの浮動小数点信頼度スコア。start
:コンテキスト内の回答の最初のトークンの整数インデックス。end
:元のコンテクストにおける回答の最後のトークンの整数インデックス。answer
:見つかった回答を含む文字列。
例:
--------------------------------------------------------------------------------
|"score" |"start" |"end" |"answer" |
--------------------------------------------------------------------------------
|0.61094731092453 |139 |178 |learn more about the world of athletics |
--------------------------------------------------------------------------------
質問応答(複数出力)¶
タスクが「 question-answering 」であるパイプラインは、 top_k
が設定され、1より大きい場合、次の入出力があります。
入力¶
question
:回答が必要な質問を含む文字列。context
:回答を含む文字列。
例:
-----------------------------------------------------------------------------------
|"question" |"context" |
-----------------------------------------------------------------------------------
|What did Doris want to do? |Doris is a cheerful mermaid from the ocean dept... |
-----------------------------------------------------------------------------------
出力¶
outputs
:score
、start
、end
、answer
のようなキーを含む、結果オブジェクトのリストの JSON 表現を含む文字列。
例:
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|"outputs" |
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|[{"score": 0.61094731092453, "start": 139, "end": 178, "answer": "learn more about the world of athletics"}, {"score": 0.17750297486782074, "start": 139, "end": 180, "answer": "learn more about the world of athletics.\""}, {"score": 0.06438097357749939, "start": 138, "end": 178, "answer": "\"learn more about the world of athletics"}] |
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
要約¶
タスクが「 要約 」のパイプラインでは、 return_tensors
がFalseまたは未設定であり、次の入出力があります。
入力¶
documents
:要約するテキストを含む文字列。
例:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|"documents" |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|Neuro-sama is a chatbot styled after a female VTuber that hosts live streams on the Twitch channel "vedal987". Her speech and personality are generated by an artificial intelligence (AI) system wh... |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
出力¶
summary_text
: 生成された要約を含む文字列、またはnum_return_sequences
が1より大きい場合、結果のリストの JSON 表現を含む文字列であり、各辞書にはsummary_text
を含むフィールドがあります。
例:
---------------------------------------------------------------------------------
|"summary_text" |
---------------------------------------------------------------------------------
| Neuro-sama is a chatbot styled after a female VTuber that hosts live streams |
---------------------------------------------------------------------------------
テーブル質問応答¶
タスクが「 table-question-answering 」であるパイプラインには、以下の入出力があります。
入力¶
query
: 回答が必要な質問を含む文字列。table
: 回答を含む可能性のあるテーブルを表す{column -> [values]}
形式の JSON シリアル化ディクショナリを含む文字列。
例:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|"query" |"table" |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|Which channel has the most subscribers? |{"Channel": ["A.I.Channel", "Kaguya Luna", "Mirai Akari", "Siro"], "Subscribers": ["3,020,000", "872,000", "694,000", "660,000"], "Videos": ["1,200", "113", "639", "1,300"], "Created At": ["Jun 30 2016", "Dec 4 2017", "Feb 28 2014", "Jun 23 2017"]} |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
出力¶
answer
: 考えられる回答を含む文字列。coordinates
: 回答が見つかったセルの座標を表す整数のリスト。cells
: 回答が見つかったセルの内容を含む文字列のリスト。aggregator
:使用するアグリゲーターの名前を含む文字列。
例:
----------------------------------------------------------------
|"answer" |"coordinates" |"cells" |"aggregator" |
----------------------------------------------------------------
|A.I.Channel |[ |[ |NONE |
| | [ | "A.I.Channel" | |
| | 0, |] | |
| | 0 | | |
| | ] | | |
| |] | | |
----------------------------------------------------------------
テキスト分類(単一出力)¶
タスクが「 text-clasification 」または「sentiment-analysis」で、 top_k
が設定されていないかNoneのパイプラインには、次の入出力があります。
入力¶
text
:分類する文字列。text_pair
:text
と一緒に分類する文字列で、テキストの類似度を計算するモデルで使用されます。モデルが使用しない場合は空のままにします。
例:
----------------------------------
|"text" |"text_pair" |
----------------------------------
|I like you. |I love you, too. |
----------------------------------
出力¶
label
:テキストの分類ラベルを表す文字列。score
:0.0から1.0までの浮動小数点信頼度スコア。
例:
--------------------------------
|"label" |"score" |
--------------------------------
|LABEL_0 |0.9760091304779053 |
--------------------------------
テキスト分類(複数出力)¶
タスクが「 text-clasification 」または「sentiment-analysis」で、 top_k
が数値に設定されているパイプラインには、次の入出力があります。
注釈
テキスト分類タスクは、 top_k
が任意の数に設定されている場合、その数が1であっても、複数出力とみなされます。 単一出力 を取得するには、 top_k
の値をNoneにしてください。
入力¶
text
:分類する文字列。text_pair
:text
と一緒に分類する文字列で、テキストの類似度を計算するモデルで使用されます。モデルが使用しない場合は空のままにします。
例:
--------------------------------------------------------------------
|"text" |"text_pair" |
--------------------------------------------------------------------
|I am wondering if I should have udon or rice fo... | |
--------------------------------------------------------------------
出力¶
outputs
: 結果のリストの JSON 表現を含む文字列で、各リストには、label
とscore
を含むフィールドがあります。
例:
--------------------------------------------------------
|"outputs" |
--------------------------------------------------------
|[{"label": "NEGATIVE", "score": 0.9987024068832397}] |
--------------------------------------------------------
テキスト生成¶
タスクが「 テキスト生成 」で、 return_tensors
がFalseまたは未設定であるパイプラインには、以下の入出力があります。
注釈
return_tensors
がTrueのテキスト生成パイプラインはサポートされていません。
入力¶
inputs
: プロンプトを含む文字列。
例:
--------------------------------------------------------------------------------
|"inputs" |
--------------------------------------------------------------------------------
|A descendant of the Lost City of Atlantis, who swam to Earth while saying, " |
--------------------------------------------------------------------------------
出力¶
outputs
:generated_text
を含むフィールドを含む結果オブジェクトのリストを JSON で表した文字列。
例:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|"outputs" |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|[{"generated_text": "A descendant of the Lost City of Atlantis, who swam to Earth while saying, \"For my life, I don't know if I'm gonna land upon Earth.\"\n\nIn \"The Misfits\", in a flashback, wh... |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
テキストからテキストへの生成¶
タスクが「 text2text generation 」であるパイプライン(return_tensors
がFalseまたは未設定)には、次の入出力があります。
注釈
return_tensors
がTrueのテキストからテキストの生成パイプラインはサポートされていません。
入力¶
inputs
: プロンプトを含む文字列。
例:
--------------------------------------------------------------------------------
|"inputs" |
--------------------------------------------------------------------------------
|A descendant of the Lost City of Atlantis, who swam to Earth while saying, " |
--------------------------------------------------------------------------------
出力¶
generated_text:
num_return_sequences
が1の場合に生成されたテキストを含む文字列、またはnum_return_sequences が1より大きい場合のgenerated_text
などのフィールドを含む結果ディクショナリの JSON リストの文字列表現。
例:
----------------------------------------------------------------
|"generated_text" |
----------------------------------------------------------------
|, said that he was a descendant of the Lost City of Atlantis |
----------------------------------------------------------------
翻訳生成¶
タスクが「 translation 」であるパイプライン(return_tensors
がFalseまたは未設定)には、以下の入出力があります。
注釈
return_tensors
がTrueの翻訳生成パイプラインはサポートされていません。
入力¶
inputs
:翻訳するテキストを含む文字列。
例:
------------------------------------------------------------------------------------------------------
|"inputs" |
------------------------------------------------------------------------------------------------------
|Snowflake's Data Cloud is powered by an advanced data platform provided as a self-managed service. |
------------------------------------------------------------------------------------------------------
出力¶
translation_text
:num_return_sequences
が1の場合、生成された翻訳を表す文字列。または、translation_text
などのフィールドをそれぞれ含む、結果ディクショナリのリスト JSON の文字列表現。
例:
---------------------------------------------------------------------------------------------------------------------------------
|"translation_text" |
---------------------------------------------------------------------------------------------------------------------------------
|Le Cloud de données de Snowflake est alimenté par une plate-forme de données avancée fournie sous forme de service autogérés. |
---------------------------------------------------------------------------------------------------------------------------------
ゼロショット分類¶
タスクが「 zero-shot-classification 」であるパイプラインには、以下の入出力があります。
入力¶
sequences
:分類するテキストを含む文字列。candidate_labels
:テキストに適用するラベルを含む文字列のリスト。
例:
-----------------------------------------------------------------------------------------
|"sequences" |"candidate_labels" |
-----------------------------------------------------------------------------------------
|I have a problem with Snowflake that needs to be resolved asap!! |[ |
| | "urgent", |
| | "not urgent" |
| |] |
|I have a problem with Snowflake that needs to be resolved asap!! |[ |
| | "English", |
| | "Japanese" |
| |] |
-----------------------------------------------------------------------------------------
出力¶
sequence
:入力文字列。labels
:適用されたラベルを表す文字列のリスト。scores
:各ラベルの浮動小数点信頼度スコアのリスト。
例:
--------------------------------------------------------------------------------------------------------------
|"sequence" |"labels" |"scores" |
--------------------------------------------------------------------------------------------------------------
|I have a problem with Snowflake that needs to be resolved asap!! |[ |[ |
| | "urgent", | 0.9952737092971802, |
| | "not urgent" | 0.004726255778223276 |
| |] |] |
|I have a problem with Snowflake that needs to be resolved asap!! |[ |[ |
| | "Japanese", | 0.5790848135948181, |
| | "English" | 0.42091524600982666 |
| |] |] |
--------------------------------------------------------------------------------------------------------------