AI盗作:Elasticsearchによる盗作検出
ここでは、NLP モデルと Vector Search のユースケースに焦点を当て、Elasticsearch を使用して AI の盗用をチェックする方法を説明します。
盗作には、直接的な盗用(コンテンツの一部または全体をコピーする)と言い換えれば言い換え(著者の作品のいくつかの単語やフレーズを変更して言い換える)があります。

インスピレーションと言い換えには違いがあります。コンテンツを読んでインスピレーションを得て、たとえ同じような結論に達したとしても、自分の言葉でそのアイデアを探求することは可能です。
盗作は長い間議論されてきたテーマですが、コンテンツの制作と公開が加速するにつれて、盗作は関連性を保ち、継続的な課題となっています。

この課題は、盗作チェックが頻繁に行われる書籍、学術研究、司法文書に限定されません。それは新聞やソーシャルメディアにも及ぶ可能性があります。
情報が豊富で出版物に簡単にアクセスできるようになった今、スケーラブルなレベルで盗作を効果的にチェックするにはどうすればよいでしょうか?
大学、政府機関、企業はさまざまなツールを使用していますが、単純な語彙検索で直接的な盗用を効果的に検出できる一方で、言い換えられたコンテンツを特定することが主な課題です。
生成AIによる盗作検出
生成 AI によって新たな課題が生まれます。AI によって生成されたコンテンツは、コピーされた場合に盗作とみなされますか?

たとえば、 OpenAI の利用規約では、OpenAI はユーザー向けに API によって生成されたコンテンツに対する著作権を主張しないことが規定されています。この場合、生成 AI を使用する個人は、生成されたコンテンツを引用なしで自由に使用できます。

しかし、効率性を向上させるために生成 AI を使用することが受け入れられるかどうかは、依然として議論の余地があります。
OpenAIは盗作検出に貢献しようと検出モデルを開発したが、後にその精度が十分に高くないことを認めた。
「これは単独の検出では精度が十分ではなく、より効果を上げるにはメタデータベースのアプローチ、人間の判断、一般の教育と組み合わせる必要があると考えています。」
課題は依然として残っていますが、利用できるツールが増えたことにより、言い換えられたコンテンツや AI コンテンツの場合でも盗作を検出するための選択肢が増えています。
Elasticsearchで盗作を検出する
これを認識して、このブログでは、メタデータ検索を超えて、自然言語処理 (NLP) モデルとベクトル検索、盗作検出を使用したもう 1 つのユース ケースを検討します。
これは Python の例 で実証されており、NLP 関連の記事を含む SentenceTransformers の データセット を活用しています。以前に Elasticsearch にインポートされたテキスト埋め込みモデルで生成された「要約」埋め込みを考慮して「意味的テキスト類似性」を実行することにより、要約の盗用をチェックします。さらに、AI によって生成されたコンテンツ (AI 盗作) を識別するために、OpenAI によって開発されたNLP モデルも Elasticsearch にインポートされました。
次の図はデータ フローを示しています。

推論プロセッサ を使用した 取り込みパイプラインの 実行中に、「abstract」段落は 768 次元のベクトル「abstract_vector.predicted_value」にマッピングされます。
マッピング:
"abstract_vector.predicted_value": { # Inference results field
"type": "dense_vector",
"dims": 768, # model embedding_size
"index": "true",
"similarity": "dot_product" # When indexing vectors for approximate kNN search, you need to specify the similarity function for comparing the vectors.ベクトル表現間の類似性は、「類似性」パラメータを使用して定義されるベクトル類似性メトリックを使用して測定されます。
コサインはデフォルトの類似度メトリックであり、「(1 + cosine(クエリ、ベクトル)) / 2」として計算されます。元のベクトルを保持する必要があり、事前に正規化できない場合を除き、コサイン類似度を実行する最も効率的な方法は、すべてのベクトルを単位長さに正規化することです。これにより、検索中に余分なベクトルの長さの計算を実行することを回避でき、代わりに 'dot_product' を使用できます。
この同じパイプラインでは、テキスト分類モデルを含む別の推論プロセッサが、コンテンツがおそらく人間によって書かれた「本物」か、おそらく AI によって書かれた「偽物」かを検出し、各ドキュメントに「openai-detector.predicted_value」を追加します。
取り込みパイプライン:
client.ingest.put_pipeline(
id="plagiarism-checker-pipeline",
processors = [
{
"inference": { #for ml models - to infer against the data that is being ingested in the pipeline
"model_id": "roberta-base-openai-detector", #text classification model id
"target_field": "openai-detector", # Target field for the inference results
"field_map": { #Maps the document field names to the known field names of the model.
"abstract": "text_field" # Field matching our configured trained model input.
}
}
},
{
"inference": {
"model_id": "sentence-transformers__all-mpnet-base-v2", #text embedding model id
"target_field": "abstract_vector", # Target field for the inference results
"field_map": {
"abstract": "text_field" # Field matching our configured trained model input. Typically for NLP models, the field name is text_field.
}
}
}
]
)クエリ時に、同じテキスト埋め込みモデルを使用して、「query_vector_builder」オブジェクト内のクエリ「model_text」のベクトル表現も生成されます。
k 最近傍 (kNN) 検索は、類似度メトリックによって測定されたクエリ ベクトルに最も近い k ベクトルを見つけます。
各ドキュメントの _score は類似性から導き出され、スコアが大きいほどランキングが高くなります。これは、ドキュメントが意味的に類似していることを意味します。結果として、3 つの可能性を出力します。スコアが 0.9 を超える場合は「高い類似性」を考慮し、スコアが 0.7 未満の場合は「低い類似性」、それ以外の場合は「中程度の類似性」を考慮します。ユースケースに応じて、_score のどのレベルが盗作とみなされるかを決定するために、さまざまなしきい値を柔軟に設定できます。
さらに、テキスト分類が実行され、テキスト クエリ内の AI によって生成された要素もチェックされます。
クエリ:
from elasticsearch import Elasticsearch
from elasticsearch.client import MlClient
#duplicated text - direct plagiarism test
model_text = 'Understanding and reasoning about cooking recipes is a fruitful research direction towards enabling machines to interpret procedural text. In this work, we introduce RecipeQA, a dataset for multimodal comprehension of cooking recipes. It comprises of approximately 20K instructional recipes with multiple modalities such as titles, descriptions and aligned set of images. With over 36K automatically generated question-answer pairs, we design a set of comprehension and reasoning tasks that require joint understanding of images and text, capturing the temporal flow of events and making sense of procedural knowledge. Our preliminary results indicate that RecipeQA will serve as a challenging test bed and an ideal benchmark for evaluating machine comprehension systems. The data and leaderboard are available at http://hucvl.github.io/recipeqa.'
response = client.search(index='plagiarism-checker', size=1,
knn={
"field": "abstract_vector.predicted_value",
"k": 9,
"num_candidates": 974,
"query_vector_builder": { #The 'all-mpnet-base-v2' model is also employed to generate the vector representation of the query in a 'query_vector_builder' object.
"text_embedding": {
"model_id": "sentence-transformers__all-mpnet-base-v2",
"model_text": model_text
}
}
}
)
for hit in response['hits']['hits']:
score = hit['_score']
title = hit['_source']['title']
abstract = hit['_source']['abstract']
openai = hit['_source']['openai-detector']['predicted_value']
url = hit['_source']['url']
if score > 0.9:
print(f"\nHigh similarity detected! This might be plagiarism.")
print(f"\nMost similar document: '{title}'\n\nAbstract: {abstract}\n\nurl: {url}\n\nScore:{score}\n\n")
if openai == 'Fake':
print("This document may have been created by AI.\n")
elif score < 0.7:
print(f"\nLow similarity detected. This might not be plagiarism.")
if openai == 'Fake':
print("This document may have been created by AI.\n")
else:
print(f"\nModerate similarity detected.")
print(f"\nMost similar document: '{title}'\n\nAbstract: {abstract}\n\nurl: {url}\n\nScore:{score}\n\n")
if openai == 'Fake':
print("This document may have been created by AI.\n")
ml_client = MlClient(client)
model_id = 'roberta-base-openai-detector' #open ai text classification model
document = [
{
"text_field": model_text
}
]
ml_response = ml_client.infer_trained_model(model_id=model_id, docs=document)
predicted_value = ml_response['inference_results'][0]['predicted_value']
if predicted_value == 'Fake':
print("\nNote: The text query you entered may have been generated by AI.\n")アウトプット:
High similarity detected! This might be plagiarism.
Most similar document: 'RecipeQA: A Challenge Dataset for Multimodal Comprehension of Cooking Recipes'
Abstract: Understanding and reasoning about cooking recipes is a fruitful research direction towards enabling machines to interpret procedural text. In this work, we introduce RecipeQA, a dataset for multimodal comprehension of cooking recipes. It comprises of approximately 20K instructional recipes with multiple modalities such as titles, descriptions and aligned set of images. With over 36K automatically generated question-answer pairs, we design a set of comprehension and reasoning tasks that require joint understanding of images and text, capturing the temporal flow of events and making sense of procedural knowledge. Our preliminary results indicate that RecipeQA will serve as a challenging test bed and an ideal benchmark for evaluating machine comprehension systems. The data and leaderboard are available at[ http://hucvl.github.io/recipeqa](http://hucvl.github.io/recipeqa).
url:[http://aclweb.org/anthology/D18-1166](http://aclweb.org/anthology/D18-1166)
Score:1.0この例では、データセットの「抽象」値の 1 つをテキスト クエリ「model_text」として使用した後、盗用が特定されました。類似度スコアは 1.0 であり、類似度が高いこと、つまり直接的な盗用であることを示しています。ベクトル化されたクエリとドキュメントは、予想どおり AI 生成コンテンツとして認識されませんでした。
クエリ:
#similar text - paraphrase plagiarism test
model_text = 'Comprehending and deducing information from culinary instructions represents a promising avenue for research aimed at empowering artificial intelligence to decipher step-by-step text. In this study, we present CuisineInquiry, a database for the multifaceted understanding of cooking guidelines. It encompasses a substantial number of informative recipes featuring various elements such as headings, explanations, and a matched assortment of visuals. Utilizing an extensive set of automatically crafted question-answer pairings, we formulate a series of tasks focusing on understanding and logic that necessitate a combined interpretation of visuals and written content. This involves capturing the sequential progression of events and extracting meaning from procedural expertise. Our initial findings suggest that CuisineInquiry is poised to function as a demanding experimental platform.'アウトプット:
High similarity detected! This might be plagiarism.
Most similar document: 'RecipeQA: A Challenge Dataset for Multimodal Comprehension of Cooking Recipes'
Abstract: Understanding and reasoning about cooking recipes is a fruitful research direction towards enabling machines to interpret procedural text. In this work, we introduce RecipeQA, a dataset for multimodal comprehension of cooking recipes. It comprises of approximately 20K instructional recipes with multiple modalities such as titles, descriptions and aligned set of images. With over 36K automatically generated question-answer pairs, we design a set of comprehension and reasoning tasks that require joint understanding of images and text, capturing the temporal flow of events and making sense of procedural knowledge. Our preliminary results indicate that RecipeQA will serve as a challenging test bed and an ideal benchmark for evaluating machine comprehension systems. The data and leaderboard are available at[ http://hucvl.github.io/recipeqa](http://hucvl.github.io/recipeqa).
url:[http://aclweb.org/anthology/D18-1166](http://aclweb.org/anthology/D18-1166)
Score:0.9302529
Note: The text query you entered may have been generated by AI.テキストクエリ「model_text」を、類似した単語の繰り返しを最小限に抑えながら同じメッセージを伝える AI 生成テキストで更新すると、検出された類似度は依然として高かったものの、スコアは 1.0 ではなく 0.9302529 になりました(言い換え盗用) 。AIによって生成されたこのクエリが検出されることも予想されました。
最後に、テキスト クエリ「model_text」を、これらのドキュメントの要約ではない Elasticsearch に関するテキストと見なすと、検出された類似度は 0.68991005 となり、考慮されたしきい値によると類似度が低いことが示されました。
クエリ:
#different text - not a plagiarism
model_text = 'Elasticsearch provides near real-time search and analytics for all types of data.'アウトプット:
Low similarity detected. This might not be plagiarism.AI によって生成されたテキスト クエリでは、言い換えや直接コピーされたコンテンツの場合と同様に、盗用が正確に識別されましたが、盗用検出の状況を把握するには、さまざまな側面を認識する必要があります。
AI 生成コンテンツの検出という観点から、私たちは価値ある貢献を果たすモデルを検討しました。ただし、単独の検出には固有の限界があり、精度を高めるには他の方法を組み込む必要があることを認識することが重要です。
テキスト埋め込みモデルの選択によってもたらされる変動性も、もうひとつの考慮事項です。異なるデータセットでトレーニングされたさまざまなモデルでは、さまざまなレベルの類似性が得られ、生成されたテキスト埋め込みの重要性が強調されます。
最後に、これらの例では、ドキュメントの要約を使用しました。ただし、盗作検出には大きな文書が関係することが多く、テキストの長さの問題に対処することが不可欠です。テキストがモデルのトークン制限を超えることはよくあり、埋め込みを構築する前にチャンクに分割する必要があります。これを処理する実用的なアプローチとしては、dense_vector を使用したネストされた構造を利用することが挙げられます。
まとめ
このブログでは、特に言い換えられたコンテンツや AI によって生成されたコンテンツにおける盗作の検出の課題と、この目的のために意味的なテキストの類似性とテキスト分類をどのように使用できるかについて説明しました。
これらの方法を組み合わせることで、AI によって生成されたコンテンツ、直接的な盗用と言い換えられた盗用を正常に識別した盗用検出の例を示しました。
主な目的は検出を簡素化するフィルタリング システムを確立することですが、検証には人間による評価が依然として不可欠です。
意味的テキスト類似性と NLP についてさらに詳しく知りたい場合は、次のリンクもご覧ください。




