前回の記事では、「elasticsearch:インジェスト言語プロセッサを。」その記事では、この作業を完了するために、プラグインのコミュニティを使用しています。弾性スタックのリリース7.6では、私たちはあなたを伝えるために喜んでいる:弾性スタックでは、我々は音声認識プロセッサを統合しました。
ハンズ
まず第一に、私たちは、弾性スタック7.6の最新版をインストールする必要があります。私たちは、中Kibanaで次のコマンドを入力します。
PUT _ingest/pipeline/my-pipeline-id
{
"description": "describe pipeline",
"processors": [
{
"inference": {
"model_id": "lang_ident_model_1",
"inference_config": {
"classification": {
"num_top_classes": 1
}
},
"field_mappings": {}
}
}
]
}
我々はパイプラインを作成する上記の私のパイプライン-IDのと呼ばれます。我々はElasticsearchに文書を入れたときに、私たちは、このパイプラインを参照することができます。
POST test/_doc/1?pipeline=my-pipeline-id
{
"text": "我爱北京天安门"
}
上記では、「持っているI愛北京天安門にElasticsearchに書かれています」。我々は、次のコマンドで書き込まれた情報を確認することができます。
GET test/_doc/1/
次のように私たちは応答を見ることができます:
{
"_index" : "test",
"_type" : "_doc",
"_id" : "1",
"_version" : 2,
"_seq_no" : 1,
"_primary_term" : 1,
"found" : true,
"_source" : {
"text" : "我爱北京天安门",
"ml" : {
"inference" : {
"top_classes" : [
{
"class_name" : "zh",
"class_probability" : 0.9999770918986735,
"class_score" : 0.9999770918986735
}
],
"predicted_value" : "zh",
"model_id" : "lang_ident_model_1"
}
}
}
}
上記では、我々はml.inference.predicated_valueというフィールドを見ることができ、それは言語ZHを示し、中国です。
同様に、私たちは日本語など他の言語に実験を行うことができます。
POST test/_doc/2?pipeline=my-pipeline-id
{
"text": "これはフリーテキストです。"
}
それでは、次のコマンドにより、文書入力をチェックしてみましょう:
GET test/_doc/2/
上記の返された結果は以下のとおりです。
{
"_index" : "test",
"_type" : "_doc",
"_id" : "2",
"_version" : 2,
"_seq_no" : 3,
"_primary_term" : 1,
"found" : true,
"_source" : {
"text" : "これはフリーテキストです。",
"ml" : {
"inference" : {
"top_classes" : [
{
"class_name" : "ja",
"class_probability" : 0.999997979528696,
"class_score" : 0.999997979528696
}
],
"predicted_value" : "ja",
"model_id" : "lang_ident_model_1"
}
}
}
}
ml.inference.predicted_value上記に示した日本語である「JA」です。
我々はテストに_simulateパイプラインを使用する場合は、次に我々は、次のコマンドを使用できます。
POST _ingest/pipeline/_simulate
{
"pipeline": {
"processors": [
{
"inference": {
"model_id": "lang_ident_model_1",
"inference_config": {
"classification": {
"num_top_classes": 1
}
},
"field_mappings": {
}
}
}
]
},
"docs": [
{"_source": {"text": "this is some free text."}},
{"_source": {"text": "c'est du texte libre."}},
{"_source": {"text": "Dies ist ein Freitext."}},
{"_source": {"text": "これはフリーテキストです。"}},
{"_source": {"text": "یہ کچھ مفت متن ہے۔"}},
{"_source": {"text": "我爱北京天安门"}}
]
}
結果はそれを示しています。
{
"docs" : [
{
"doc" : {
"_index" : "_index",
"_type" : "_doc",
"_id" : "_id",
"_source" : {
"text" : "this is some free text.",
"ml" : {
"inference" : {
"top_classes" : [
{
"class_name" : "en",
"class_probability" : 0.9999832919481261,
"class_score" : 0.9999832919481261
}
],
"predicted_value" : "en",
"model_id" : "lang_ident_model_1"
}
}
},
"_ingest" : {
"timestamp" : "2020-03-04T05:51:26.380985Z"
}
}
},
{
"doc" : {
"_index" : "_index",
"_type" : "_doc",
"_id" : "_id",
"_source" : {
"text" : "c'est du texte libre.",
"ml" : {
"inference" : {
"top_classes" : [
{
"class_name" : "fr",
"class_probability" : 0.996991483545992,
"class_score" : 0.996991483545992
}
],
"predicted_value" : "fr",
"model_id" : "lang_ident_model_1"
}
}
},
"_ingest" : {
"timestamp" : "2020-03-04T05:51:26.380988Z"
}
}
},
{
"doc" : {
"_index" : "_index",
"_type" : "_doc",
"_id" : "_id",
"_source" : {
"text" : "Dies ist ein Freitext.",
"ml" : {
"inference" : {
"top_classes" : [
{
"class_name" : "de",
"class_probability" : 0.9999995801281829,
"class_score" : 0.9999995801281829
}
],
"predicted_value" : "de",
"model_id" : "lang_ident_model_1"
}
}
},
"_ingest" : {
"timestamp" : "2020-03-04T05:51:26.38099Z"
}
}
},
{
"doc" : {
"_index" : "_index",
"_type" : "_doc",
"_id" : "_id",
"_source" : {
"text" : "これはフリーテキストです。",
"ml" : {
"inference" : {
"top_classes" : [
{
"class_name" : "ja",
"class_probability" : 0.999997979528696,
"class_score" : 0.999997979528696
}
],
"predicted_value" : "ja",
"model_id" : "lang_ident_model_1"
}
}
},
"_ingest" : {
"timestamp" : "2020-03-04T05:51:26.380992Z"
}
}
},
{
"doc" : {
"_index" : "_index",
"_type" : "_doc",
"_id" : "_id",
"_source" : {
"text" : "یہ کچھ مفت متن ہے۔",
"ml" : {
"inference" : {
"top_classes" : [
{
"class_name" : "ur",
"class_probability" : 0.9999762917090316,
"class_score" : 0.9999762917090316
}
],
"predicted_value" : "ur",
"model_id" : "lang_ident_model_1"
}
}
},
"_ingest" : {
"timestamp" : "2020-03-04T05:51:26.380994Z"
}
}
},
{
"doc" : {
"_index" : "_index",
"_type" : "_doc",
"_id" : "_id",
"_source" : {
"text" : "我爱北京天安门",
"ml" : {
"inference" : {
"top_classes" : [
{
"class_name" : "zh",
"class_probability" : 0.9999770918986735,
"class_score" : 0.9999770918986735
}
],
"predicted_value" : "zh",
"model_id" : "lang_ident_model_1"
}
}
},
"_ingest" : {
"timestamp" : "2020-03-04T05:51:26.380995Z"
}
}
}
]
}