File size: 10,798 Bytes
e224fb7
 
 
 
5b4e4c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24536ec
 
 
 
 
 
 
 
 
 
 
 
5b4e4c8
 
 
 
 
 
e224fb7
5b4e4c8
 
 
e224fb7
 
 
5b4e4c8
 
e224fb7
 
 
 
24536ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e224fb7
 
 
 
401c1a6
e224fb7
 
5eb8195
 
 
 
714588e
 
5eb8195
 
 
 
 
 
4cfcba2
0db3cf1
5eb8195
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e224fb7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0db3cf1
e224fb7
 
 
 
 
 
0db3cf1
e224fb7
 
 
 
 
 
 
 
 
 
 
 
5b4e4c8
83be564
 
 
5b4e4c8
24536ec
5b4e4c8
e224fb7
 
5b4e4c8
 
 
 
 
 
a9f773b
5b4e4c8
 
e224fb7
ed5200a
5b4e4c8
 
4cfcba2
83be564
e224fb7
4cfcba2
 
 
e224fb7
4cfcba2
 
 
 
 
 
 
 
e224fb7
4cfcba2
 
 
 
 
 
cda1e75
4cfcba2
e224fb7
4cfcba2
 
 
 
 
 
e224fb7
c119d8b
 
4cfcba2
e224fb7
4cfcba2
 
e224fb7
4cfcba2
db413ca
4cfcba2
 
d1b9ce2
4cfcba2
 
db413ca
4cfcba2
cda1e75
4cfcba2
 
db413ca
4cfcba2
cda1e75
4cfcba2
 
db413ca
4cfcba2
cda1e75
4cfcba2
 
db413ca
4cfcba2
cda1e75
4cfcba2
 
db413ca
4cfcba2
cda1e75
4cfcba2
 
db413ca
4cfcba2
cda1e75
4cfcba2
 
db413ca
4cfcba2
db413ca
4cfcba2
db413ca
4cfcba2
 
 
db413ca
4cfcba2
 
 
 
 
 
 
 
 
 
cda1e75
4cfcba2
 
 
 
d1b9ce2
4cfcba2
 
 
 
db413ca
4cfcba2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e224fb7
cda1e75
4cfcba2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cda1e75
4cfcba2
 
 
 
 
 
 
 
5d2ad64
4cfcba2
 
 
 
 
 
 
 
 
 
 
 
 
 
cda1e75
4cfcba2
 
 
 
 
cda1e75
4cfcba2
 
 
 
 
cda1e75
4cfcba2
 
 
 
 
cda1e75
4cfcba2
 
 
 
 
 
 
e224fb7
 
401c1a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# NOTE:
# This is a starter layout for the redesigned MTQE demo.
# Copy your existing evaluate() function and LANGUAGES dictionary into this file.

import os
import requests
import gradio as gr

API_URL = "https://api.pangeanic.com/mtqe/v2/score"
API_KEY = os.environ.get("MTQE_API_Key", "")

LANGUAGES = {
    "English": "en-us",
    "Spanish": "es-es",
    "French": "fr-fr",
    "German": "de-de",
    "Italian": "it-it",
    "Portuguese": "pt-pt",
    "Russian": "ru-ru",
    "Chinese": "zh-cn",
    "Japanese": "ja-jp",
    "Korean": "ko-kr",
    "Arabic": "ar-001",
    "Thai": "th-th",
    "Vietnamese": "vi-vn",
    "Lithuanian": "lt-lt",
    "Swedish": "sv-se",
}

def score_color(score):
    if score >= 90:
        return "#22C55E"      # Green
    elif score >= 75:
        return "#84CC16"      # Lime
    elif score >= 60:
        return "#FACC15"      # Yellow
    elif score >= 40:
        return "#FB923C"      # Orange
    else:
        return "#EF4444"      # Red

def evaluate(source_language, target_language, source, target):
    payload = {
        "source": source,
        "target": target,
        "source_language": LANGUAGES[source_language],
        "target_language": LANGUAGES[target_language],
        "ape": False,
    }

    headers = {
        "accept": "application/json",
        "Content-Type": "application/json",
        "X-API-Key": API_KEY,
    }

    r = requests.post(API_URL, json=payload, headers=headers, timeout=60)
    r.raise_for_status()
    j = r.json()

    score = j["score"]
    explanation = j["explanation"]
    
    color = score_color(score)
    
    html = f"""
    <div style="
    border:1px solid #ececec;
    border-radius:14px;
    padding:18px 20px;
    background:white;
    display:flex;
    align-items:flex-start;
    gap:18px;
    ">
    
    <div style="
    min-width:56px;
    height:36px;
    border-radius:10px;
    background:{color}20;
    color:{color};
    display:flex;
    align-items:center;
    justify-content:center;
    font-weight:700;
    font-size:20px;
    ">
    {round(score)}
    </div>
    
    <div style="
    border-left:2px solid #d6d6d6;
    padding-left:18px;
    flex:1;
    font-size:16px;
    line-height:1.7;
    color:#374151;
    ">
    
    {explanation if explanation else "<span style='color:#16A34A;'>No issues detected.</span>"}
    
    </div>
    
    </div>
    """
    
    return html


theme = gr.themes.Soft(primary_hue="orange", radius_size="lg")

with gr.Blocks(title="Pangeanic MTQE") as demo:

    gr.HTML("""
<div style="
    background: linear-gradient(180deg,#ffffff,#fafafa);
    border:1px solid #ececec;
    border-radius:20px;
    padding:8px 12px;
    margin-bottom:12px;
">

<div style="display:flex;justify-content:space-between;align-items:center;">

<div>

<img src="https://blog.pangeanic.com/hubfs/assets/logo-pangeanic.png"
     style="height:42px;margin-bottom:18px;">

<div style="
font-size:42px;
font-weight:700;
color:#F58220;
line-height:1.1;
margin-bottom:8px;
">
MTQE v2
</div>

<div style="
font-size:22px;
font-weight:500;
color:#25324B;
margin-bottom:24px;
">
Reference-free Machine Translation Quality Estimation
</div>

<div style="
max-width:760px;
font-size:17px;
line-height:1.8;
color:#5A6473;
">
</div>

</div>

</div>

</div>
""")

    with gr.Group():

        with gr.Row():
            source_language = gr.Dropdown(
                choices=list(LANGUAGES.keys()),
                value="English",
                label="Source Language",
            )

            target_language = gr.Dropdown(
                choices=list(LANGUAGES.keys()),
                value="Spanish",
                label="Target Language",
            )

        with gr.Row():

            source = gr.Textbox(
                label="Source Text",
                lines=3,
                placeholder="Enter the original text...",
                scale=1,
            )

            target = gr.Textbox(
                label="Translation",
                lines=3,
                placeholder="Enter the translated text...",
                scale=1,
            )

        with gr.Row():
            evaluate_btn = gr.Button(
                "Evaluate Translation",
                variant="primary",
                scale=3,
            )

            clear = gr.ClearButton(scale=1)

    gr.HTML("""
    <h2 style="margin:15px 0 10px 0;">Results</h2>
    """)

    result = gr.HTML(label="Assessment")

    evaluate_btn.click(
        evaluate,
        inputs=[
            source_language,
            target_language,
            source,
            target,
        ],
        outputs=result,
    )

    clear.add(
        [source, target, result]
    )

    gr.HTML("""
<div style="max-width:1100px;margin:20px auto;font-family:Inter,Segoe UI,sans-serif;">

<!-- ======================================================= -->
<!-- Beyond the Demo -->
<!-- ======================================================= -->

<div style="
background:#ffffff;
border:1px solid #e8e8e8;
border-radius:18px;
padding:36px;
box-shadow:0 4px 16px rgba(0,0,0,.05);
margin-bottom:32px;
">

<h2 style="
margin-top:0;
color:#F58220;
font-size:32px;
font-weight:700;
">
Beyond the Demo
</h2>

<p style="
font-size:17px;
line-height:1.8;
color:#555;
margin-bottom:28px;
">

This interactive demo showcases the core capabilities of
Pangeanic MTQE v2 by estimating translation quality from a source
sentence and its translation without requiring reference translations.

The complete enterprise platform extends these capabilities with advanced
features designed for production localization workflows.

</p>

<div style="
display:grid;
grid-template-columns:repeat(auto-fit,minmax(160px,1fr));
gap:18px;
">

<div style="border:1px solid #eee;border-radius:14px;padding:18px;">
<h3 style="color:#F58220;margin-top:0;">Translation Memory</h3>
<p>Incorporate Translation Memory matches into quality estimation.</p>
</div>

<div style="border:1px solid #eee;border-radius:14px;padding:18px;">
<h3 style="color:#F58220;margin-top:0;">Glossary Validation</h3>
<p>Detect terminology inconsistencies and enforce approved terminology.</p>
</div>

<div style="border:1px solid #eee;border-radius:14px;padding:18px;">
<h3 style="color:#F58220;margin-top:0;">Automatic Post-Editing</h3>
<p>Automatically improve low-quality translations before delivery.</p>
</div>

<div style="border:1px solid #eee;border-radius:14px;padding:18px;">
<h3 style="color:#F58220;margin-top:0;">Human Post-Editing</h3>
<p>Prioritize segments requiring human review to optimize post-editing effort.</p>
</div>

<div style="border:1px solid #eee;border-radius:14px;padding:18px;">
<h3 style="color:#F58220;margin-top:0;">REST API</h3>
<p>Integrate MTQE directly into CAT tools and enterprise localization platforms.</p>
</div>

<div style="border:1px solid #eee;border-radius:14px;padding:18px;">
<h3 style="color:#F58220;margin-top:0;">70+ Languages</h3>
<p>Supports more than 70 languages and regional variants for multilingual enterprise workflows.</p>
</div>

</div>

</div>

<!-- ======================================================= -->
<!-- Benchmark -->
<!-- ======================================================= -->

<div style="
background:#ffffff;
border:1px solid #e8e8e8;
border-radius:18px;
padding:36px;
box-shadow:0 4px 16px rgba(0,0,0,.05);
margin-bottom:32px;
">

<h2 style="margin-top:0;color:#F58220;font-size:32px;">
Benchmark Highlights
</h2>

<div style="
display:grid;
grid-template-columns:repeat(auto-fit,minmax(160px,1fr));
gap:20px;
margin:30px 0;
text-align:center;
">

<div>
<div style="font-size:42px;font-weight:700;color:#F58220;">98.9%</div>
<div>Correct rejection accuracy</div>
</div>

<div>
<div style="font-size:42px;font-weight:700;color:#F58220;">6006</div>
<div>Incorrect segments</div>
</div>

<div>
<div style="font-size:42px;font-weight:700;color:#F58220;">16</div>
<div>Language pairs</div>
</div>

<div>
<div style="font-size:42px;font-weight:700;color:#F58220;">0.49s</div>
<div>Average latency</div>
</div>

</div>

<h3 style="color:#F58220;">Benchmark Methodology</h3>

<p style="line-height:1.8;color:#555;">

Pangeanic MTQE v2 was validated using a representative subset of the
<b><a href="https://huggingface.co/datasets/nikitam/ACES" target="_blank">
ACES multilingual benchmark</a></b>,
covering <b>6,006 deliberately incorrect translation segments</b>,
<b>16 language pairs</b>, and
<b>68 translation error categories</b>.

</p>

<ol style="line-height:1.8;color:#555;">

<li>Machine translations were generated across sixteen multilingual language pairs.</li>

<li>Thousands of deliberately incorrect translation segments were collected to simulate realistic production errors.</li>

<li>MTQE evaluated each segment using only the source sentence and translated output, without requiring reference translations.</li>

<li>Predictions were compared against manually validated quality labels.</li>

<li>Additional experiments evaluated Automatic Post-Editing recovery performance.</li>

</ol>

<p>

<a href="https://pangeanic.com/hubfs/MTQE_Benchmark_Whitepaper.pdf" target="_blank">
Read the Benchmark Whitepaper
</a>

</p>

</div>

<!-- ======================================================= -->
<!-- Contact -->
<!-- ======================================================= -->

<div style="
background:#F58220;
border-radius:20px;
padding:40px;
color:white;
text-align:center;
">

<h2 style="margin-top:0;color:white;">
Interested in the Full MTQE Platform?
</h2>

<p style="
font-size:17px;
line-height:1.8;
max-width:850px;
margin:auto;
margin-bottom:30px;
color:#25324B;
">

The complete enterprise platform includes Translation Memory support,
Glossary validation, Automatic and Human Post-Editing workflows,
batch processing, REST API integration, and multilingual support for
more than 70 languages and dialects.

</p>

<div style="display:flex;justify-content:center;gap:20px;flex-wrap:wrap;">

<a href="https://pangeanic.com/hubfs/MTQE_Benchmark_Whitepaper.pdf"
target="_blank"
style="background:white;color:#F58220;padding:14px 24px;border-radius:10px;text-decoration:none;font-weight:600;">
Whitepaper
</a>

<a href="https://docs.pangeanic.com/"
target="_blank"
style="background:white;color:#F58220;padding:14px 24px;border-radius:10px;text-decoration:none;font-weight:600;">
API Docs
</a>

<a href="https://www.pangeanic.com/"
target="_blank"
style="background:white;color:#F58220;padding:14px 24px;border-radius:10px;text-decoration:none;font-weight:600;">
Website
</a>

<a href="https://www.pangeanic.com/contact-us/"
target="_blank"
style="background:white;color:#F58220;padding:14px 24px;border-radius:10px;text-decoration:none;font-weight:600;">
Contact Us
</a>

</div>

</div>

</div>
""")

demo.launch(theme=theme, css="style.css")