Aprendendo a se classificar no Amazon OpenSearch Service - OpenSearch Serviço Amazon

As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.

Aprendendo a se classificar no Amazon OpenSearch Service

OpenSearch usa uma estrutura de classificação probabilística chamada BM-25 para calcular as pontuações de relevância. Se uma palavra-chave distintiva aparece com mais frequência em um documento, o BM-25 atribui uma pontuação de relevância maior a esse documento. Esse framework, no entanto, não leva em conta o comportamento do usuário, como dados de cliques, o que pode melhorar ainda mais a relevância.

O Learning to Rank é um plug-in de código aberto que permite que você use machine learning e dados comportamentais para ajustar a relevância de documentos. Ele usa modelos das bibliotecas XGBoost e Ranklib para reclassificar os resultados da pesquisa. O plugin Elasticsearch LTR foi desenvolvido inicialmente pela OpenSource Connections, com contribuições significativas da Fundação Wikimedia, Snagajob Engineering, Bonsai e Yelp Engineering. A OpenSearch versão do plug-in é derivada do plug-in Elasticsearch LTR.

Aprender a classificar requer o Elasticsearch 7.7 OpenSearch ou posterior. Para usar o plug-in Learning to Rank, é necessário ter permissões de administrador completas. Para saber mais, consulte Modificação do usuário primário.

nota

Esta documentação fornece uma visão geral do plug-in Learning to Rank e ajuda você a começar a usá-lo. A documentação completa, incluindo etapas detalhadas e descrições da API, está disponível na documentação do Learning to Rank.

Conceitos básicos do Learning to Rank

Você precisa fornecer uma lista de julgamentos, preparar um conjunto de dados de treinamento e treinar o modelo fora do Amazon OpenSearch Service. As peças em azul ocorrem fora do OpenSearch Serviço:

Exemplo de processo de plug-in Learning to Rank.

Etapa 1: Inicializar o plug-in

Para inicializar o plug-in Learning to Rank, envie a seguinte solicitação para seu domínio OpenSearch de serviço:

PUT _ltr
{ "acknowledged" : true, "shards_acknowledged" : true, "index" : ".ltrstore" }

Este comando cria um índice .ltrstore oculto que armazena informações de metadados, como conjuntos de recursos e modelos.

Etapa 2: Criar uma lista de julgamento

nota

Você deve executar essa etapa fora do OpenSearch Serviço.

Uma lista de julgamentos é uma coleção de exemplos com os quais um modelo de machine learning aprende. Sua lista de julgamento deve incluir palavras-chave que são importantes para você e um conjunto de documentos classificados para cada palavra-chave.

Neste exemplo, temos uma lista de julgamento para um conjunto de dados de filmes. Um grau 4 indica uma combinação perfeita. Um grau 0 indica a pior correspondência.

Grau Palavra-chave ID do documento Nome do filme
4 rambo 7555 Rambo
3 rambo 1370 Rambo III
3 rambo 1369 Rambo: First Blood Part II
3 rambo 1368 First Blood

Prepare sua lista de julgamento no seguinte formato:

4 qid:1 # 7555 Rambo 3 qid:1 # 1370 Rambo III 3 qid:1 # 1369 Rambo: First Blood Part II 3 qid:1 # 1368 First Blood where qid:1 represents "rambo"

Para um exemplo mais completo de uma lista de julgamento, consulte Julgamentos de filmes.

Você pode criar essa lista de julgamentos manualmente com a ajuda de anotadores humanos ou inferi-la programaticamente a partir de dados analíticos.

Etapa 3: Construir um conjunto de recursos

Um recurso é um campo que corresponde à relevância de um documento — por exemplo, title, overview, popularity score(número de visualizações) e assim por diante.

Crie um conjunto de recursos com um modelo do Mustache para cada recurso. Para obter mais informações sobre os recursos, consulte Como trabalhar com recursos.

Neste exemplo, construímos um conjunto de recursos movie_features com os campos title e overview:

POST _ltr/_featureset/movie_features { "featureset" : { "name" : "movie_features", "features" : [ { "name" : "1", "params" : [ "keywords" ], "template_language" : "mustache", "template" : { "match" : { "title" : "{{keywords}}" } } }, { "name" : "2", "params" : [ "keywords" ], "template_language" : "mustache", "template" : { "match" : { "overview" : "{{keywords}}" } } } ] } }

Se você consultar o índice .ltrstore original, obterá seu conjunto de recursos de volta:

GET _ltr/_featureset

Etapa 4: Registrar os valores dos recursos

Os valores dos recursos são as pontuações de relevância calculadas pelo BM-25 para cada recurso.

Combine o conjunto de recursos e a lista de julgamento para registrar os valores dos recursos. Para obter mais informações sobre recursos de registro em log do, consulte Pontuações de recursos de registro.

Neste exemplo, a consulta bool recupera os documentos classificados com o filtro e, em seguida, seleciona o conjunto de recursos com a consulta sltr. A consulta ltr_log combina os documentos e os recursos para registrar os valores dos recursos correspondentes:

POST tmdb/_search { "_source": { "includes": [ "title", "overview" ] }, "query": { "bool": { "filter": [ { "terms": { "_id": [ "7555", "1370", "1369", "1368" ] } }, { "sltr": { "_name": "logged_featureset", "featureset": "movie_features", "params": { "keywords": "rambo" } } } ] } }, "ext": { "ltr_log": { "log_specs": { "name": "log_entry1", "named_query": "logged_featureset" } } } }

Uma resposta de exemplo pode ser a seguinte:

{ "took" : 7, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 4, "relation" : "eq" }, "max_score" : 0.0, "hits" : [ { "_index" : "tmdb", "_type" : "movie", "_id" : "1368", "_score" : 0.0, "_source" : { "overview" : "When former Green Beret John Rambo is harassed by local law enforcement and arrested for vagrancy, the Vietnam vet snaps, runs for the hills and rat-a-tat-tats his way into the action-movie hall of fame. Hounded by a relentless sheriff, Rambo employs heavy-handed guerilla tactics to shake the cops off his tail.", "title" : "First Blood" }, "fields" : { "_ltrlog" : [ { "log_entry1" : [ { "name" : "1" }, { "name" : "2", "value" : 10.558305 } ] } ] }, "matched_queries" : [ "logged_featureset" ] }, { "_index" : "tmdb", "_type" : "movie", "_id" : "7555", "_score" : 0.0, "_source" : { "overview" : "When governments fail to act on behalf of captive missionaries, ex-Green Beret John James Rambo sets aside his peaceful existence along the Salween River in a war-torn region of Thailand to take action. Although he's still haunted by violent memories of his time as a U.S. soldier during the Vietnam War, Rambo can hardly turn his back on the aid workers who so desperately need his help.", "title" : "Rambo" }, "fields" : { "_ltrlog" : [ { "log_entry1" : [ { "name" : "1", "value" : 11.2569065 }, { "name" : "2", "value" : 9.936821 } ] } ] }, "matched_queries" : [ "logged_featureset" ] }, { "_index" : "tmdb", "_type" : "movie", "_id" : "1369", "_score" : 0.0, "_source" : { "overview" : "Col. Troutman recruits ex-Green Beret John Rambo for a highly secret and dangerous mission. Teamed with Co Bao, Rambo goes deep into Vietnam to rescue POWs. Deserted by his own team, he's left in a hostile jungle to fight for his life, avenge the death of a woman and bring corrupt officials to justice.", "title" : "Rambo: First Blood Part II" }, "fields" : { "_ltrlog" : [ { "log_entry1" : [ { "name" : "1", "value" : 6.334839 }, { "name" : "2", "value" : 10.558305 } ] } ] }, "matched_queries" : [ "logged_featureset" ] }, { "_index" : "tmdb", "_type" : "movie", "_id" : "1370", "_score" : 0.0, "_source" : { "overview" : "Combat has taken its toll on Rambo, but he's finally begun to find inner peace in a monastery. When Rambo's friend and mentor Col. Trautman asks for his help on a top secret mission to Afghanistan, Rambo declines but must reconsider when Trautman is captured.", "title" : "Rambo III" }, "fields" : { "_ltrlog" : [ { "log_entry1" : [ { "name" : "1", "value" : 9.425955 }, { "name" : "2", "value" : 11.262714 } ] } ] }, "matched_queries" : [ "logged_featureset" ] } ] } }

No exemplo anterior, o primeiro recurso não tem um valor de recurso porque a palavra-chave “rambo” não aparece no campo título do documento com um ID igual a 1368. Este é um valor de recurso ausente nos dados de treinamento.

Etapa 5: Criar um conjunto de dados de treinamento

nota

Você deve executar essa etapa fora do OpenSearch Serviço.

A próxima etapa é combinar a lista de julgamento e os valores de recursos para criar um conjunto de dados de treinamento. Se a lista de julgamento original é semelhante a:

4 qid:1 # 7555 Rambo 3 qid:1 # 1370 Rambo III 3 qid:1 # 1369 Rambo: First Blood Part II 3 qid:1 # 1368 First Blood

Converta-a para o conjunto de dados de treinamento final, que é semelhante a:

4 qid:1 1:12.318474 2:10.573917 # 7555 rambo 3 qid:1 1:10.357875 2:11.950391 # 1370 rambo 3 qid:1 1:7.010513 2:11.220095 # 1369 rambo 3 qid:1 1:0.0 2:11.220095 # 1368 rambo

Você pode executar esta etapa manualmente ou escrever um programa para automatizá-la.

Etapa 6: Escolher um algoritmo e construir o modelo

nota

Você deve executar essa etapa fora do OpenSearch Serviço.

Com o conjunto de dados de treinamento instalado, o próximo passo é usar bibliotecas XGBoost ou Ranklib para construir um modelo. As bibliotecas XGBoost e Ranklib permitem criar modelos populares como LambdaMART, Random Forests e assim por diante.

Para ver as etapas de uso do XGBoost e do Ranklib para criar o modelo, consulte o XGBoost e a documentação, respectivamente. RankLib Para usar a Amazon SageMaker para criar o modelo XGBoost, consulte Algoritmo XGBoost.

Etapa 7: Implantar o modelo

Depois de criar o modelo, implante-o no plug-in Learning to Rank. Para obter mais informações sobre como implantar um modelo, consulte Carregar um modelo treinado.

Neste exemplo, construímos um modelo my_ranklib_model usando a biblioteca Ranklib:

POST _ltr/_featureset/movie_features/_createmodel?pretty { "model": { "name": "my_ranklib_model", "model": { "type": "model/ranklib", "definition": """## LambdaMART ## No. of trees = 10 ## No. of leaves = 10 ## No. of threshold candidates = 256 ## Learning rate = 0.1 ## Stop early = 100 <ensemble> <tree id="1" weight="0.1"> <split> <feature>1</feature> <threshold>10.357875</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-2.0</output> </split> <split pos="right"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <output>-2.0</output> </split> <split pos="right"> <output>-2.0</output> </split> </split> </split> <split pos="right"> <output>2.0</output> </split> </split> </tree> <tree id="2" weight="0.1"> <split> <feature>1</feature> <threshold>10.357875</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.67031991481781</output> </split> <split pos="right"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <output>-1.67031991481781</output> </split> <split pos="right"> <output>-1.6703200340270996</output> </split> </split> </split> <split pos="right"> <output>1.6703201532363892</output> </split> </split> </tree> <tree id="3" weight="0.1"> <split> <feature>2</feature> <threshold>10.573917</threshold> <split pos="left"> <output>1.479954481124878</output> </split> <split pos="right"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.4799546003341675</output> </split> <split pos="right"> <output>-1.479954481124878</output> </split> </split> <split pos="right"> <output>-1.479954481124878</output> </split> </split> </split> </tree> <tree id="4" weight="0.1"> <split> <feature>1</feature> <threshold>10.357875</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.3569872379302979</output> </split> <split pos="right"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <output>-1.3569872379302979</output> </split> <split pos="right"> <output>-1.3569872379302979</output> </split> </split> </split> <split pos="right"> <output>1.3569873571395874</output> </split> </split> </tree> <tree id="5" weight="0.1"> <split> <feature>1</feature> <threshold>10.357875</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.2721362113952637</output> </split> <split pos="right"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <output>-1.2721363306045532</output> </split> <split pos="right"> <output>-1.2721363306045532</output> </split> </split> </split> <split pos="right"> <output>1.2721362113952637</output> </split> </split> </tree> <tree id="6" weight="0.1"> <split> <feature>1</feature> <threshold>10.357875</threshold> <split pos="left"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.2110036611557007</output> </split> <split pos="right"> <output>-1.2110036611557007</output> </split> </split> <split pos="right"> <output>-1.2110037803649902</output> </split> </split> <split pos="right"> <output>1.2110037803649902</output> </split> </split> </tree> <tree id="7" weight="0.1"> <split> <feature>1</feature> <threshold>10.357875</threshold> <split pos="left"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.165616512298584</output> </split> <split pos="right"> <output>-1.165616512298584</output> </split> </split> <split pos="right"> <output>-1.165616512298584</output> </split> </split> <split pos="right"> <output>1.165616512298584</output> </split> </split> </tree> <tree id="8" weight="0.1"> <split> <feature>1</feature> <threshold>10.357875</threshold> <split pos="left"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.131177544593811</output> </split> <split pos="right"> <output>-1.131177544593811</output> </split> </split> <split pos="right"> <output>-1.131177544593811</output> </split> </split> <split pos="right"> <output>1.131177544593811</output> </split> </split> </tree> <tree id="9" weight="0.1"> <split> <feature>2</feature> <threshold>10.573917</threshold> <split pos="left"> <output>1.1046180725097656</output> </split> <split pos="right"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.1046180725097656</output> </split> <split pos="right"> <output>-1.1046180725097656</output> </split> </split> <split pos="right"> <output>-1.1046180725097656</output> </split> </split> </split> </tree> <tree id="10" weight="0.1"> <split> <feature>1</feature> <threshold>10.357875</threshold> <split pos="left"> <feature>1</feature> <threshold>7.010513</threshold> <split pos="left"> <feature>1</feature> <threshold>0.0</threshold> <split pos="left"> <output>-1.0838804244995117</output> </split> <split pos="right"> <output>-1.0838804244995117</output> </split> </split> <split pos="right"> <output>-1.0838804244995117</output> </split> </split> <split pos="right"> <output>1.0838804244995117</output> </split> </split> </tree> </ensemble> """ } } }

Para ver o modelo, envie a seguinte solicitação:

GET _ltr/_model/my_ranklib_model

Etapa 8: Pesquisar com Learning to Rank

Após a implantação do modelo, você estará pronto para pesquisar.

Execute a consulta sltr com os recursos que você está usando e o nome do modelo que deseja executar:

POST tmdb/_search { "_source": { "includes": ["title", "overview"] }, "query": { "multi_match": { "query": "rambo", "fields": ["title", "overview"] } }, "rescore": { "query": { "rescore_query": { "sltr": { "params": { "keywords": "rambo" }, "model": "my_ranklib_model" } } } } }

Com o Learning to Rank, você vê “Rambo” como o primeiro resultado porque nós atribuímos a ele a nota mais alta na lista de julgamento:

{ "took" : 12, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 7, "relation" : "eq" }, "max_score" : 13.096414, "hits" : [ { "_index" : "tmdb", "_type" : "movie", "_id" : "7555", "_score" : 13.096414, "_source" : { "overview" : "When governments fail to act on behalf of captive missionaries, ex-Green Beret John James Rambo sets aside his peaceful existence along the Salween River in a war-torn region of Thailand to take action. Although he's still haunted by violent memories of his time as a U.S. soldier during the Vietnam War, Rambo can hardly turn his back on the aid workers who so desperately need his help.", "title" : "Rambo" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "1370", "_score" : 11.17245, "_source" : { "overview" : "Combat has taken its toll on Rambo, but he's finally begun to find inner peace in a monastery. When Rambo's friend and mentor Col. Trautman asks for his help on a top secret mission to Afghanistan, Rambo declines but must reconsider when Trautman is captured.", "title" : "Rambo III" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "1368", "_score" : 10.442155, "_source" : { "overview" : "When former Green Beret John Rambo is harassed by local law enforcement and arrested for vagrancy, the Vietnam vet snaps, runs for the hills and rat-a-tat-tats his way into the action-movie hall of fame. Hounded by a relentless sheriff, Rambo employs heavy-handed guerilla tactics to shake the cops off his tail.", "title" : "First Blood" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "1369", "_score" : 10.442155, "_source" : { "overview" : "Col. Troutman recruits ex-Green Beret John Rambo for a highly secret and dangerous mission. Teamed with Co Bao, Rambo goes deep into Vietnam to rescue POWs. Deserted by his own team, he's left in a hostile jungle to fight for his life, avenge the death of a woman and bring corrupt officials to justice.", "title" : "Rambo: First Blood Part II" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "31362", "_score" : 7.424202, "_source" : { "overview" : "It is 1985, and a small, tranquil Florida town is being rocked by a wave of vicious serial murders and bank robberies. Particularly sickening to the authorities is the gratuitous use of violence by two “Rambo” like killers who dress themselves in military garb. Based on actual events taken from FBI files, the movie depicts the Bureau’s efforts to track down these renegades.", "title" : "In the Line of Duty: The F.B.I. Murders" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "13258", "_score" : 6.43182, "_source" : { "overview" : """Will Proudfoot (Bill Milner) is looking for an escape from his family's stifling home life when he encounters Lee Carter (Will Poulter), the school bully. Armed with a video camera and a copy of "Rambo: First Blood", Lee plans to make cinematic history by filming his own action-packed video epic. Together, these two newfound friends-turned-budding-filmmakers quickly discover that their imaginative ― and sometimes mishap-filled ― cinematic adventure has begun to take on a life of its own!""", "title" : "Son of Rambow" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "61410", "_score" : 3.9719706, "_source" : { "overview" : "It's South Africa 1990. Two major events are about to happen: The release of Nelson Mandela and, more importantly, it's Spud Milton's first year at an elite boys only private boarding school. John Milton is a boy from an ordinary background who wins a scholarship to a private school in Kwazulu-Natal, South Africa. Surrounded by boys with nicknames like Gecko, Rambo, Rain Man and Mad Dog, Spud has his hands full trying to adapt to his new home. Along the way Spud takes his first tentative steps along the path to manhood. (The path it seems could be a rather long road). Spud is an only child. He is cursed with parents from well beyond the lunatic fringe and a senile granny. His dad is a fervent anti-communist who is paranoid that the family domestic worker is running a shebeen from her room at the back of the family home. His mom is a free spirit and a teenager's worst nightmare, whether it's shopping for Spud's underwear in the local supermarket", "title" : "Spud" } } ] } }

Se você pesquisar sem usar o plug-in Learning to Rank, OpenSearch retornará resultados diferentes:

POST tmdb/_search { "_source": { "includes": ["title", "overview"] }, "query": { "multi_match": { "query": "Rambo", "fields": ["title", "overview"] } } }
{ "took" : 5, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 5, "relation" : "eq" }, "max_score" : 11.262714, "hits" : [ { "_index" : "tmdb", "_type" : "movie", "_id" : "1370", "_score" : 11.262714, "_source" : { "overview" : "Combat has taken its toll on Rambo, but he's finally begun to find inner peace in a monastery. When Rambo's friend and mentor Col. Trautman asks for his help on a top secret mission to Afghanistan, Rambo declines but must reconsider when Trautman is captured.", "title" : "Rambo III" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "7555", "_score" : 11.2569065, "_source" : { "overview" : "When governments fail to act on behalf of captive missionaries, ex-Green Beret John James Rambo sets aside his peaceful existence along the Salween River in a war-torn region of Thailand to take action. Although he's still haunted by violent memories of his time as a U.S. soldier during the Vietnam War, Rambo can hardly turn his back on the aid workers who so desperately need his help.", "title" : "Rambo" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "1368", "_score" : 10.558305, "_source" : { "overview" : "When former Green Beret John Rambo is harassed by local law enforcement and arrested for vagrancy, the Vietnam vet snaps, runs for the hills and rat-a-tat-tats his way into the action-movie hall of fame. Hounded by a relentless sheriff, Rambo employs heavy-handed guerilla tactics to shake the cops off his tail.", "title" : "First Blood" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "1369", "_score" : 10.558305, "_source" : { "overview" : "Col. Troutman recruits ex-Green Beret John Rambo for a highly secret and dangerous mission. Teamed with Co Bao, Rambo goes deep into Vietnam to rescue POWs. Deserted by his own team, he's left in a hostile jungle to fight for his life, avenge the death of a woman and bring corrupt officials to justice.", "title" : "Rambo: First Blood Part II" } }, { "_index" : "tmdb", "_type" : "movie", "_id" : "13258", "_score" : 6.4600153, "_source" : { "overview" : """Will Proudfoot (Bill Milner) is looking for an escape from his family's stifling home life when he encounters Lee Carter (Will Poulter), the school bully. Armed with a video camera and a copy of "Rambo: First Blood", Lee plans to make cinematic history by filming his own action-packed video epic. Together, these two newfound friends-turned-budding-filmmakers quickly discover that their imaginative ― and sometimes mishap-filled ― cinematic adventure has begun to take on a life of its own!""", "title" : "Son of Rambow" } } ] } }

Com base no quanto bem você acha que o modelo está funcionando, ajuste a lista de julgamento e os recursos. Em seguida, repita as etapas 2 a 8 para melhorar os resultados da classificação ao longo do tempo.

API do Learning to Rank

Use as operações do Learning to Rank para trabalhar programaticamente com conjuntos de recursos e modelos.

Criar armazenamento

Cria um índice .ltrstore oculto que armazena informações de metadados, como conjuntos de recursos e modelos.

PUT _ltr

Excluir armazenamento

Exclui o índice .ltrstore oculto e redefine o plug-in.

DELETE _ltr

Criar conjunto de recursos

Cria um conjunto de recursos.

POST _ltr/_featureset/<name_of_features>

Excluir conjunto de recursos

Exclui um conjunto de recursos.

DELETE _ltr/_featureset/<name_of_feature_set>

Obter conjunto de recursos

Recupera um conjunto de recursos.

GET _ltr/_featureset/<name_of_feature_set>

Criar modelo

Cria um modelo.

POST _ltr/_featureset/<name_of_feature_set>/_createmodel

Excluir modelo

Exclui um modelo.

DELETE _ltr/_model/<name_of_model>

Obter modelo

Recupera um modelo.

GET _ltr/_model/<name_of_model>

Obter estatísticas

Fornece informações sobre como o plug-in está se comportando.

GET _ltr/_stats

Também é possível usar filtros para recuperar uma única estatística:

GET _ltr/_stats/<stat>

Além disso, é possível limitar as informações a um único nó no cluster:

GET _ltr/_stats/<stat>/nodes/<nodeId> { "_nodes" : { "total" : 1, "successful" : 1, "failed" : 0 }, "cluster_name" : "873043598401:ltr-77", "stores" : { ".ltrstore" : { "model_count" : 1, "featureset_count" : 1, "feature_count" : 2, "status" : "green" } }, "status" : "green", "nodes" : { "DjelK-_ZSfyzstO5dhGGQA" : { "cache" : { "feature" : { "eviction_count" : 0, "miss_count" : 0, "entry_count" : 0, "memory_usage_in_bytes" : 0, "hit_count" : 0 }, "featureset" : { "eviction_count" : 2, "miss_count" : 2, "entry_count" : 0, "memory_usage_in_bytes" : 0, "hit_count" : 0 }, "model" : { "eviction_count" : 2, "miss_count" : 3, "entry_count" : 1, "memory_usage_in_bytes" : 3204, "hit_count" : 1 } }, "request_total_count" : 6, "request_error_count" : 0 } } }

As estatísticas são fornecidas em dois níveis, nó e cluster, conforme especificado nas seguintes tabelas:

Estatísticas em nível de nó
Nome do campo Descrição
request_total_count Contagem total de solicitações de classificação.
request_error_count Contagem total de solicitações malsucedidas.
cache Estatísticas em todos os caches (recursos, conjuntos de recursos, modelos). Um acerto de cache ocorre quando um usuário consulta o plug-in e o modelo já está carregado na memória.
cache.eviction_count Número de remoções de cache.
cache.hit_count Número de acertos de cache.
cache.miss_count Número de perdas no cache. Uma perda de cache ocorre quando um usuário consulta o plug-in e o modelo ainda não está carregado na memória.
cache.entry_count Número de entradas no cache.
cache.memory_usage_in_bytes Memória total usada em bytes.
cache.cache_capacity_reached Indica se o limite de cache foi atingido.
Estatísticas em nível de cluster
Nome do campo Descrição
stores Indica onde os conjuntos de recursos e metadados de modelos são armazenados. (O padrão é “.ltrstore”. Caso contrário, é prefixado com “.ltrstore_”, mais um nome fornecido pelo usuário).
stores.status O status do índice.
stores.feature_sets Número de conjuntos de recursos.
stores.features_count Número de recursos.
stores.model_count Número de modelos.
status O status do plug-in baseado no status dos índices da feature store (vermelho, amarelo ou verde) e estado do disjuntor (aberto ou fechado).
cache.cache_capacity_reached Indica se o limite de cache foi atingido.

Get cache stats (Obter estatísticas de cache)

Retorna estatísticas sobre o uso do cache e da memória.

GET _ltr/_cachestats { "_nodes": { "total": 2, "successful": 2, "failed": 0 }, "cluster_name": "opensearch-cluster", "all": { "total": { "ram": 612, "count": 1 }, "features": { "ram": 0, "count": 0 }, "featuresets": { "ram": 612, "count": 1 }, "models": { "ram": 0, "count": 0 } }, "stores": { ".ltrstore": { "total": { "ram": 612, "count": 1 }, "features": { "ram": 0, "count": 0 }, "featuresets": { "ram": 612, "count": 1 }, "models": { "ram": 0, "count": 0 } } }, "nodes": { "ejF6uutERF20wOFNOXB61A": { "name": "opensearch1", "hostname": "172.18.0.4", "stats": { "total": { "ram": 612, "count": 1 }, "features": { "ram": 0, "count": 0 }, "featuresets": { "ram": 612, "count": 1 }, "models": { "ram": 0, "count": 0 } } }, "Z2RZNWRLSveVcz2c6lHf5A": { "name": "opensearch2", "hostname": "172.18.0.2", "stats": { ... } } } }

Clear cache (Limpar cache)

Limpa o cache do plug-in. Use esta opção para atualizar o modelo.

POST _ltr/_clearcache