<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Amogha on Medium]]></title>
        <description><![CDATA[Stories by Amogha on Medium]]></description>
        <link>https://medium.com/@amoghar23?source=rss-0e4a183884fb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eZEadEj_WaFcbhIsMoC5Ag.png</url>
            <title>Stories by Amogha on Medium</title>
            <link>https://medium.com/@amoghar23?source=rss-0e4a183884fb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 05:09:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amoghar23/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a distributed job execution system: Kairos]]></title>
            <link>https://medium.com/@amoghar23/building-a-distributed-job-execution-system-kairos-0c65ecfa324f?source=rss-0e4a183884fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/0c65ecfa324f</guid>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[system-design-project]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[reliability]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Amogha]]></dc:creator>
            <pubDate>Sun, 04 Oct 2026 07:57:13 GMT</pubDate>
            <atom:updated>2026-10-04T07:57:13.326Z</atom:updated>
            <content:encoded><![CDATA[<p>Running a job in the background is straightforward. Making sure it recovers from crashes, retries safely, and does not wait indefinitely behind higher-priority work is where things get interesting.</p><p>I built Kairos, a distributed job execution system in Go, to explore these problems. It uses PostgreSQL for durable job state and Redis to dispatch work to workers. You can check it out <a href="https://github.com/amoghar29/kairos">here</a>.</p><p>In this blog, I walk through its architecture, job lifecycle, and the challenges I faced around retries, stale workers, and priority scheduling.</p><h4>Contents</h4><ol><li>What is a distributed job execution system?</li><li>Tech stack</li><li>Why Go?</li><li>Features</li><li>Architecture</li><li>Lifecycle of a job</li><li>Why is exactly-once execution difficult to guarantee?</li><li>Interesting challenges I faced and how I tackled them</li><li>Caveats</li></ol><h4>What is a distributed job execution system?</h4><p>A distributed job execution system coordinates the execution of background jobs across multiple worker nodes. Jobs are submitted asynchronously, and the system handles scheduling, assigning them to workers, tracking their status, and retrying failures.</p><blockquote>“Distributed” means the jobs run across multiple machines.</blockquote><blockquote>“Asynchronous” means the submitter doesn’t have to wait for the job to finish.</blockquote><p>For example, sending promotional emails to a large number of users can happen in the background. The application submits jobs, and multiple worker machines process different batches of emails in parallel.</p><h4>Tech stack</h4><p><strong>Go </strong>— API, consumer, and worker library.</p><p><strong>PostgreSQL</strong> — Source of truth for every job, attempt, and log.</p><p><strong>Redis</strong> — Disposable dispatch buffer and live worker registry.</p><h4>Why Go?</h4><p>I chose Go because its concurrency model fits a job execution system well. Goroutines let a worker handle multiple jobs concurrently, with less overhead than creating an operating system thread for each job. Go also provides channels and synchronization primitives to coordinate concurrent work.</p><h4>Features</h4><p><strong>Task scheduling : </strong>Clients can submit tasks for immediate execution or schedule recurring tasks using cron expressions, with configurable start and end times.</p><p><strong>Priority based scheduling : </strong>Ready tasks are dispatched based on priority and waiting time. Aging helps older tasks receive preference over newer work.</p><p><strong>Retries and crash recovery : </strong>Failed tasks are retried with exponential backoff . If a worker crashes, unfinished tasks become eligible for execution again after the heartbeat deadline expires.</p><p><strong>Duplicate submission protection : </strong>Clients can provide an idempotency key when submitting a task. Repeated requests with the same key return the existing task instead of creating another one.</p><p><strong>Track task status : </strong>Clients can query task status and inspect execution history, results, errors, and logs through the API or built-in dashboard.</p><h4>Architecture</h4><figure><img alt="High level design for karios" src="https://cdn-images-1.medium.com/max/1000/1*oqFv80BJ32UjFS5xFyNKqg.png" /><figcaption>HLD</figcaption></figure><p>Kairos consists of the following components:</p><ul><li>Frontend</li><li>Job Store</li><li>Queue</li><li>Scheduler</li><li>Coordinator</li><li>Worker</li><li>Handler</li></ul><p><strong>Frontend<br></strong>The frontend is a web interface for creating and managing jobs. It provides a dashboard to track job status, inspect execution history and logs, monitor workers and queues, and manage recurring schedules.</p><p><strong>Job Store<br></strong>PostgreSQL is the source of truth for Kairos. It stores job payloads, priorities, schedules, execution states, retry deadlines, attempt history, and logs. Keeping this information in PostgreSQL allows Kairos to recover unfinished work independently of Redis.</p><p><strong>Queue<br></strong>Redis queues act as a buffer between the scheduler and workers. Each configured queue contains job IDs rather than complete job payloads. Workers retrieve the job details from PostgreSQL when claiming work. If queued IDs are lost, the scheduler can redispatch unclaimed jobs after their deadlines expire.</p><p><strong>Scheduler<br></strong>The scheduler periodically polls PostgreSQL for jobs ready to execute. These include newly submitted jobs, due recurring jobs, and failed jobs whose retry delays have elapsed. It ranks ready jobs by priority and age, pushes their IDs to the appropriate Redis queues, and updates their state.</p><p>The scheduler also recovers jobs whose worker heartbeats have expired and jobs that were dispatched but never claimed.</p><p>Its polling loop can be described as:</p><pre>While True:<br>1. recover stale and unclaimed jobs<br>2. select jobs ready for execution<br>3. push job IDs to the appropriate Redis queues<br>4. update dispatch state and deadlines</pre><p><strong>Coordinator<br></strong>Coordination happens inside each worker process. This logic pulls job IDs from the queues the worker serves, claims jobs in PostgreSQL, and directs them to the registered handlers within the configured concurrency limit.</p><p><strong>Worker<br></strong>A worker is an application process that imports Kairos, registers handlers, and listens for jobs on selected queues. Multiple worker processes can run across different machines.</p><p>Each worker manages concurrent execution, heartbeats, retries, and graceful shutdown. If a worker crashes, the scheduler can recover its unfinished jobs after their heartbeat deadlines expire.</p><p><strong>Handler<br></strong>Kairos exposes a handler interface that the service importing it implements to define the job’s actual work, such as sending an email or generating a report. The service registers its handlers, and the worker selects the appropriate implementation using the handler name specified in the job.</p><p>Handlers receive the job payload and an execution context, then return a result or an error. Because a job may execute more than once, handlers should make their external effects idempotent where possible. They should also respect context cancellation when the worker loses its claim.</p><h4>Lifecycle of a Job</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6DuRgIhiS0ow4KO5oh4AUg.png" /><figcaption>Job lifecycle</figcaption></figure><p>Every job in Kairos moves through a set of states recorded in PostgreSQL. These states describe whether the job is waiting, executing, retrying, or finished.</p><p><strong>Submission and execution<br></strong>A newly submitted job starts in pending. When it becomes ready, the scheduler pushes its ID to Redis and moves it to queued. A worker claims the job, changing its state to running, and executes the registered handler.</p><p><strong>Successful completion<br></strong>If the handler returns without an error, a one-time job moves to success. A recurring job returns to pending with its next scheduled execution time.</p><p><strong>Failure and retry<br></strong>If the handler returns an error and retries remain, the job moves to awaiting_retry. After its backoff delay expires, the scheduler queues it for another attempt. Backoff increases between retries and includes jitter to spread retry traffic.<br>If a worker crashes, its heartbeats stop. Once the heartbeat deadline expires, the scheduler recovers the unfinished job for another attempt.</p><p><strong>Exhausted retries<br></strong>A job moves to dead when its retry or delivery limit is exhausted. It remains available for inspection. An operator can rerun an eligible dead job, resetting its counters and returning it to pending.</p><p><strong>Pause, cancellation, and expiration<br></strong>Recurring jobs can be paused and resumed. Eligible jobs can be cancelled before execution. Jobs move to expired when their execution window ends or a recurring schedule has no valid next run.</p><h3>Why is exactly-once execution difficult to guarantee?</h3><p>Suppose you submit a job to send promotional emails to your customers.</p><pre>1. The job is recorded in PostgreSQL.<br>2. The scheduler polls the database for jobs ready to execute.<br>3. It finds the email job and enqueues it in Redis.<br>4. A worker picks up the job.<br>5. The worker sends the emails.<br><br>Before recording the job as completed in PostgreSQL, the worker crashes.</pre><p>The emails have been sent, but the database still shows the job as incomplete. If the system retries the job, customers may receive duplicate emails.</p><p>Skipping the retry is also risky. From the incomplete status alone, the system cannot tell whether the worker crashed before or after sending the emails.</p><p>The challenge is making the external operation and the completion update atomic: either both happen, or neither happens. A PostgreSQL transaction alone cannot include an email service’s operation. Without transactional cooperation or reliable deduplication from that service, the job system cannot guarantee exactly-once email effects.</p><p>Job systems therefore commonly provide these execution semantics:</p><ul><li><strong>At-most-once:</strong> A job is attempted zero or one time. Work may be lost, but the system does not retry an uncertain attempt.</li><li><strong>At-least-once:</strong> The system retries jobs whose completion has not been confirmed, so a job may execute multiple times. This assumes durable storage and eventual recovery; it does not guarantee that every job succeeds.</li></ul><p>Exactly-once effects may still be achievable within a defined transactional boundary or through reliable deduplication(idempotency), even when execution is repeated.</p><p>Kairos offers at-least-once execution semantics, with configured retry and delivery limits.</p><h3>Interesting challenges I faced and how I tackled them</h3><p><strong>Making client retries safe<br></strong>A client might submit a job successfully but lose the response because of a network failure. Retrying the request could create a duplicate job.<br>I added support for an Idempotency-Key, enforced through a unique constraint in PostgreSQL. Repeated requests with the same key return the existing job instead of creating another one. This makes submission retries safe, but does not prevent duplicate execution or external effects.</p><p><strong>Preventing stale workers from updating job state<br></strong>A worker can stop sending heartbeats long enough for its job to be reclaimed and assigned to another worker. The original worker may later recover and finish while the replacement worker is still executing.<br>Without a guard, the original worker could mark the job as completed even though it no longer owns the execution. The dashboard would then show a completed job while the replacement worker was still running.<br>I used version-guarded updates to prevent this. Reclaiming and claiming the job advances its version. Updates from the original worker carry an outdated version and are rejected, preventing them from overwriting the current execution’s state. The same mechanism protects against dashboard actions based on outdated data.<br>These guards protect job state. Handlers still need to account for duplicate external effects.</p><p><strong>Balancing priority with waiting time<br></strong>Strict priority scheduling can repeatedly push low-priority jobs behind newly arriving high-priority work which can lead to job starvation.<br>I added an aging term to the scheduling query so dispatch order considers both priority and waiting time. Older jobs gain preference over newer work, reducing starvation without requiring a separate process to continuously update job priorities.</p><p><strong>Separating handler failures from worker crashes<br></strong>A handler returning an error and a worker process crashing are different situations. In the first case, the worker reports a failed execution. In the second, the system only knows that heartbeats stopped; it cannot determine whether the job completed.<br>I used two counters to handle these separately. <strong><em>retry_count</em></strong><em> </em>tracks retries triggered by reported handler failures. <strong><em>delivery_count </em></strong>tracks worker claims and lost dispatches.<br>When a worker becomes stale, the scheduler recovers its job without increasing retry_count. However, repeatedly crashing jobs must not be redelivered indefinitely. The recovery path checks delivery_count against a configured limit and moves the job to dead when that limit is reached.<br>This preserves the handler’s retry budget during worker failures while bounding repeated crash recover</p><h4>Caveats</h4><p><strong>Handler idempotency : </strong>Handlers must be idempotent or use reliable deduplication to prevent duplicate external effects. This does not guarantee that the handler executes only once.</p><p><strong>Scheduler scalability : </strong>Workers can scale across multiple processes and machines. The scheduler currently supports only one instance.</p><p>Thank you for reading. If you found this useful, please like,share and leave a comment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0c65ecfa324f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handling task dependencies at Scale]]></title>
            <link>https://medium.com/@amoghar23/handling-task-dependencies-at-scale-b334f64c4dd1?source=rss-0e4a183884fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/b334f64c4dd1</guid>
            <category><![CDATA[task-dependencies]]></category>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[gda]]></category>
            <category><![CDATA[leastaction]]></category>
            <category><![CDATA[backfill]]></category>
            <dc:creator><![CDATA[Amogha]]></dc:creator>
            <pubDate>Wed, 02 Sep 2026 05:41:02 GMT</pubDate>
            <atom:updated>2026-09-02T05:41:02.907Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>LeastAction never materialises the dependency graph. Each task names its parents and resolves them when its turn comes. Here is the model, the call path, the concurrency, and a 90-day backfill traced through this design and through a DAG file.</blockquote><p>There are two places to write a dependency down. In a file, where the edge is a statement the scheduler parses, so the parser holds the whole shape and can validate it, order it and draw it. Or on the task, where each unit carries its own parents and resolves them when its turn comes, and nothing ever holds the whole shape at once.</p><p>We took the second, because the unit of scheduling here is already the task: independent rows with their own state, schedule and partition. A file-level graph would have meant a second source of truth above those rows, re-parsed and redeployed on every change.</p><h4><strong>PART 1 · HIGH-LEVEL DESIGN</strong></h4><h4><strong>The graph is a query result, not a stored object</strong></h4><p>No edge is ever persisted as an edge. A task holds a list of parent descriptors, and the graph rendered in the UI is the union of those declarations, computed on read.</p><p><strong>Contract · a pre-action returning a boolean run(action_object, parents)</strong></p><p><strong>LeastActionCheckIfParentsAreDone</strong> is a pre-action: a codeblock the platform runs before dispatch, whose return value determines whether dispatch continues.</p><pre>returns True   -&gt; task proceeds down the pipeline<br>returns False  -&gt; dropped from this pass</pre><p>The false branch writes nothing at all. The task retains whichever state it was selected in and is re-evaluated on the next tick, so being blocked is the absence of a transition rather than a transition of its own.</p><p><strong>State · two timestamps, on every task - </strong><strong>logical_date / </strong><strong>prev_interval_start</strong></p><p>logical_date is the interval a task is running for, the data epoch rather than the wall clock. prev_interval_start is the interval it last finished: on success a task copies its own logical_date into it, recording <em>which</em> slot completed rather than when. Both sit on every task, parent or child, and logical_date advances only inside the success path, so a task never advances past an interval it did not complete. A parent is found by the task&#39;s primary key (name, project, account and partition), which is what lets it live in another team&#39;s project on another schedule.</p><blockquote><em>A blocked task and a task that isn’t due yet are the same thing to this scheduler. That is exactly why blocking is free, and exactly why nothing alerts on it.</em></blockquote><h4><strong>PART 2 · LOW-LEVEL DESIGN</strong></h4><p><strong>From cron tick to worker</strong></p><p>Every project runs its own scheduler: CronExecutor.run(), a Celery job supervised by heartbeat. Its work loop polls on a project_scheduler_interval cycle, five seconds by default, and queries the catalog for due tasks. That query is an allow-list on state: scheduled, success or created with next_run_date in the past, plus a retry branch. Anything already running or holding a connection slot is structurally excluded, so a slow run cannot stack up behind itself.</p><ol><li><strong>validate</strong> · dates, connection-operator pairing, referenced items; config merged workflow → task → inline.</li><li><strong>pre_actions</strong> · here is where the dependency check lives. Anything that fails gets dropped from the list.</li><li><strong>connection queue</strong> · survivors grouped by connection, released against available parallelism.</li><li><strong>payload render</strong> · Jinja over merged config and the builtins derived from logical_date.</li><li><strong>dispatch</strong> · the worker runs the operator, writes state back, and advances the schedule.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mgl3Tzq3Z_Xmu8SrMUyOPA.png" /><figcaption>Task sequence flow</figcaption></figure><p>The ordering is the argument. The gate is a semantic check (is the upstream interval present?) and the connection queue is a resource check (can this connection take another concurrent task?). Semantic first means a blocked task never becomes a resource question. Shard a workflow across forty partitions and the blocked ones cost 1 + N catalog reads every five seconds and nothing else; workers track what is runnable, not how large the graph has grown.</p><p>Inside the gate: one lookup for itself, one per parent, keyed on that same primary key. A parent is rejected outright in error, fail, cancelled or cancel. Then the timing half. The <em>parent&#39;s</em> cron is evaluated one step back from the child&#39;s logical_date, yielding the most recent parent slot at or before it, and both that and the parent&#39;s prev_interval_start are truncated to the parent&#39;s granularity. The boundary is inclusive by construction: croniter is seeded one second past the anchor, so a child interval landing exactly on a parent slot resolves to that slot rather than the one before.</p><pre>expected = prev_cron_time(parent_frequency, child_logical_date)<br>actual   = isoparse(parent[&quot;prev_interval_start&quot;])<br>granularity = get_cron_granularity(parent_frequency)return truncate_dt(actual, g) &gt;= truncate_dt(expected, g)</pre><p>Granularity comes from the parent, so mixed frequencies need no special case. A weekly parent satisfies a daily child, because the question is never “did you run today” but “have you finished the interval that covers mine”.</p><p>The write side closes the loop. On success the executor copies logical_date into prev_interval_start, advances it one cron step, and advances next_run_date one interval from the previous next_run_date rather than from the clock. If that is still in the past, the task is due again immediately. Catch-up is not a separate mode; it is what falls out of advancing the schedule from the schedule.</p><h4><strong>PART 3 · CONCURRENCY AND FAILURE</strong></h4><p><strong>Three loops and one contended counter</strong></p><p>One executor per project, three loops inside it, joined by asyncio.gather and stopped by a shared event: work dispatches, heartbeat writes liveness, cleanup reaps. Liveness is on its own loop deliberately. If the work loop wrote the heartbeat, a slow batch would be indistinguishable from a dead scheduler, and the supervisor would restart one that was merely busy.</p><p>Throttling happens in one place, at the contended resource rather than the worker fleet. Every connection carries a max_parallelism; each pass computes max_parallelism - current_parallelism and releases min(available, in_queue) tasks in that connection&#39;s sort order. A global pool would let one slow warehouse starve every other pipeline. Those counters are contended, with a scheduler enqueueing while workers finish and decrement, so enqueue and dequeue run under optimistic concurrency with five retries and backoff rather than a lock.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UKP3Xlx361FAZAAYrZwCUw.png" /><figcaption>The gate sits on a transition, not in a state. A rejected task is left exactly as it was found.</figcaption></figure><p>Failure detection runs at two levels. Workers heartbeat while running, and the cleanup loop fails and dequeues anything past the staleness threshold (12.5 seconds by default), which is what releases the connection’s counter. But an out-of-memory SIGKILL takes the process before it can record anything, so the same loop also queries Celery&#39;s result backend for the run state, which reports FAILURE or REVOKED the moment the worker is lost. At the scheduler level, the project&#39;s heartbeat is stale after three intervals. Both detectors only look at running, so a task held at the gate falls outside both.</p><h4><strong>PART 4 · A 90-DAY BACKFILL, TRACED</strong></h4><p><strong>Re-running history</strong></p><p>Three daily tasks. orders_raw writes the landing table and belongs to another team in another project; orders_enriched reads it; orders_daily_report reads that. A column was computed wrong, so 90 days have to be re-run, upstream first for each day.</p><p>In the DAG-file model the two pipelines are separate parse units, so the cross-pipeline edge is a sensor carrying an interval offset that must be right for every slot in the range, the re-run is a run-level operation, and a poking sensor holds a worker slot unless it is written to defer.</p><p>In the task-level model there is no backfill mode and no second code path, because the check never referred to the present in the first place. The 90 slots are the same three tasks with their interval set back across the range: each success advances next_run_date from the previous one, so while that stays in the past the task is selected again on the next five-second tick and advances one interval, re-running the same gate at every slot. Ninety slots are not ninety sensors; they are one task evaluated ninety times.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*db2reCKst4yIhOt1yog6ow.png" /><figcaption>task-level-gate vs DAG-file table</figcaption></figure><h4><strong>What the choice costs</strong></h4><ul><li><strong>Reruns do not cascade.</strong> Resolution is pull-based, so re-running a parent for a day the child already consumed will not re-trigger it. You re-run the subtree.</li><li><strong>Names are the contract.</strong> Rename a parent and its children start reporting that it cannot be found, and stop. There is no reference to update, because there was never a reference, only a name.</li></ul><p><a href="https://leastactionlabs.com/">LeastAction</a> - source-available, self-hosted data orchestration. <a href="http://github.com/LeastAction-Labs/LeastAction">github.com/LeastAction-Labs/LeastAction</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b334f64c4dd1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is AI Text Watermark?]]></title>
            <link>https://medium.com/@amoghar23/what-is-ai-text-watermark-f20827ca1715?source=rss-0e4a183884fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/f20827ca1715</guid>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[watermark]]></category>
            <category><![CDATA[ai-generated-content]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[chatgpt]]></category>
            <dc:creator><![CDATA[Amogha]]></dc:creator>
            <pubDate>Wed, 19 Aug 2026 13:13:27 GMT</pubDate>
            <atom:updated>2026-08-19T13:13:27.071Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s all over social media that text generated by AI is going to be watermarked and will be detectable if the text was generated with the help of AI .</p><p>As of 2 August 2026, the transparency obligations under Article 50 of the EU AI Act have started applying . It states</p><blockquote>“providers generating synthetic audio, image, video or text must ensure outputs are marked in a machine-readable format and detectable as artificially generated/manipulated. “</blockquote><p>This is an important distinction: the EU does not simply require AI companies to put a visible <strong>AI Generated </strong>label on every piece of text. The requirement is for the content to carry a machine-readable mark that allows AI-generated or manipulated content to be detected.</p><p><strong>In this blog, we’ll be looking into</strong></p><ul><li>What exactly is a digital watermark?</li><li>How can a watermark be added to any piece of content(images, audio, video, or text)</li><li>How does an LLM actually generate a watermark?</li><li>How to check if it’s AI generated ?</li><li>Limitations of the current text watermarking method</li></ul><h3>What exactly is a digital watermark?</h3><p>A digital watermark is a pattern, logo, signal or other piece of information either hidden or visible in the content to indicate the ownership, authenticity or source of the content . <br>For example look at the image below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PXLjrKKinazrS9TzHwsXRw.png" /><figcaption>image generated by Gemini AI</figcaption></figure><p>You can see a small Gemini logo embedded into the image indicating the image was generated with Gemini .</p><h3>How is watermarking done ?</h3><p>Watermarks can be implemented in different ways depending on the type of the content being marked.</p><p>In the case of <strong>images</strong>, a visible watermark can be embedded into the image such as text or a logo and easily recognizable by a person. Similarly, in <strong>videos</strong>, a visible watermark can be overlaid on the video, either throughout the video or at specific points in the timeline.</p><p>Watermarks in images can also be invisible to a person, where the watermark is embedded into the pixels as subtle patterns that are not easily identifiable by the naked eye.</p><p>In <strong>audio</strong>, a watermark can be embedded by making subtle modifications to the audio signal. These changes are designed extremely well that listener does not notice it while still allowing a specialized detector to identify the watermark.</p><p>Watermark does not necessarily have to be visible. Depending on the technique, it can be embedded directly into the underlying data in a way that is imperceptible to humans but detectable by software.</p><p>The other approach that is different than watermarking but is used for similar purpose is <strong>metadata-based provenance</strong></p><p>Files today already contain metadata such as how and when it was created or modified etc..</p><p>Standards such as <a href="https://c2pa.org/">C2PA</a>(Coalition for Content Provenance and Authenticity ) allow digital content to contain cryptographically signed provenance information, known as Content Credentials.</p><p>For example, the AI generated image above contains C2PA Content Credentials indicating information about its origin and how it was created .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*b5jNxsDwKHhGzhPxu1xQQw.png" /><figcaption>metadata of the AI generated image</figcaption></figure><p>For detailed information of the image and its metadata check the <a href="https://c2paviewer.com/report/p4AbBr7mUIMr?token=9ZTs6QFFI3Lx8o9ARs0iXxQD">here</a>.</p><h3>Why is text watermarking difficult and how are AI companies doing it?</h3><p>Watermarking text is considerably more difficult than watermarking an image. With an image, you have millions of pixels that can be modified very slightly without noticeably changing the image. Similarly with videos you have millions of frames that can be modified . Text gives you far fewer places to hide information without potentially changing the way it looks or reads.</p><p>The simplest way of adding watermarks to text is to insert hidden characters, unusual spaces, or other patterns into the text . However a simple find and replace could remove all.</p><p><strong>So how can we add a watermark to text without inserting something obviously unusual into the text itself?</strong></p><p>To understand this effectively, we first need to understand how an LLM generates text. If you already know how ChatGPT, Claude, Gemini, and other LLMs work, you can skip this section. Otherwise, here’s a simplified explanation.</p><p>Think of a Large Language Model(LLM) as a mathematical function that predicts which token is likely to occur next based on the previous tokens.\</p><p>For example, the given sentence looks like</p><blockquote>The dog is</blockquote><p>Given the current sentence, the model assigns different probabilities to the next possible token.</p><ol><li>playing 0.35</li><li>sleeping 0.33</li><li>happy 0.30</li><li>….</li></ol><p>The model then uses this probability distribution to select the next token. Depending on the sampling strategy, the highest-probability token may be selected, or another token may be sampled. The selected token is then added to the sentence, and the process repeats until the response is complete.</p><p>(check <a href="https://youtu.be/LPZh9BOjkQs?si=Gjs6ABP8DdboSEpe">here </a>for detailed explanation on how LLMs work)</p><h3>How are AI companies adding watermarks to text ?</h3><p>Researchers at Google Deepmind came up with a text watermarking method called <a href="https://www.nature.com/articles/s41586-024-08025-4"><strong>SynthID-Text</strong></a>. It is designed to add a watermark during the text-generation process by influencing how the next token is selected from the language model’s probability distribution without affecting the output noticeably .</p><p>SynthID-Text does not require retraining or modifying the underlying language model. Instead it is applied to the generation process. The process involves 2 controllable parameters, the <strong>keys</strong> and the <strong>ngram_len</strong>.</p><ul><li>The <strong>keys</strong> parameter is a list of unique, random integers that are used to compute g-function scores across the model’s vocabulary.</li><li>The <strong>ngram_len</strong> parameter is used to balance robustness and detectability; the larger the value the more detectable the watermark will be, at the cost of being more brittle to changes.</li></ul><p>These parameters are used as part of the watermarking algorithm to generate pseudorandom scores for candidate tokens. SynthID-Text then uses those scores during the sampling process to influence which token is ultimately selected.</p><p>The result is not a visible mark or a hidden character inserted into the text. Instead, the watermark appears as a statistical pattern in the sequence of tokens that the model chooses.</p><h3>How to check if it’s AI generated ?</h3><p>Different AI companies use different watermarking and provenance mechanisms. This means that there is currently no universal watermark detector that can reliably identify text generated by every AI model. Currently companies are still in the process of rolling out capabilities for text AI detection.</p><p>For images and videos, there are already tools available and you can check them out here:-</p><p>OpenAi : <a href="https://openai.com/research/verify/">https://openai.com/research/verify/</a></p><p>Gemini : <a href="https://support.google.com/gemini/answer/16722517?hl=en&amp;co=GENIE.Platform%3DAndroid">https://support.google.com/gemini/answer/16722517?hl=en&amp;co=GENIE.Platform%3DAndroid</a></p><h3>Limitations of text watermark</h3><ul><li>If the size of the sentence is small then identification of whether the sentence was generated with the help of AI is difficult to predict.</li><li>The AI generated output can be easily modified to remove watermarks substantially.</li><li>Watermark only whether a particular AI model was used for the content and varies from company to company, from model to model.</li><li>As of August 2026, there is no single tool or platform that can reliably determine whether a piece of text was generated by AI, regardless of which AI provider or model was used.</li><li>Even if the entire content written by a human and corrected for mistakes, formatting etc it can still show up as AI generated in the detector.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f20827ca1715" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>