File size: 2,035 Bytes
2f99848
 
 
 
 
 
 
 
 
 
 
 
 
0b5a142
 
 
 
 
 
 
 
071d750
0b5a142
 
 
071d750
0004aa5
2908950
0004aa5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d540b7d
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
---
language:
- en
- de
pipeline_tag: text-generation
library_name: transformers
tags:
- machine-translation
- error-detection
- error-correction
- lora
- qwen3
---
# MT Error Detection and Correction Models

This repository contains models for machine translation error detection and error correction.

## Repository Structure

```text
error_detection/
β”œβ”€β”€ model/   # Model for translation error detection
└── lora/    # GRPO LoRA adapter for error detection

error_correction/
β”œβ”€β”€ model/   # Model for translation error correction
└── lora/    # GRPO LoRA adapter for error correction
```
## Usage

The repository contains two components:

- `error_detection`: machine translation error detection
- `error_correction`: machine translation error correction

### Installation

```bash
pip install transformers huggingface_hub vllm
```

### Load a Model

First download the repository:

```python
import os
from huggingface_hub import snapshot_download
from transformers import AutoTokenizer
from vllm import LLM
from vllm.lora.request import LoRARequest

repo_dir = snapshot_download(
    repo_id="otelk/mt-error-detect-correct"
)
```

For error detection:

```python
model_dir = os.path.join(repo_dir, "error_detection", "model")
adapter_dir = os.path.join(repo_dir, "error_detection", "lora")
```

For error correction:

```python
model_dir = os.path.join(repo_dir, "error_correction", "model")
adapter_dir = os.path.join(repo_dir, "error_correction", "lora")
```

```python
tokenizer = AutoTokenizer.from_pretrained(
    model_dir,
    trust_remote_code=True
)

llm = LLM(
    model=model_dir,
    tokenizer=model_dir,
    dtype="bfloat16",
    enable_lora=True,
    max_lora_rank=16,
    trust_remote_code=True
)

lora_request = LoRARequest(
    "mt_lora",
    1,
    adapter_dir
)
```

The model can then be used with vLLM by passing the corresponding `lora_request` during generation.

```python
outputs = llm.generate(
    prompts,
    sampling_params=sampling_params,
    lora_request=lora_request
)
```