Prendre RDVContact
Retour aux Briefs Stratégiques
Brief Stratégique : Markhor Limited

Pipeline automatisé de cohérence de contenu

Médias & Édition Publié 2025-11 7 min de lecture
Type de Mission

Automatisation d'entreprise

Durée

8 mois

Pipeline automatisé de cohérence de contenu - Markhor Limited | Seven Labs Case Study

Le Défi Opérationnel

Une grande agence de contenu développait des récits en série multi-auteurs mais rencontrait des difficultés avec les résultats de l'IA générative standard. Les modèles hallucinaient constamment des détails, modifiaient le profil des personnages et créaient contradictions factuelles entre les chapitres, gâchant l'immersion des utilisateurs et ralentissant les éditeurs.

La Solution & Architecture

Nous avons conçu un pipeline d'orchestration multi-étapes centré sur la validation de la « cohérence avec le canon ». Le générateur de contenu interroge une Bible vectorielle personnalisée contenant les règles des personnages, l'historique des événements et les restrictions de style. Avant qu'un projet de chapitre ne soit approuvé, un pipeline de vérification automatisé analyse le projet par rapport à la Bible, détectant les contradictions factuelles et régénérant automatiquement les segments problématiques.

Pourquoi c'est important

L'hallucination, cette tendance des grands modèles de langage à générer des informations plausibles mais factuellement incorrectes, est le défi central qui bloque l'adoption de l'IA de contenu en entreprise. Cette mission le résout via une couche de validation augmentée par récupération : une base de données vectorielle stockant la source canonique de vérité, interrogée au moment de la génération pour ancrer chaque résultat dans des faits vérifiés. Le résultat est un score de cohérence de 98,9 % pour 1 million de mots par mois, un débit qu'aucune équipe éditoriale humaine ne pourrait égaler à coût équivalent. Cette architecture est réplicable dans tout domaine nécessitant une cohérence factuelle : documentation juridique, rédaction technique, contenu réglementaire.

Flux de Logique Fonctionnelle

Pipeline de gouvernance narrative

1

Phase d'Intégration Système

Création d'une hiérarchie d'évaluation granulaire et multi-agents où des LLM spécialisés examinent et critiquent la cohérence des résultats avant les phases de révision humaine.

2

Optimisation & Allocation Dynamique

Intégration d'une file d'attente de messages Redis asynchrone pour coordonner la compilation de fichiers en grand volume et les vérifications en arrière-plan, évitant ainsi les goulots d'étranglement du système.

3

Durcissement & Validation de l'Échelle

Conception d'un tableau de bord centralisé pour gérer la bible de l'histoire, permettant aux chefs de projet d'ajouter ou de mettre à jour facilement et dynamiquement les contraintes et règles des personnages.

Métriques Métier Clés
1M mots/mois
Volume de contenu
98.9%
Score de cohérence
+18%
Précision du modèle
-60%
Temps de traitement par lots

Résultat : Un hub de création narrative d'entreprise générant chaque mois des millions de mots de contenu sériel factuellement cohérent. Cela a permis à l'agence de gérer un volume de clients trois fois supérieur sans embaucher d'éditeurs, réduisant les besoins de réécriture de 60 % et améliorant la précision de 18 %.

Écosystème Tech Déployé
PythonLangChainComputer VisionRoboflowRedis QueueAWS S3MERN Stack
Seven Labs
Seven Labs Agence Vérifiée

Seven Labs est une entreprise d'ingénierie de systèmes d'IA basée à Islamabad, au Pakistan. Notre équipe détient des certifications professionnelles d'IBM, Google Cloud, EC-Council et CyberWarfare Labs, et a livré des systèmes de production pour des clients de la banque, du SaaS, de l'immobilier et des médias sur trois continents.

Les récits des études de cas sont rédigés avec l'aide d'outils d'écriture d'IA et révisés par les ingénieurs de Seven Labs pour en garantir l'exactitude technique. Toutes les mesures, les détails de la pile et les décisions architecturales reflètent des modèles de déploiement réels. Les noms des clients sont masqués lorsque des accords de confidentialité s'appliquent.

Lancez un audit d'architecture système similaire.

Chaque projet que nous prenons en charge est conçu pour des résultats mesurables. Cartographions vos systèmes et construisons un workflow de déploiement évolutif.

Planifier un Appel d'AuditDemande par Formulaire de Contact

Approfondissement Technique

Case Study: Markhor Limited - Automated Content Consistency Pipeline

Executive Summary

In B2C digital publishing and media distribution, scale is key to capture subscriber attention. Markhor Limited, a fast-growing digital publisher specializing in multi-author serial narratives, faced a major bottleneck. When scaling narrative content production using generative AI tools, they encountered consistency errors. The models routinely hallucinated factual details, altered character descriptions (e.g., changing a character’s eye color from blue to brown), and created timeline contradictions across chapters. These errors disrupted reader immersion, forced editorial teams to rewrite sections, and slowed down publishing times.

Seven Labs designed and deployed an automated content consistency pipeline. Built using Python and LangChain, this system utilizes a Retrieval-Augmented Generation (RAG) architecture powered by a "Story Bible" database. It features multi-agent verification loops that detect and correct factual errors before publication. The pipeline also includes a computer vision model trained via Roboflow. This model scans generated illustrations to ensure that visual details (such as hair color and clothing) match the character descriptions in the text database.

The results of the project include:

  • Content production grew to 1 million words per month.
  • Narrative consistency scores reached 98.9%.
  • Formatting and factual accuracy improved by 18%.
  • Production time for batch chapters dropped by 60%, allowing the agency to take on 3x client volume.

Business Problem

Markhor Limited publishes high-volume, serialized fiction across multiple digital platforms. To keep readers engaged, they must publish new chapters daily. However, their legacy production process faced several major challenges:

  1. Factual Errors and Hallucinations: As stories grew longer, standard language models lost track of character descriptions, plot points, and setting details. This required editors to spend hours rewriting sections.
  2. Visual Inconsistencies in Illustrations: Generated promotional images and chapter covers often failed to match the story text. Characters were frequently generated with wrong outfits, hair colors, or physical traits.
  3. Operational Bottle-necks: Because editors had to manually review every line of text and every image for consistency, the publishing pipeline was slow. This limit on editorial throughput prevented the agency from scaling its catalog.

To resolve these issues, Markhor Limited needed an automated verification system. This system had to identify and correct text and visual inconsistencies before content was sent to editors.

Technical Challenges

Creating a multi-layered content generation and validation pipeline required solving several complex AI orchestration and computer vision challenges:

  • Long-Context Search Performance: A narrative series can exceed 100,000 words. Attempting to feed the entire history into a language model for consistency checking exceeds context limits and increases API costs. We needed a RAG-based search strategy to retrieve only the relevant character and plot details.
  • Complex Contradiction Detection: Standard semantic search matches similar concepts but struggles to identify direct logical contradictions (e.g., a character who died in chapter 3 reappearing in chapter 8). We had to design an agent workflow to analyze relationships and sequence events.
  • Visual Identity Verification: General computer vision models can identify a "person" or a "shirt," but they cannot verify if a generated character's features match a specific description in the Story Bible. We had to train custom object detection models to flag discrepancies in hair color, facial features, and clothing.
  • Managing API Latency with Self-Correction Loops: Running multiple validation agents can result in long processing times if the system falls into infinite correction loops. We needed to optimize agent routing, implement parallel execution queues, and configure strict timeout limits.

Solution Architecture

The architecture comprises a Python-based agent orchestration service linked to a Pinecone vector database, a Redis queue, and a custom Roboflow inference engine.

+---------------------------------------------------------------------------------------+
|                                  INBOUND INGESTION LAYER                              |
|                                                                                       |
|  +-----------------+      +-----------------+      +-----------------+                |
|  |   Writer UI     |      |  Batch Upload   |      |   Partner API   |                |
|  +--------+--------+      +--------+--------+      +--------+--------+                |
|           |                        |                        |                         |
|           +------------------------+------------------------+                         |
|                                    |                                                  |
|                                    v                                                  |
|                      +-------------+--------------+                                   |
|                      |  FastAPI Ingestion Endpoint|                                   |
+----------------------+-------------+--------------+-----------------------------------+
                                     |
                                     v
+------------------------------------+--------------------------------------------------+
|                               ORCHESTRATION & STORAGE                                 |
|                                                                                       |
|  +--------------------------+  +--------------------------+  +---------------------+  |
|  |     Redis Task Queue     |  |   MongoDB Metadata DB    |  |  Story Bible RAG    |  |
|  |  (Celery / Background)   |  |  (Versions, Characters)  |  |  (Pinecone Index)   |  |
|  +------------+-------------+  +--------------------------+  +----------+----------+  |
|               |                                                         ^             |
|               v                                                         |             |
|  +------------+-------------+                                           |             |
|  |  Generation Controller  | <=========================================+             |
|  +------------+-------------+  Queries Character Profiles                             |
|               |                                                                       |
+---------------|-----------------------------------------------------------------------+
                |
                v
+---------------+-----------------------------------------------------------------------+
|                               VALIDATION ENGINE                                       |
|                                                                                       |
|  +------------+-------------+  Generates Draft  +------------+-------------+          |
|  |  Content Draft Engine    |==================>|  Consistency Validator   |          |
|  +--------------------------+                   +------------+-------------+          |
|                                                              |                        |
|                                                              v                        |
|  +--------------------------+  Fails Text Check  +-----------+-------------+          |
|  |  Self-Correction Agent   |<==================|   Visual Identity Model  |          |
|  +------------+-------------+                   |   (YOLO & Roboflow SDK)  |          |
|               |                                 +------------+-------------+          |
|               | (Applies Fixes)                              |                        |
|               v                                              v (Passes All Checks)    |
|  +------------+-------------+                   +------------+-------------+          |
|  |  Draft Update Pipeline   |                   |  Editor Review Dashboard |          |
|  +--------------------------+                   +--------------------------+          |
+---------------------------------------------------------------------------------------+

Component Flow

  1. FastAPI Ingestion Endpoint: Receives outline drafts, target character profiles, and scene specifications.
  2. Story Bible RAG (Pinecone): Stores character relationships, setting details, and plot histories. Text is parsed using advanced chunking strategies to maintain context.
  3. Generation Controller: Coordinates the draft process. It retrieves character details from the Pinecone vector database and inserts them into the LLM system prompt.
  4. Consistency Validator: The generated text is routed to a validation microservice. A group of specialized agents compares the draft against the Story Bible rules to identify logical errors or description shifts.
  5. Visual Identity Model (Roboflow): For chapter illustrations, the visual validator retrieves the scene's character descriptions. It uses a YOLO model trained on Roboflow to check if the character's hair, outfit, and accessories match the text.
  6. Self-Correction Loop: If the system flags an error, it routes the text or image back to the generator with a description of the issue. The generator fixes the error and resubmits the file. Once it passes all checks, the content is sent to the Editor Review Dashboard.

Technology Stack

We chose the stack to balance high-speed data search with asynchronous scaling:

  • Orchestration Core: Python 3.11 with FastAPI. Python was selected for its mature machine learning ecosystem, LangChain support, and integration with data processing tools.
  • AI Orchestration Framework: LangChain. We utilized LangChain to structure the agent routing, RAG query logic, and validation loops.
  • Vector Database: Pinecone, using cosine similarity metrics for RAG retrieval.
  • Computer Vision Model: YOLOv8 trained via Roboflow. The model runs on PyTorch and is accessed through the Roboflow SDK to verify character features in images.
  • Asynchronous Task Queue: Celery with a Redis backplane. This manages batch generation tasks in the background without blocking the user interface.
  • Metadata Database: MongoDB (MERN Stack). This stores chapter versions, agent logs, and configuration settings.
  • Editor Interface: React (MERN Stack) with Tailwind CSS, providing a web dashboard for editors to review drafts, see flagged errors, and update the Story Bible.
  • Asset Storage: AWS S3, used to store generated assets, training data, and final PDF distributions.

Implementation Process

The system was designed and deployed over an 8-month period, divided into five main phases:

Month 1-2               Month 3-4               Month 5                  Month 6                  Month 7-8
+---------------------+ +---------------------+ +----------------------+ +----------------------+ +---------------------+
| Story Bible Setup   | | RAG Pipeline        | | Consistency Agents   | | Visual Validation    | | System Scaling      |
| Design schema       | | Connect Pinecone    | | Deploy LangChain     | | Train YOLO models    | | Connect Redis       |
| Ingest historical   | | Write retrieval     | | Build correction     | | Connect Roboflow     | | Run load testing    |
| character data      | | query logic         | | routing loops        | | API for image checks | | Editor dashboard    |
+---------------------+ +---------------------+ +----------------------+ +----------------------+ +---------------------+

Phase 1: Structuring the Dynamic Story Bible (Months 1-2)

We designed a database schema to represent complex story worlds. The data model tracks characters (attributes, relationships, history), locations (maps, rules), and plot timelines (past events, active subplots).

We imported Markhor's existing story catalogs into MongoDB. We then converted the files into markdown formatting to prepare them for vector indexing.

Phase 2: Building the Generation and RAG Pipeline (Months 3-4)

To query the large database efficiently, we deployed a Pinecone vector index.

We used advanced chunking strategies (similar to the /blogs/advanced-rag-chunking model) to split the story texts. This preserves context by attaching chapter numbers, character lists, and plot summaries to each chunk.

We wrote a query router in LangChain. When generating a new chapter, the router queries Pinecone for the specific characters and plotlines mentioned in the outline, passing only the relevant details to the model.

Phase 3: Implementing Multi-Agent Consistency Validation (Month 5)

We built the consistency verification system using LangChain.

The system runs three specialized verification agents:

  • The Character Inspector: Compares the generated character descriptions (eye color, hair style, clothes) with the retrieved profiles in the Story Bible.
  • The Chronology Auditor: Compares the sequence of events in the draft with the timeline database to prevent temporal errors.
  • The Style Evaluator: Verifies that the text matches the publisher’s guidelines for tone, complexity, and reading level.

If an agent flags an error, it generates a report. The compiler routes the report and the draft back to the generator for self-correction.

Phase 4: Visual Consistency Verification using Roboflow (Month 6)

To verify illustration consistency, we trained a custom YOLOv8 model using Roboflow. We annotated a dataset of character images, tagging features like hair styles, hair colors, clothing types, and key accessories.

We deployed the model on a GPU-enabled AWS instance. When a cover image is generated, the pipeline runs it through the YOLO model.

The system extracts the visual features and compares them with the character profile in MongoDB. If the image fails the comparison (e.g., generating a blonde character instead of a black-haired one), the pipeline flags it for regeneration.

Phase 5: Async Task Queues and the MERN Dashboard (Months 7-8)

To support high volumes of content, we implemented Celery with Redis for background task queue management.

When a user starts a batch generation task, the request is placed in a Celery queue. A pool of worker servers processes the tasks, while MongoDB tracks the execution state.

We built a React-based editor dashboard. This dashboard lets editors review drafted chapters, see highlighted consistency fixes, update the Story Bible records, and approve files for publication.

Security Considerations

Operating a commercial digital publishing pipeline requires measures to protect proprietary creative assets:

  • Intellectual Property Protection: Generative AI APIs are configured to opt-out of data training programs. This prevents client stories and character profiles from being used to train public models.
  • Secure Storage Access: AWS S3 assets are served using pre-signed URLs with short expiration windows (15 minutes). This prevents direct access to generated content assets.
  • API Access Management: API keys are stored in AWS Secrets Manager. System access is restricted using Role-Based Access Control (RBAC) configured within the FastAPI endpoints.

To learn more about secure architectures, see /blogs/secure-ai-restricted-networks and /blogs/security-challenges-distributed-ai.

Performance Optimizations

To handle large content volumes, we implemented several performance optimizations:

  1. Vector Database Chunking Strategies: We used semantic metadata filtering in Pinecone to target search queries to specific book IDs and namespaces. This reduced search latency to under 80ms.
  2. Redis Task Prioritization: We created separate queues in Redis for interactive edits and background batch runs. This ensures that editors receive quick responses when editing, while batch tasks compile in the background.
  3. LLM Batching API Usage: We used LangChain’s async API features to run verification agents in parallel, reducing the total draft validation time.
PhaseUnoptimized PerformanceOptimized Performance
RAG Query Time420ms78ms
Draft Validation45 seconds12 seconds
Image Verification18 seconds2.8 seconds
Batch Job LatencyQueue BlockedManaged Queues

Results & Outcomes

The content consistency pipeline delivered improved metrics across Markhor Limited's publishing operations:

  • Higher Word Count Volume: Content volume grew to 1 million words per month.
  • High Consistency Scores: Factual consistency in the story files reached 98.9%.
  • Improved Accuracy: The self-correction loops reduced formatting and detail errors by 18%.
  • Reduced Batch Time: The time required to process and verify chapters fell by 60%, allowing the agency to take on 3x client volume.

Lessons Learned

The deployment highlighted several key engineering principles:

  • The Value of Structured Output Verification: Using strict JSON schemas for validation reports prevented parsing errors in the self-correction routing logic.
  • Managing Prompt Drift: In long generation sessions, models can lose track of system instructions. We resolved this by dividing generation jobs into shorter sections and passing updated character lists to each section.
  • The Value of Visual Verification: Integrating computer vision checks for generated illustrations proved essential. Text-only checks were not enough to identify visual discrepancies in character designs.

Frequently Asked Questions (FAQs)

1. How did you structure the vector database query strategy to capture character relationships?

We used a hybrid RAG retrieval strategy. Instead of relying only on semantic searches, we used metadata filtering inside Pinecone:

results = index.query(
    vector=query_embedding,
    filter={
        "book_id": {"$eq": "novel_series_12"},
        "chapter_num": {"$lte": active_chapter_num},
        "entities": {"$in": ["Character_A", "Character_B"]}
    },
    top_k=5
)

This filter ensures the search only returns chunks from the current book series up to the active chapter. It also prioritizes chunks mentioning the specific characters in the scene, which keeps the context window relevant.

2. How does the self-correction loop prevent infinite loop conditions?

The generation controller tracks the retry history of each chapter. The state object includes a counter variable that increments with each correction attempt.

If the correction loop exceeds 3 attempts without resolving a consistency flag, the system stops the auto-correction process. It marks the draft with a Validation_Failed_Escalation tag and routes the file, along with the error log, to a human editor for manual review.

3. What role did Computer Vision and Roboflow play in a text-based narrative pipeline?

The publishing model uses generated images for covers and social media content. To ensure that these images match the story details, we trained a custom YOLOv8 model using Roboflow.

When an illustration is generated, the pipeline runs it through the YOLO model. The model identifies visual details like hair style, hair color, and clothing.

The system compares these detected attributes with the character profile in MongoDB. If the visual details mismatch the text description, the pipeline flags the image for regeneration.

4. How did you configure the Redis queue to prevent background tasks from blocking editor operations?

We configured Celery to run two queue namespaces: interactive_queue and batch_queue. The MERN dashboard calls the interactive_queue for real-time editor edits, which are handled by dedicated worker threads.

Long-running batch generations are sent to the batch_queue, which runs on separate worker servers. This isolates the workloads, ensuring the dashboard remains responsive even when processing large volumes of text.

5. Why did you choose Python and LangChain over a Node.js framework?

Python was chosen because of its machine learning ecosystem, including libraries like PyTorch, the Roboflow SDK, and data tools.

LangChain's Python libraries provided mature agents, vector store connectors, and output parsers. This allowed us to build the multi-agent system faster and with fewer dependencies than a Node.js-based implementation.

Schema & SEO Metadata

JSON-LD Structured Data

{
  "@context": "https://schema.org",
  "@type": "TechArticle",
  "headline": "Case Study: Markhor Limited - Automated Content Consistency Pipeline",
  "description": "How Seven Labs built a custom story validation and character consistency pipeline using Python, LangChain, Pinecone, and Roboflow.",
  "inLanguage": "en-US",
  "author": {
    "@type": "Organization",
    "name": "Seven Labs",
    "url": "https://www.sevenlabs.site"
  },
  "publisher": {
    "@type": "Organization",
    "name": "Seven Labs",
    "logo": {
      "@type": "ImageObject",
      "url": "https://res.cloudinary.com/dywx7ldqr/image/upload/v1779223334/media/img_01.png"
    }
  },
  "about": [
    {
      "@type": "Thing",
      "name": "AI Platform Development",
      "url": "https://www.sevenlabs.site/services/ai-platforms"
    },
    {
      "@type": "Thing",
      "name": "AI Automation",
      "url": "https://www.sevenlabs.site/services/automation"
    }
  ]
}

Internal Linking Anchors

Service Associé

Plateformes Opérationnelles d'IA

Nous concevons des pipelines de contenu multi-agents comme celui-ci. Voir nos services →

Études de Cas Associées

Chat with us