跳到正文
DEV Community· Dreven·· 2 小時前AI 評分40

Quillgrain 如何在交由模型撰寫前驗證寫作語境

I verify the voice context before I ask a model to write

AI 導讀

Quillgrain 0.1.0rc3 可將明確選定的語氣套件編譯成本機寫作語境,並在交由模型撰寫前驗證其相容性。驗證會檢查雜湊、語言、語域、標籤及核准的模型主機;範例中的編譯與驗證均在本機完成,沒有呼叫模型。

正文

A mismatch before the first sentence

An English voice bundle attached to a Russian request is a problem before the first sentence exists. The request can be well formed while carrying writing instructions that belong to a different language or format.

I want to catch that mismatch while the input is still something I can inspect. In Quillgrain, I compile an explicitly chosen voice pack into local writing context, then verify that context before handing it to a model.

That gives me a concrete boundary in a writing tool: prepare the instructions, check their identity and scope, then ask for prose. Compilation itself does not call Ollama or any other model.

The small example I can check locally

For this example I used Quillgrain 0.1.0rc3 and the public demonstration pack in the PatchPitch checkout. The pack lives at examples/editorial/voice; the code below is meant to run from that checkout with the engine installed. The setup guide covers the pinned integration.

The pack contains designed editorial preferences: connected explanations, concrete examples and first-person prose. Its long-form and short-X rules have separate scopes. There are no personal writing samples hidden inside this demo.

Here is the complete compile-and-verify example. The selected context is English, uses the maker_announcement register and is scoped to social.longform on the ollama host.

from quillgrain.compose import compile_context
from quillgrain.consumer import bundle, verify_bundle

context, lock = compile_context(
    "examples/editorial/voice", language="en", register="maker_announcement",
    target="patchpitch", model_host="ollama", tags=["social.longform"], max_chars=8000,
)
checked = verify_bundle(bundle(context, lock), model_host="ollama",
    language="en", register="maker_announcement", tags=["social.longform"])
print(checked["build_id"])

The successful run returned a verified context with a build ID. Both compilation and verification completed locally; this example made no model request.

The editorial decision comes after the check

I also checked the failure path: asking the verifier to use the same English bundle for Russian was rejected before inference. That is the kind of mismatch I want a request builder to catch, rather than discovering it in the generated article.

The bundle keeps the compiled context together with its lock. Verification checks the hashes, language, register, tags and approved model host. I can use those checks to stop an incompatible profile from slipping into a request.

Passing the check does not make the resulting prose sound like me. The demo profile is a set of explicit preferences, not a learned personal voice. I still need to read the opening, check the examples and decide which sentences belong in the article.

For me, the useful part is having a writing context I can inspect and a separate editorial decision after generation. The compiler can establish structure and compatibility; the draft still has to earn its place on the page.

Where do you catch writing-context mistakes today: in the request builder, or only when you read the output?

來源:DEV Community · dev.to