使用 Elasticsearch 检测抄袭 (一)
作者:Priscilla Parodi
抄袭可以是直接的,涉及复制部分或全部内容,也可以是释义的,即通过更改一些单词或短语来重新表述作者的作品。
灵感和释义之间是有区别的。 即使你得出类似的结论,也可以阅读内容,获得灵感,然后用自己的话探索这个想法。
虽然抄袭长期以来一直是讨论的话题,但内容的加速制作和发布使其保持了相关性并构成了持续的挑战。
这一挑战不仅限于经常进行抄袭检查的书籍、学术研究或司法文件。 它还可以扩展到报纸甚至社交媒体。
随着信息的丰富和发布的便捷性,如何在可扩展的水平上有效地检查抄袭行为?
大学、政府实体和公司使用不同的工具,虽然简单的词汇搜索可以有效地检测直接抄袭,但主要的挑战在于识别释义内容。
如果你想一步一步地在你自己的电脑里实现如下的文章中所描述的练习,请详细阅读文章 “使用 Elasticsearch 检测抄袭 (二)”。
使用生成人工智能检测抄袭
生成人工智能出现了新的挑战。 人工智能生成的内容在复制时是否被视为抄袭?
例如,OpenAI 使用条款规定 OpenAI 不会对 API 为用户生成的内容主张版权。 在这种情况下,使用生成式人工智能的个人可以根据自己的喜好使用生成的内容,而无需引用。
然而,是否接受使用生成式人工智能来提高效率仍然是一个讨论的话题。
为了为抄袭检测做出贡献,OpenAI 开发了一个检测模型,但后来承认其准确性不够高。
“我们认为这对于独立检测来说不够高,需要与基于元数据的方法、人类判断和公共教育相结合才能更有效。”
挑战依然存在; 然而,随着更多工具的出现,现在检测抄袭的选项也增加了,即使是在释义和人工智能内容的情况下也是如此。
使用 Elasticsearch 检测抄袭
认识到这一点,在这篇博客中,我们正在探索自然语言处理 (NLP) 模型和向量搜索的另一个用例,即除元数据搜索之外的抄袭检测。
这通过 Python 示例进行了演示,其中我们利用包含 NLP 相关文章的 SentenceTransformers 的数据集。 我们通过执行 “语义文本相似性” 来检查摘要是否抄袭,考虑到使用之前导入 Elasticsearch 的文本嵌入模型生成的 “abstract” 嵌入。 此外,为了识别人工智能生成的内容 —— 人工智能抄袭,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.
向量表示之间的相似性是使用向量相似性度量来测量的,该度量是使用 “similarity” 参数定义的。
余弦是默认的相似度度量,计算公式为 “(1 + cosine(query, vector)) / 2”。 除非需要保留原始向量并且无法提前对它们进行归一化,否则执行余弦相似度的最有效方法是将所有向量归一化为单位长度。 这有助于避免在搜索过程中执行额外的向量长度计算,而是使用 “dot_product”。
在同一管道中,另一个包含文本分类模型的推理处理器会检测内容是可能由人类编写的 “真实” 内容,还是可能由人工智能编写的 “假” 内容,并将 “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 是根据相似度得出的,确保较大的分数对应较高的排名。 这意味着该文档在语义上更加相似。 因此,我们打印三种可能性:如果分数> 0.9,我们正在考虑 “高度相似性”; 如果 < 0.7,“低相似度”,否则,“中等相似度”。 你可以根据你的用例灵活地设置不同的阈值,以确定什么级别的 _score 判定为抄袭。
此外,执行文本分类还可以检查文本查询中人工智能生成的元素。
询问:
from elasticsearch import Elasticsearch
from elasticsearch.client import MlClient#duplicated text - direct plagiarism testmodel_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 modeldocument = [{"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
在此示例中,在利用数据集中的 “abstract” 值之一作为文本查询 “model_text” 后,识别出了抄袭。 相似度得分为1.0,表明相似度很高 —— 直接抄袭。 向量化查询和文档未被识别为人工智能生成的内容,这是预期的。
查询:
#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.9302529Note: The text query you entered may have been generated by AI.
通过使用 AI 生成的文本更新文本查询 “model_text”,该文本传达相同的信息,同时最大限度地减少相似单词的重复,检测到的相似度仍然很高,但得分为 0.9302529,而不是 1.0 —— 释义抄袭 (paraphrase plagiarism) 。 人们还预计该由人工智能生成的查询会被检测到。
最后,考虑到文本查询 “model_text” 是关于 Elasticsearch 的文本,它不是这些文档之一的摘要,检测到的相似度为 0.68991005,根据考虑的阈值表明相似度较低。
查询:
#different text - not a plagiarismmodel_text = 'Elasticsearch provides near real-time search and analytics for all types of data.'
输出:
Low similarity detected. This might not be plagiarism.
尽管在人工智能生成的文本查询中以及在释义和直接复制内容的情况下可以准确地识别出抄袭行为,但在抄袭检测领域的导航涉及到承认各个方面。
在人工智能生成的内容检测的背景下,我们探索了一种做出有价值贡献的模型。 然而,认识到独立检测的固有局限性至关重要,因此需要结合其他方法来提高准确性。
文本嵌入模型的选择带来的可变性是另一个考虑因素。 使用不同数据集训练的不同模型会产生不同程度的相似性,凸显了生成的文本嵌入的重要性。
最后,在这些示例中,我们使用了文档的摘要。 然而,抄袭检测通常涉及大型文档,因此必须解决文本长度的挑战。 文本超出模型的标记限制是很常见的,需要在构建嵌入之前将其分割成块。 处理这个问题的一种实用方法是利用带有 dense_vector 的嵌套结构。
结论:
在这篇博客中,我们讨论了检测剽窃的挑战,特别是在释义和人工智能生成的内容中,以及如何将语义文本相似性和文本分类用于此目的。
通过结合这些方法,我们提供了抄袭检测的示例,其中我们成功识别了人工智能生成的内容、直接抄袭和转述抄袭。
主要目标是建立一个简化检测的过滤系统,但人工评估对于验证仍然至关重要。
如果你有兴趣了解有关语义文本相似性和 NLP 的更多信息,我们鼓励你也查看以下链接:
- 什么是语义搜索?
- 什么是自然语言处理(NLP)?
- 使用 Elasticsearch 进行词汇和语义搜索
- 通过摄取管道加上嵌套向量对大型文档进行分块等于轻松的段落搜索
原文:Elasticsearch:通过摄取管道加上嵌套向量对大型文档进行分块轻松地实现段落搜索-CSDN博客
相关文章:

使用 Elasticsearch 检测抄袭 (一)
作者:Priscilla Parodi 抄袭可以是直接的,涉及复制部分或全部内容,也可以是释义的,即通过更改一些单词或短语来重新表述作者的作品。 灵感和释义之间是有区别的。 即使你得出类似的结论,也可以阅读内容,获得…...

STM32 cubeMX 直流电机控制风扇转动
本文使用的是 HAL 库。 文章目录 前言一、直流电机介绍二、直流电机原理图三、直流电机控制方法四、STM32CubeMX 配置直流电机五、代码编写总结 前言 实验开发板:STM32F051K8。所需软件:keil5 , cubeMX 。实验目的:了解 直流电机…...

我在 VSCode 插件里接入了 ChatGPT,解决了Bug无法定位的难题
作为一名软件开发者,我时常面临着代码中Bug的定位和解决问题。这个过程往往既费时又充满挑战。然而,最近我在我的VSCode插件中接入了ChatGPT,这个决定彻底改变了我处理Bug的方式。 Bug:开发者的噩梦 在开发过程中,遇…...
学Java的第四天
一、switch语句 switch (表达式) { case 1: 语句体1; break; case 2: 语句体2; break; ... default: 语句体n1; break; } 首先计算表达式的值,然后和case 比较,有对应的值就执行对应的语句,遇到 break 就结束。 最后如果所有的cas…...

[内功修炼]函数栈帧的创建与销毁
文章目录 1:什么是函数栈帧2:理解函数栈帧能解决什么问题呢3:函数栈帧的创建与销毁的解析3.1:什么是栈3.2:认识相关寄存器与汇编指令相关寄存器相关汇编指令 3.3 解析函数栈帧的创建和销毁3.3.1 预备知识3.3.2 详细解析一:调用main函数,为main函数开辟函数栈帧First:push前push…...

【深度学习-目标检测】03 - Faster R-CNN 论文学习与总结
论文地址:Faster R-CNN: Towards Real-Time ObjectDetection with Region Proposal Networks 论文学习 1. 摘要与引言 研究背景与挑战:当前最先进的目标检测网络依赖于 区域提议(Region Proposals)来假设目标的位置,…...
oracle11体系结构二-存储结构
数据区: 数据区(数据扩展区)由一组连续的oracle数据块所构成的存储结构,一个或多个数据块组成一个数据区,一个或多个数据区组成一个段。当段中所有空间被使用完后,oracle系统将自动为该段分配一个新的数据…...

如何通过内网穿透实现远程访问本地Linux SVN服务
文章目录 前言1. Ubuntu安装SVN服务2. 修改配置文件2.1 修改svnserve.conf文件2.2 修改passwd文件2.3 修改authz文件 3. 启动svn服务4. 内网穿透4.1 安装cpolar内网穿透4.2 创建隧道映射本地端口 5. 测试公网访问6. 配置固定公网TCP端口地址6.1 保留一个固定的公网TCP端口地址6…...

网页乱码问题(edge浏览器)
网页乱码问题(edge) 文章目录 网页乱码问题(edge)前言一、网页乱码问题1.是什么:(描述)2.解决方法:(针对edge浏览器)(1)下载charset插…...

泛微OA xmlrpcServlet接口任意文件读取漏洞(CNVD-2022-43245)
CNVD-2022-43245 泛微e-cology XmlRpcServlet接口处存在任意文件读取漏洞,攻击者可利用漏洞获取敏感信息。 1.漏洞级别 中危 2.影响范围 e-office < 9.5 202201133.漏洞搜索 fofa 搜索 app"泛微-OA(e-cology)"4.漏洞复现 …...

MATLAB ga函数的使用方法
一、ga句法结构 x ga(fitnessfcn,nvars) x ga(fitnessfcn,nvars,A,b) x ga(fitnessfcn,nvars,A,b,Aeq,beq) x ga(fitnessfcn,nvars,A,b,Aeq,beg,IB,UB) x ga(fitnessfcn,nvars,A,b,Aeq,beq,LB,UB,nonlcon) x ga(fitnessfcn,nvars,A,b,Aeq,beq,LB,UB,nonlcon,options) x …...

基于STM32和MQ-2传感器的无线烟雾检测系统设计
随着科技的不断发展,人们对生活安全的要求也越来越高。其中,烟雾检测系统在预防火灾方面起着至关重要的作用。本文将介绍一种基于STM32和MQ-2传感器的无线烟雾检测系统设计,旨在实时检测环境中的烟雾,并及时发出警报,以…...

华为vrrp+mstp+ospf+dhcp+dhcp relay配置案例
1、左边是vlan 10主桥,右边是vlan 20的主桥,并且互为备桥 2、 vlan 10 vrrp网关默认用左边,vlan 20的vrrp 网关默认用右边,对应mstp生成树 3、两边都track检测,不通就把vrrp减掉60,这样就会自动切另一边了 …...
5-Docker实例-tomcat application
1.安装如下树形结构创建目录及文件,内容如下: 目录结构: [root@centos79 ~]# tree demo demo ├── index.html └── WEB-INF└── web.xml1 directory, 2 files [root@centos79 ~]# index.html文件内容 [root@centos79 demo]# cat index.html <h1>hello dock…...

Pikachu靶场 “Http Header”SQL注入
1. 先在 pikachu 打开 Http Header 注入模块,点击提示 查看登录 账号 和 密码,登陆后去 Burp 中找到登陆的 GET请求 2. 设置payload1 :在 User-Agent最后 输入 查看 数据库名 or updatexml(1,concat(0x7e,database()),0) or 查看 用户名…...

OpenEuler安装内网穿透工具实现ssh连接openEuler系统
文章目录 1. 本地SSH连接测试2. openEuler安装Cpolar3. 配置 SSH公网地址4. 公网远程SSH连接5. 固定连接SSH公网地址6. SSH固定地址连接测试 本文主要介绍在openEuler中安装Cpolar内网穿透工具实现远程也可以ssh 连接openEuler系统使用. 欧拉操作系统(openEuler, 简称“欧拉”…...
【效率工具】利用python进行本地知识库(PDF和WORK文件内容)的批量模糊搜索
目录 前言 一、为什么要进行本地文档的批量搜索? 二、如何去做呢?...

快速入门学习定时任务框架-xxljob
定时任务框架-xxljob 简介 主要用于分布式任务调度,可以将任务调度和执行分布在多个节点上。它提供了一个集中式的管理平台,支持动态添加、修改、删除任务,以及任务的分片执行,确保任务在分布式环境中的高可用性的一个框架 spr…...

Floyd(弗洛伊德)算法总结
知识概览 Floyd算法适合解决多源汇最短路问题,其中源点是起点,汇点是终点。时间复杂度是。 例题展示 题目链接 活动 - AcWing 系统讲解常用算法与数据结构,给出相应代码模板,并会布置、讲解相应的基础算法题目。https://www.acw…...

西南科技大学计算机网络实验二 (IP协议分析与以太网协议分析)
一、实验目的 通过分析由跟踪执行traceroute程序发送和接收捕获得到的IP 数据报,深入研究在IP 数据报中的各种字段,理解IP协议。基于ARP命令和Ethereal进行以太网帧捕获与分析,理解和熟悉ARP协议原理以及以太网帧格式。 二、实验环境 与因特网连接的计算机网络系统;主机操…...
基于算法竞赛的c++编程(28)结构体的进阶应用
结构体的嵌套与复杂数据组织 在C中,结构体可以嵌套使用,形成更复杂的数据结构。例如,可以通过嵌套结构体描述多层级数据关系: struct Address {string city;string street;int zipCode; };struct Employee {string name;int id;…...
云计算——弹性云计算器(ECS)
弹性云服务器:ECS 概述 云计算重构了ICT系统,云计算平台厂商推出使得厂家能够主要关注应用管理而非平台管理的云平台,包含如下主要概念。 ECS(Elastic Cloud Server):即弹性云服务器,是云计算…...

《Qt C++ 与 OpenCV:解锁视频播放程序设计的奥秘》
引言:探索视频播放程序设计之旅 在当今数字化时代,多媒体应用已渗透到我们生活的方方面面,从日常的视频娱乐到专业的视频监控、视频会议系统,视频播放程序作为多媒体应用的核心组成部分,扮演着至关重要的角色。无论是在个人电脑、移动设备还是智能电视等平台上,用户都期望…...

基于uniapp+WebSocket实现聊天对话、消息监听、消息推送、聊天室等功能,多端兼容
基于 UniApp + WebSocket实现多端兼容的实时通讯系统,涵盖WebSocket连接建立、消息收发机制、多端兼容性配置、消息实时监听等功能,适配微信小程序、H5、Android、iOS等终端 目录 技术选型分析WebSocket协议优势UniApp跨平台特性WebSocket 基础实现连接管理消息收发连接…...

聊聊 Pulsar:Producer 源码解析
一、前言 Apache Pulsar 是一个企业级的开源分布式消息传递平台,以其高性能、可扩展性和存储计算分离架构在消息队列和流处理领域独树一帜。在 Pulsar 的核心架构中,Producer(生产者) 是连接客户端应用与消息队列的第一步。生产者…...

基于当前项目通过npm包形式暴露公共组件
1.package.sjon文件配置 其中xh-flowable就是暴露出去的npm包名 2.创建tpyes文件夹,并新增内容 3.创建package文件夹...
Axios请求超时重发机制
Axios 超时重新请求实现方案 在 Axios 中实现超时重新请求可以通过以下几种方式: 1. 使用拦截器实现自动重试 import axios from axios;// 创建axios实例 const instance axios.create();// 设置超时时间 instance.defaults.timeout 5000;// 最大重试次数 cons…...

均衡后的SNRSINR
本文主要摘自参考文献中的前两篇,相关文献中经常会出现MIMO检测后的SINR不过一直没有找到相关数学推到过程,其中文献[1]中给出了相关原理在此仅做记录。 1. 系统模型 复信道模型 n t n_t nt 根发送天线, n r n_r nr 根接收天线的 MIMO 系…...

嵌入式学习笔记DAY33(网络编程——TCP)
一、网络架构 C/S (client/server 客户端/服务器):由客户端和服务器端两个部分组成。客户端通常是用户使用的应用程序,负责提供用户界面和交互逻辑 ,接收用户输入,向服务器发送请求,并展示服务…...

群晖NAS如何在虚拟机创建飞牛NAS
套件中心下载安装Virtual Machine Manager 创建虚拟机 配置虚拟机 飞牛官网下载 https://iso.liveupdate.fnnas.com/x86_64/trim/fnos-0.9.2-863.iso 群晖NAS如何在虚拟机创建飞牛NAS - 个人信息分享...