Skip to content

Commit eb7d024

Browse files
authored
Update index.bs to include Proofreading usage and Permissions policy integration
1 parent d7c600d commit eb7d024

File tree

1 file changed

+178
-0
lines changed

1 file changed

+178
-0
lines changed

index.bs

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,175 @@ The <dfn attribute for="Proofreader">correctionExplanationLanguage</dfn> getter
355355
1. Return the result of [=measuring AI model input usage=] given [=this=], |options|, and |measureUsage|.
356356
</div>
357357

358+
<h3 id="proofreader-proofreading">Proofreading</h3>
359+
360+
<h4 id="proofreader-algorithm">The algorithm</h4>
361+
362+
<div algorithm>
363+
To <dfn>proofreader</dfn> given:
364+
365+
* a [=string=] |input|,
366+
* a [=boolean=] |includeCorrectionTypes|,
367+
* a [=boolean=] |includeCorrectionExplanations|,
368+
* a [=string=]-or-null |correctionExplanationLanguage|,
369+
* an algorithm |chunkProduced| that takes a [=string=] and returns nothing,
370+
* an algorithm |done| that takes no arguments and returns nothing,
371+
* an algorithm |error| that takes [=error information=] and returns nothing, and
372+
* an algorithm |stopProducing| that takes no arguments and returns a boolean,
373+
374+
perform the following steps:
375+
376+
1. [=Assert=]: this algorithm is running [=in parallel=].
377+
378+
1. Let |requested| be the result of [=measuring proofreader input usage=] given |input|, |includeCorrectionTypes|, |correctionExplanationLanguage|, |correctionExplanationLanguage|, and |stopProducing|.
379+
380+
1. If |requested| is null, then return.
381+
382+
1. If |requested| is an [=error information=], then:
383+
384+
1. Perform |error| given |requested|.
385+
386+
1. Return.
387+
388+
1. [=Assert=]: |requested| is a number.
389+
390+
1. In an [=implementation-defined=] manner, subject to the following guidelines, begin the process of proofreading |input| into a {{ProofreadResult}} with a [=string=] |correctedInput| as the proofread text and a {{ProofreadCorrections}} |corrections| detailing all the corrections made to |input| to form |correctedInput|.
391+
392+
If |input| is the empty string, or otherwise consists of no proofreadable content (e.g., only contains whitespace, or control characters), then the resulting proofread text should be the empty string. In such cases, |includeCorrectionTypes|, |includeCorrectionExplanations|, and |correctionExplanationLanguage| should be ignored.
393+
394+
The proofreading should conform to the guidance given by |includeCorrectionTypes| and |includeCorrectionExplanations|.
395+
396+
The proofreading process must conform to the guidance given in [[#privacy]] and [[#security]], notably including (but not limited to) [[#privacy-user-input]] and [[#security-runtime]].
397+
398+
If |correctionExplanationLanguage| is non-null, the proofreading should be in that language. Otherwise, it should be in the language of |input|. If |input| contains multiple languages, or the language of |input| cannot be detected, then either the correction explanation language is [=implementation-defined=], or the implementation may treat this as an error, per the guidance in [[#proofreader-errors]].
399+
400+
Implementers should do their utmost to ensure that the result is an actual proofread result of |input|, and is not arbitrary output prompted by |input|.
401+
402+
<p class="example" id="example-bad-proofread-question-answering">For example, if |input| is "`what is capital of France`", then it would be incorrect to answer this question, e.g. by outputting "`Paris is the capital of France.`" A more correct output would be, e.g., "`What is the capital of France?`".
403+
404+
1. Wait for the next chunk of proofreading data to be produced, for the proofreading process to finish, or for the result of calling |stopProducing| to become true.
405+
406+
1. If such a chunk is successfully produced:
407+
408+
1. Let it be represented as a [=string=] |chunk|.
409+
410+
1. Perform |chunkProduced| given |chunk|.
411+
412+
1. Otherwise, if the proofreading process has finished:
413+
414+
1. Perform |done|.
415+
416+
1. [=iteration/Break=].
417+
418+
1. Otherwise, if |stopProducing| returns true, then [=iteration/break=].
419+
420+
1. Otherwise, if an error occurred during proofreading:
421+
422+
1. Let the error be represented as [=error information=] |errorInfo| according to the guidance in [[#proofreader-errors]].
423+
424+
1. Perform |error| given |errorInfo|.
425+
426+
1. [=iteration/Break=].
427+
</div>
428+
429+
<h4 id="proofreader-usage">Usage</h4>
430+
431+
<div algorithm>
432+
To <dfn>measure proofreader input usage</dfn>, given:
433+
434+
* a [=string=] |input|,
435+
* a [=boolean=] |includeCorrectionTypes|,
436+
* a [=boolean=] |includeCorrectionExplanations|,
437+
* a [=string=]-or-null |correctionExplanationLanguage|, and
438+
* an algorithm |stopMeasuring| that takes no arguments and returns a boolean,
439+
440+
perform the following steps:
441+
442+
1. [=Assert=]: this algorithm is running [=in parallel=].
443+
444+
1. Let |inputToModel| be the [=implementation-defined=] string that would be sent to the underlying model in order to [=proofread=] given |input|, |includeCorrectionTypes|, |includeCorrectionExplanations|, and |correctionExplanationLanguage|.
445+
446+
If during this process |stopMeasuring| starts returning true, then return null.
447+
448+
If an error occurs during this process, then return an appropriate [=DOMException error information=] according to the guidance in [[#proofreader-errors]].
449+
450+
1. Return the amount of input usage needed to represent |inputToModel| when given to the underlying model. The exact calculation procedure is [=implementation-defined=], subject to the following constraints.
451+
452+
The returned input usage must be nonnegative and finite. It must be 0, if there are no usage quotas for the proofreading process. Otherwise, it must be positive and should be roughly proportional to the [=string/length=] of |inputToModel|.
453+
454+
<p class="note" id="note-proofreader-input-usage">This might be the number of tokens needed to represent |input| in a <a href="https://arxiv.org/abs/2404.08335">language model tokenization scheme</a>, or it might be |input|'s [=string/length=]. It could also be some variation of these which also counts the usage of any prefixes or suffixes necessary to give to the model.
455+
456+
If during this process |stopMeasuring| starts returning true, then instead return null.
457+
458+
If an error occurs during this process, then instead return an appropriate [=DOMException error information=] according to the guidance in [[#proofreader-errors]].
459+
</div>
460+
461+
<h4 id="proofreader-options">Options</h4>
462+
463+
The [=proofread=] algorithm's details are [=implementation-defined=], as they are expected to be powered by an AI model. However, it is intended to be controllable by the web developer through the |includeCorrectionTypes| and |includeCorrectionExplanations| flags.
464+
465+
This section gives normative guidance on how the implementation of [=proofread=] should use each boolean flag to guide the proofreading process.
466+
467+
<table class="data enum-table">
468+
<caption>|includeCorrectionTypes| values</caption>
469+
<thead>
470+
<tr>
471+
<th>Value
472+
<th>Meaning
473+
<tbody>
474+
<tr>
475+
<th>"<dfn boolean-value for="includeCorrectionTypes">true</dfn>"
476+
<td>
477+
<p>The proofread result should contain a list of corrections where each {{ProofreadCorrection}}, defined by its range from |startIndex| to |endIndex|, should describe the types of errors that are corrected according to the {{CorrectionType}} enumeration.
478+
<tr>
479+
<th>"<dfn boolean-value for="includeCorrectionTypes">false</dfn>"
480+
<td>
481+
<p>The proofread result should contain a list of corrections where each {{ProofreadCorrection}}, defined by its range from |startIndex| to |endIndex|, does not provide the types of errors that are corrected.
482+
<tr>
483+
<th>"<dfn boolean-value for="includeCorrectionExplanations">true</dfn>"
484+
<td>
485+
<p>The proofread result should contain a list of corrections where each {{ProofreadCorrection}}, defined by its range from |startIndex| to |endIndex|, should provide a text explanation for the errors corrected.
486+
<tr>
487+
<th>"<dfn boolean-value for="includeCorrectionTypes">false</dfn>"
488+
<td>
489+
<p>The proofread result should contain a list of corrections where each {{ProofreadCorrection}}, defined by its range from |startIndex| to |endIndex|, does not provide the text explanation for the errors corrected.
490+
</table>
491+
492+
<p class="note">As with all "<span class="allow-2119">should</span>"-level guidance, user agents might not conform perfectly to these. Especially in the case of providing correction types for all corrections, it's expected that language models might not conform perfectly.
493+
494+
<h4 id="proofreader-errors">Errors</h4>
495+
496+
When proofreading fails, the following possible reasons may be surfaced to the web developer. This table lists the possible {{DOMException}} [=DOMException/names=] and the cases in which an implementation should use them:
497+
498+
<table class="data">
499+
<thead>
500+
<tr>
501+
<th>{{DOMException}} [=DOMException/name=]
502+
<th>Scenarios
503+
<tbody>
504+
<tr>
505+
<td>"{{NotAllowedError}}"
506+
<td>
507+
<p>Proofreading is disabled by user choice or user agent policy.
508+
<tr>
509+
<td>"{{NotSupportedError}}"
510+
<td>
511+
<p>The input to be proofread, or the context to be provided, was in a language that the user agent does not support, or was not provided properly in the call to {{Proofreader/create()}}.
512+
513+
<p>The proofreading correction explanation language ended up being in a language that the user agent does not support (e.g., because the user agent has not performed sufficient quality control tests on that output language), or was not provided properly in the call to {{Proofreader/create()}}.
514+
515+
<p>The |includeCorrectionExplanations| is set to true, the {{ProofreaderCreateCoreOptions/correctionExplanationLanguage}} option was not set, and the language of the input text could not be determined, so the user agent did not have a good correction explanation language default available.
516+
<tr>
517+
<td>"{{UnknownError}}"
518+
<td>
519+
<p>All other scenarios, including if the user agent believes it cannot proofread and also meet the requirements given in [[#privacy]] or [[#security]]. Or, if the user agent would prefer not to disclose the failure reason.
520+
</table>
521+
522+
<p class="note">This table does not give the complete list of exceptions that can be surfaced by the proofreader API. It only contains those which can come from certain [=implementation-defined=] steps.
523+
524+
<h3 id="proofreader-permissions-policy">Permissions policy integration</h3>
525+
526+
Access to the proofreader API is gated behind the [=policy-controlled feature=] "<dfn permission>proofreader</dfn>", which has a [=policy-controlled feature/default allowlist=] of <code>[=default allowlist/'self'=]</code>.
358527

359528
<h2 id="supporting">Shared infrastructure</h2>
360529

@@ -375,3 +544,12 @@ enum Availability {
375544
"available"
376545
};
377546
</xmp>
547+
548+
<h2 id="privacy">Privacy considerations</h2>
549+
550+
<h3 id="privacy-user-input">User input</h3>
551+
552+
<h2 id="security">Security considerations</h2>
553+
554+
<h3 id="security-runtime">Runtime shared resources</h3>
555+

0 commit comments

Comments
 (0)