Skip to main content

Detector IA

PyPI Python CI MIT

Español · English

Desarrollado por Alberto Ortiz Sánchez · albertoortiz.is-a.dev · PyPI · GitHub

pip install detector-ia && detector-ia --version

Español

Herramienta de línea de comandos para detectar indicios de texto generado por IA y posibles copias entre entregas de alumnos, y generar un reporte CSV ordenado por riesgo.

Analiza cuadernos de Jupyter (.ipynb), PDF, Word (.docx), Markdown (.md) y texto plano (.txt) en una sola pasada.

Es una ayuda para la revisión, no una prueba. Un porcentaje alto es un motivo para hablar con el alumno o revisar el trabajo a mano; nunca un veredicto automático.

Documentación

Guías en español e inglés dentro de cada archivo:

Cómo funciona

Cada entrega se parte en bloques de ~1500 caracteres y cada bloque de más de 300 caracteres se puntúa combinando tres señales:

Señal Peso Qué mide
Huella estructural en español 50 % Guiones largos (—), listas * **Concepto:**, encabezados ### 1., conectores enciclopédicos (por tanto, cabe destacar, en última instancia) y ausencia de erratas/coloquialismos
Uniformidad estadística 30 % Baja variación en la longitud de las frases, típica de texto generado
Red neuronal 20 % fakespot-ai/roberta-base-ai-text-detection-v1

Además se calcula la similitud de coseno (bolsa de palabras) entre todas las entregas: en los cuadernos se compara el código (o el texto, si el cuaderno no tiene código) y en el resto el texto redactado. Un mismo trabajo entregado en dos formatos (por ejemplo PDF y TXT) no se cuenta como copia.

Instalación

Requiere Python 3.13 o superior.

pip install detector-ia            # desde PyPI: señales estructurales, sin modelo neuronal
pip install "detector-ia[modelo]"  # con el modelo neuronal (torch + transformers)

El extra modelo instala torch y transformers; sin él la herramienta sigue funcionando con --sin-modelo, usando solo las señales estructurales. La primera ejecución descarga el modelo (~500 MB) en cache_modelo/, que está fuera del control de versiones. Las siguientes arrancan sin conexión.

Con el paquete instalado el comando es detector-ia; comprueba que responde con detector-ia --version.

Desde el código fuente

Si prefieres trabajar sobre el repositorio, clona y sincroniza. Para esto hace falta uv:

git clone https://github.com/alberto2005-coder/detector-ia.git
cd detector-ia
uv sync --extra modelo

Dentro del repositorio los comandos del resto de la guía se ejecutan con uv run detector-ia.

Uso

Copia las entregas a analizar en revision_ia/ y ejecuta:

uv run detector-ia

Eso lee revision_ia/, imprime el progreso y guarda reporte_profesional_ia.csv. Hay textos inventados de prueba en ejemplos/:

uv run detector-ia -c ejemplos -s reporte_ejemplos.csv

Con opciones:

uv run detector-ia --carpeta entregas --salida reportes/marzo.csv
uv run detector-ia -c ejemplos/misma_entrega.md --sin-modelo   # un solo archivo
uv run detector-ia --folder entregas --output reporte.csv --lang en
uv run detector-ia --modelo fakespot-ai/roberta-base-ai-text-detection-v1

También funciona sin uv, con el entorno activado:

python -m detector_ia --carpeta revision_ia

Opciones

Opción Por defecto Descripción
-c, --carpeta, --ruta, --folder, --path revision_ia Carpeta con las entregas o ruta de un archivo concreto
-s, --salida, --output reporte_profesional_ia.csv Ruta del reporte generado
-m, --modelo, --model RoBERTa de detección de IA Modelo de Hugging Face a usar
--sin-modelo, --no-model desactivado Analiza solo con las señales estructurales, sin descargar el modelo
--json desactivado Escribe el resultado en JSON por la salida estándar y el progreso por la de errores
--fail-on ninguno Devuelve código de salida 1 si el reporte alcanza error, alto/high o sospechoso/suspicious (también vale none)
--lang, --idioma es Idioma de los mensajes de consola (es/en); el CSV no cambia
-V, --version — Muestra la versión instalada y sale

Todos los flags, sus valores y la ayuda de -h se pueden escribir en español o en inglés: --carpeta entregas y --folder entregas hacen lo mismo, igual que --salida/--output. El CSV y los veredictos se quedan en español para que las columnas no cambien según el idioma; solo se traducen los mensajes de consola.

Reporte

El CSV se guarda en UTF-8 con BOM y separador ; para que abra directamente en Excel en español. Columnas:

  • Archivo / Formato: nombre y extensión de la entrega.
  • IA_Media (%): media de la puntuación híbrida de los bloques evaluados.
  • IA_Pico_Max (%): bloque con la puntuación más alta, el que más se parece a texto de IA.
  • Similitud_Companero (%) y Coincide_Con: entrega más parecida y su nombre si supera el 75 %.
  • Veredicto: ALTO RIESGO IA, REVISAR COPIA ENTRE ALUMNOS, Sospechoso (Revisar), Normal o Poco texto.
  • Fragmento_Sospechoso: el bloque con mayor puntuación, para leerlo en contexto.
  • Error: vacía salvo que el archivo no se pudiera leer o puntuar; en ese caso el veredicto es Error y aquí aparece el motivo, sin detener el resto del lote.

Umbrales actuales (en src/detector_ia/main.py): pico ≥ 58 % o media ≥ 45 % es alto riesgo; pico ≥ 45 % o media ≥ 35 % es sospechoso; similitud > 88 % es posible copia.

Estructura

detector-ia/
├── src/detector_ia/
│   ├── main.py          # CLI, umbrales y generación del reporte
│   ├── extractores.py   # Lectura de .ipynb, .pdf, .docx, .txt y .md
│   └── motores.py       # Modelo neuronal, huella estructural y similitud
├── tests/               # Pruebas con un detector falso, sin descargar el modelo
├── docs/                # Índice, método, uso responsable y formatos
├── ejemplos/            # Textos inventados para probar
├── evaluacion/          # Corpus etiquetado y script de métricas
├── scripts/             # Notas de release a partir del CHANGELOG
├── .github/             # CI, releases, Dependabot y plantillas
├── revision_ia/         # Entregas de entrada (ignoradas por git)
├── README.md            # Guía completa, en español e inglés
├── CONTRIBUTING.md      # Cómo contribuir
├── SECURITY.md          # Política de seguridad
├── CODE_OF_CONDUCT.md   # Código de conducta
├── CHANGELOG.md         # Historial de cambios por versión
├── LICENSE              # Licencia MIT
├── pyproject.toml       # Metadatos, dependencias y entry point
├── uv.lock              # Versiones exactas de las dependencias
├── .gitattributes       # Finales de línea normalizados
└── .gitignore           # Excluye .venv, cache_modelo y entregas

Privacidad

Las entregas de los alumnos y los reportes generados están excluidos de git (.gitignore), porque contienen trabajos reales y nombres de archivo. No los subas al repositorio ni compartas los CSV fuera del ámbito docente.

Autor

Desarrollado por Alberto Ortiz Sánchez.

Licencia

Distribuido bajo la licencia MIT. Consulta LICENSE. © 2026 Alberto Ortiz Sánchez.


English

A command-line tool to spot AI-generated text and possible copying between students' submissions, and to produce a CSV report sorted by risk.

It analyses Jupyter notebooks (.ipynb), PDF, Word (.docx), Markdown (.md) and plain text (.txt) in a single pass.

This is a review aid, not evidence. A high score is a reason to talk to the student or read the work by hand; never an automatic verdict.

Documentation

Guides in Spanish and English within each file:

How it works

Each submission is split into blocks of ~1500 characters, and every block longer than 300 characters is scored by combining three signals:

Signal Weight What it measures
Spanish structural fingerprint 50 % Em dashes (—), * **Term:** lists, ### 1. headings, encyclopedic connectors (por tanto, cabe destacar, en última instancia) and absence of typos or colloquialisms
Statistical uniformity 30 % Low variation in sentence length, typical of generated text
Neural network 20 % fakespot-ai/roberta-base-ai-text-detection-v1

Cosine similarity (bag of words) is also computed between all submissions: notebooks are compared by code (or by their text, when they have no code), everything else by written text. The same assignment submitted in two formats (say PDF and TXT) is not counted as copying.

Install

Requires Python 3.13 or newer.

pip install detector-ia            # from PyPI: structural signals, no neural model
pip install "detector-ia[modelo]"  # with the neural model (torch + transformers)

The modelo extra installs torch and transformers; without it the tool still works with --sin-modelo, using only the structural signals. The first run downloads the model (~500 MB) into cache_modelo/, which is not tracked by git. Later runs start offline.

Once installed, the command is detector-ia; check it with detector-ia --version.

From source

If you prefer working on the repository, clone and sync. This needs uv:

git clone https://github.com/alberto2005-coder/detector-ia.git
cd detector-ia
uv sync --extra modelo

Inside the repository, the commands in the rest of this guide run as uv run detector-ia.

Usage

Copy the submissions into revision_ia/ and run:

uv run detector-ia

That reads revision_ia/, prints progress and writes reporte_profesional_ia.csv. There are invented test texts in ejemplos/:

uv run detector-ia -c ejemplos -s reporte_ejemplos.csv

With options:

uv run detector-ia --carpeta entregas --salida reportes/marzo.csv
uv run detector-ia -c ejemplos/misma_entrega.md --sin-modelo   # a single file
uv run detector-ia --folder entregas --output reporte.csv --lang en
uv run detector-ia --modelo fakespot-ai/roberta-base-ai-text-detection-v1

It also works without uv, with the environment active:

python -m detector_ia --carpeta revision_ia

Options

Option Default Description
-c, --carpeta, --ruta, --folder, --path revision_ia Folder with the submissions, or the path of a single file
-s, --salida, --output reporte_profesional_ia.csv Path of the generated report
-m, --modelo, --model AI-detection RoBERTa Hugging Face model to use
--sin-modelo, --no-model off Structural signals only, without downloading the model
--json off Write the result as JSON on stdout and progress on stderr
--fail-on ninguno Exit with code 1 when the report reaches error, alto/high or sospechoso/suspicious (none works too)
--lang, --idioma es Language of the console messages (es/en); the CSV does not change
-V, --version — Print the installed version and exit

Every flag, its values and the -h help can be written in Spanish or in English: --carpeta entregas and --folder entregas are the same thing, as are --salida/--output. The CSV and the verdicts stay in Spanish so the columns never change with the language; only the console messages are translated.

Report

The CSV is written in UTF-8 with BOM and a ; separator so it opens directly in Spanish-locale Excel. Columns:

  • Archivo / Formato: file name and extension of the submission.
  • IA_Media (%): mean hybrid score of the scored blocks.
  • IA_Pico_Max (%): highest-scoring block, the most AI-like passage.
  • Similitud_Companero (%) and Coincide_Con: most similar submission, with its name when similarity is above 75 %.
  • Veredicto: ALTO RIESGO IA, REVISAR COPIA ENTRE ALUMNOS, Sospechoso (Revisar), Normal or Poco texto.
  • Fragmento_Sospechoso: the highest-scoring block, to read it in context.
  • Error: empty unless the file could not be read or scored; the verdict is then Error and the reason appears here, without stopping the rest of the batch.

Current thresholds (in src/detector_ia/main.py): peak ≥ 58 % or mean ≥ 45 % is high risk; peak ≥ 45 % or mean ≥ 35 % is suspicious; similarity > 88 % is possible copying.

Layout

detector-ia/
├── src/detector_ia/
│   ├── main.py          # CLI, thresholds and report generation
│   ├── extractores.py   # Readers for .ipynb, .pdf, .docx, .txt and .md
│   └── motores.py       # Neural model, structural fingerprint and similarity
├── tests/               # Tests with a fake detector, no model download
├── docs/                # Index, method, responsible use and formats
├── ejemplos/            # Invented texts for trying the tool
├── evaluacion/          # Labelled corpus and metrics script
├── scripts/             # Release notes from the CHANGELOG
├── .github/             # CI, releases, Dependabot and templates
├── revision_ia/         # Input submissions (git-ignored)
├── README.md            # Full guide, in Spanish and English
├── CONTRIBUTING.md      # How to contribute
├── SECURITY.md          # Security policy
├── CODE_OF_CONDUCT.md   # Code of conduct
├── CHANGELOG.md         # Change history per version
├── LICENSE              # MIT license
├── pyproject.toml       # Metadata, dependencies and entry point
├── uv.lock              # Exact dependency versions
├── .gitattributes       # Normalized line endings
└── .gitignore           # Excludes .venv, cache_modelo and submissions

Privacy

Student submissions and generated reports are excluded from git (.gitignore), because they contain real work and file names. Do not push them to the repository or share the CSVs outside the classroom.

Author

Developed by Alberto Ortiz Sánchez.

License

Distributed under the MIT license. See LICENSE. © 2026 Alberto Ortiz Sánchez.

Metadata

Release files for detector-ia 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for detector-ia 1.0.2
File Size Uploaded Provenance Actions
detector_ia-1.0.2.tar.gz 20.7 kB With provenance Details for detector_ia-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for detector-ia 1.0.2
File Interpreter ABI Platform Actions
detector_ia-1.0.2-py3-none-any.whl Python 3 none any Details for detector_ia-1.0.2-py3-none-any.whl

Total release size: 38.7 kB

Release files / detector_ia-1.0.2.tar.gz

Download URL detector_ia-1.0.2.tar.gz
Size 20.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5ffa0f2e19994f31f6f580f6af50b552dc1b2540cae835a3920fab6b44a6c13f
BLAKE2b-256 checksum
How to use checksums
800e3e58baf46f352c5284122f21fd5ecaac1508c4272dd190ceead0975ecd75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / detector_ia-1.0.2-py3-none-any.whl

Download URL detector_ia-1.0.2-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1210d384681e20b10705e2fc166d643c00d8a528e9a9c883ad6058314cb57461
BLAKE2b-256 checksum
How to use checksums
dbc4177b1dc43b0c2fe0f59449827fe6ab5db82cdd99562dd49a90f95a0e514d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for detector-ia 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for detector_ia-1.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page