ข้ามไปยังเนื้อหาหลัก

ข้อกำหนดของ Method Plugin

เวอร์ชัน: 1.1
กลุ่มเป้าหมาย: นักพัฒนา Plugin
Canonical Schema: schemas/rosetta-plugin.schema.json

ภาพรวม

i18n-rosetta ใช้ ระบบ method แบบปลั๊กอิน (pluggable method system) แต่ละคู่ภาษาสามารถใช้วิธีการแปล (translation method) ที่แตกต่างกันได้ (เช่น LLM, coached, script-converter เป็นต้น) Method ต่างๆ จะถูกลงทะเบียนใน lib/translate.js และถูกเรียกใช้ตามแต่ละคู่ภาษาผ่าน lib/pairs.js

หน้าที่ของ eval harness คือการ พัฒนา ทดสอบ และส่งออก translation method ส่วนหน้าที่ของ i18n-rosetta คือการ นำไปใช้และประมวลผล method เหล่านั้น harness จะไม่ทำงานอยู่ภายใน rosetta

การไหลของข้อมูล (Data Flow)


รูปแบบของ Method Plugin

Method plugin คือไฟล์ JSON เดี่ยว (method.json) ซึ่งอาจมีไฟล์ข้อมูล coaching รวมอยู่ด้วยหรือไม่ก็ได้

method.json — จำเป็นต้องมี

{
"name": "french-formal-v1",
"type": "llm-coached",
"version": "1.0.0",
"description": "Formally-tuned French with terminology enforcement and grammar coaching",
"author": "Plugin Author",

"config": {
"model": "google/gemini-3.5-flash",
"register": "formal",
"batchSize": 80,
"temperature": 0.2
},

"locales": ["fr"],

"benchmarks": {
"fr": {
"date": "2026-05-11T00:00:00Z",
"corpus_size": 500,
"exact_match_rate": 0.42,
"corpus_chrf": 72.3,
"corpus_bleu": 45.1,
"model": "google/gemini-3.5-flash",
"harness_version": "1.0.0"
}
},

"provenance": {
"resources": [],
"commercialReady": false,
"flags": ["license-unclear"]
},

"coaching": {
"dir": "coaching"
}
}

ข้อมูลอ้างอิงฟิลด์ (Field Reference)

ฟิลด์ประเภทจำเป็นคำอธิบาย
namestringตัวระบุ method ที่ไม่ซ้ำกัน (รูปแบบ kebab-case)
typestringประเภท method ของ Rosetta: llm, llm-coached, api, google-translate, deepl, microsoft-translator, libretranslate, openai, anthropic, gemini
versionstringเวอร์ชันแบบ Semver (เช่น 1.0.0)
localesstring[]รหัส locale ที่ method นี้รองรับ (อย่างน้อย 1)
descriptionstringคำอธิบายที่มนุษย์อ่านเข้าใจได้
authorstringผู้ที่พัฒนา/ทดสอบ method นี้
config.modelstringตัวระบุโมเดล OpenRouter
config.registerstringระดับภาษา/น้ำเสียง (register/tone) ของภาษาเป้าหมาย
config.batchSizenumberจำนวนคีย์ต่อ API batch (1–200, ค่าเริ่มต้น: 80)
config.temperaturenumberค่า temperature ของ LLM (0.0–2.0, ค่าเริ่มต้น: 0.3)
benchmarksobjectผลลัพธ์ benchmark ของแต่ละ locale
provenanceobjectข้อมูลสิทธิ์การใช้งาน (Licensing) และ resource dependencies
coaching.dirstringPath สัมพัทธ์ไปยังไดเรกทอรีข้อมูล coaching

ออบเจ็กต์ Benchmark (ต่อ locale)

ฟิลด์ประเภทจำเป็นคำอธิบาย
datestringTimestamp รูปแบบ ISO 8601 ของการรัน benchmark
corpus_sizenumberจำนวนรายการที่ถูกประเมิน
exact_match_ratenumber0.0–1.0, สัดส่วนของการจับคู่ที่ตรงกันทุกประการ (exact matches)
corpus_chrfnumberคะแนน chrF++ (0–100)
corpus_bleunumberคะแนน BLEU (0–100)
modelstringโมเดลที่ใช้ระหว่างการประเมิน (eval)
harness_versionstringเวอร์ชันของ evaluation harness ที่ใช้

:::info เมตริกใดบ้างที่ถูกแสดงผล? คำสั่ง rosetta status จะแสดง chrF++ และ อัตราการจับคู่ที่ตรงกันทุกประการ (exact match rate) จากบล็อก benchmark corpus_bleu ได้รับการยอมรับใน manifest แต่ปัจจุบันยังไม่ถูกแสดงผลหรือใช้งานโดยคำสั่งใดๆ ของ rosetta Method Leaderboard จะติดตามคะแนน chrF++, exact match และอัตราการยอมรับของ FST (FST acceptance rate) :::


ออบเจ็กต์ Provenance

บล็อก provenance ใช้สื่อสารสถานะสิทธิ์การใช้งานของทรัพยากรที่รวมอยู่ในปลั๊กอิน

ฟิลด์ประเภทค่าเริ่มต้นคำอธิบาย
resourcesobject[][]รายการทรัพยากรที่รวมอยู่ด้วย พร้อม name, license และ type
commercialReadybooleanfalseระบุว่าปลั๊กอินนี้ได้รับอนุญาตให้แจกจ่ายในเชิงพาณิชย์หรือไม่
flagsstring[]["license-unclear"]แฟล็กสถานะที่เครื่องอ่านได้ (Machine-readable status flags)

สถานะเริ่มต้น — ปลั๊กอินที่ส่งออกมาจะมาพร้อมกับ commercialReady: false และ flags: ["license-unclear"]

สถานะที่ได้รับอนุญาตแล้ว (Cleared state) — เมื่อตรวจสอบสิทธิ์การใช้งานเรียบร้อยแล้ว: ให้ตั้งค่า commercialReady: true และล้างค่าแฟล็กต่างๆ


รูปแบบข้อมูล Coaching

หาก type เป็น llm-coached ปลั๊กอินควรมีไฟล์ข้อมูล coaching อยู่ในไดเรกทอรีย่อย coaching/

coaching/<locale>.json

{
"grammar_rules": [
"French adjectives agree in gender and number with the noun they modify",
"Use 'vous' for formal contexts, 'tu' for informal"
],
"dictionary": {
"dashboard": "tableau de bord",
"deployment": "déploiement",
"settings": "paramètres"
},
"style_notes": "Prefer active voice. Avoid anglicisms where a native French term exists."
}
ฟิลด์ประเภทจำเป็นคำอธิบาย
grammar_rulesstring[]กฎที่ถูกแทรกเข้าไปในทุกๆ LLM prompt สำหรับ locale นี้
dictionaryobjectแมปคำศัพท์ → คำแปล คำศัพท์ที่ตรงกันจะถูกแทรกเป็นคำศัพท์บังคับ (required terminology)
style_notesstringคำแนะนำสไตล์แบบอิสระ (Freeform style instructions) ที่ต่อท้าย prompt

โครงสร้างไดเรกทอรี

french-formal-v1/
method.json # Method manifest with benchmarks
coaching/
fr.json # Coaching data for French

สำหรับ method ที่รองรับหลาย locale:

european-formal-v2/
method.json # locales: ["fr", "de", "es", "it"]
coaching/
fr.json
de.json
es.json
it.json

วิธีที่ Rosetta นำปลั๊กอินไปใช้งาน

การติดตั้ง

i18n-rosetta plugin install ./french-formal-v1/

บันทึกลงใน .rosetta/methods/french-formal-v1/

การตั้งค่า (Configuration)

i18n-rosetta.config.json
{
"pairs": {
"en:fr": {
"methodPlugin": "french-formal-v1"
}
}
}

:::info ความหมายของการผสานข้อมูล (Merge semantics) ปลั๊กอินจะกำหนดว่า ต้องใช้ method ใด (type) การตั้งค่าของคู่ภาษา (pair config) จะปรับแต่งว่า จะรันมันอย่างไร (model, register, batchSize) หากคู่ภาษามีการตั้งค่า model ค่านี้จะทับซ้อน (override) ค่าเริ่มต้นของปลั๊กอิน :::

ช่วงเวลาการทำงาน (Runtime)

  1. Rosetta อ่าน method.json จาก .rosetta/methods/french-formal-v1/
  2. ฟิลด์ type ของปลั๊กอินจะกำหนด translation method (เช่น llm-coached)
  3. โหลดข้อมูล coaching จากไดเรกทอรี coaching/ ของปลั๊กอิน
  4. ใช้บล็อก config เพื่อเติมเต็มข้อมูลที่ขาดหายไปในส่วนของ model/register/temperature
  5. บล็อก benchmarks จะถูกแสดงในผลลัพธ์ของ rosetta status
  6. บล็อก provenance จะถูกตรวจสอบโดย rosetta provenance เพื่อหาแฟล็กสิทธิ์การใช้งาน (licensing flags)

การตรวจสอบความถูกต้องของ Schema (Schema Validation)

Plugin manifests จะถูกตรวจสอบความถูกต้องในขณะติดตั้งโดยเทียบกับ schemas/rosetta-plugin.schema.json

อ้างอิง schema ใน method.json ของคุณเพื่อให้ IDE เติมโค้ดอัตโนมัติ (autocompletion):

{
"$schema": "./node_modules/i18n-rosetta/schemas/rosetta-plugin.schema.json",
"name": "my-method-v1"
}

สิ่งที่ "ห้าม" รวมไว้

  • ❌ ไม่มีโค้ด Python หรือ harness dependencies
  • ❌ ไม่มีข้อมูล corpus ดิบหรือบันทึกการรัน (run logs)
  • ❌ ไม่มี API keys หรือข้อมูลประจำตัว (credentials)
  • ❌ ไม่มีการตั้งค่า harness
  • ❌ ไม่มีเทมเพลต prompt ภายใน (สิ่งเหล่านี้จะอยู่ใน method implementations ของ rosetta)

ปลั๊กอินนี้เป็น ข้อมูลเท่านั้น (data only): การตั้งค่า, เนื้อหา coaching และผลลัพธ์ benchmark


ดูเพิ่มเติม