transcoder-llm 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- transcoder_llm-1.0.0/LICENSE +21 -0
- transcoder_llm-1.0.0/MANIFEST.in +25 -0
- transcoder_llm-1.0.0/PKG-INFO +324 -0
- transcoder_llm-1.0.0/README.md +242 -0
- transcoder_llm-1.0.0/README_CN.md +242 -0
- transcoder_llm-1.0.0/env.example +14 -0
- transcoder_llm-1.0.0/pyproject.toml +145 -0
- transcoder_llm-1.0.0/requirements-minimal.txt +37 -0
- transcoder_llm-1.0.0/requirements.txt +15 -0
- transcoder_llm-1.0.0/setup.cfg +4 -0
- transcoder_llm-1.0.0/static/css/style.css +343 -0
- transcoder_llm-1.0.0/static/js/app.js +1920 -0
- transcoder_llm-1.0.0/static/js/terminology.js +567 -0
- transcoder_llm-1.0.0/static/js/vector_db.js +430 -0
- transcoder_llm-1.0.0/templates/index.html +341 -0
- transcoder_llm-1.0.0/templates/terminology.html +254 -0
- transcoder_llm-1.0.0/templates/vector_db.html +261 -0
- transcoder_llm-1.0.0/tests/test_api.py +108 -0
- transcoder_llm-1.0.0/transcoder/__init__.py +24 -0
- transcoder_llm-1.0.0/transcoder/__main__.py +9 -0
- transcoder_llm-1.0.0/transcoder/api.py +332 -0
- transcoder_llm-1.0.0/transcoder/app.py +231 -0
- transcoder_llm-1.0.0/transcoder/cli.py +182 -0
- transcoder_llm-1.0.0/transcoder/core.py +639 -0
- transcoder_llm-1.0.0/transcoder_llm.egg-info/PKG-INFO +324 -0
- transcoder_llm-1.0.0/transcoder_llm.egg-info/SOURCES.txt +30 -0
- transcoder_llm-1.0.0/transcoder_llm.egg-info/dependency_links.txt +1 -0
- transcoder_llm-1.0.0/transcoder_llm.egg-info/entry_points.txt +5 -0
- transcoder_llm-1.0.0/transcoder_llm.egg-info/requires.txt +55 -0
- transcoder_llm-1.0.0/transcoder_llm.egg-info/top_level.txt +1 -0
- transcoder_llm-1.0.0/upload_pypi.bat +54 -0
- transcoder_llm-1.0.0/upload_pypi.sh +51 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 EasyCam
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
include LICENSE
|
|
2
|
+
include README.md
|
|
3
|
+
include README_CN.md
|
|
4
|
+
include pyproject.toml
|
|
5
|
+
include requirements.txt
|
|
6
|
+
include requirements-minimal.txt
|
|
7
|
+
include env.example
|
|
8
|
+
include upload_pypi.sh
|
|
9
|
+
include upload_pypi.bat
|
|
10
|
+
include AGENTS.md
|
|
11
|
+
|
|
12
|
+
recursive-include templates *.html *.css *.js
|
|
13
|
+
recursive-include static *.css *.js *.png *.jpg *.ico
|
|
14
|
+
recursive-include transcoder *.html *.css *.js
|
|
15
|
+
|
|
16
|
+
recursive-include data *.json *.csv *.xlsx *.tmx *.tbx
|
|
17
|
+
recursive-exclude data __pycache__
|
|
18
|
+
recursive-exclude tests __pycache__
|
|
19
|
+
recursive-exclude transcoder __pycache__
|
|
20
|
+
|
|
21
|
+
global-exclude __pycache__
|
|
22
|
+
global-exclude *.py[cod]
|
|
23
|
+
global-exclude *.so
|
|
24
|
+
global-exclude .DS_Store
|
|
25
|
+
global-exclude .git*
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: transcoder-llm
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Multilingual Parallel Translation Platform with Reflection-based Improvement using Local LLMs
|
|
5
|
+
Author-email: TransCoder Team <transcoder@example.com>
|
|
6
|
+
Maintainer-email: TransCoder Team <transcoder@example.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/EasyCam/TransCoder
|
|
9
|
+
Project-URL: Documentation, https://github.com/EasyCam/TransCoder#readme
|
|
10
|
+
Project-URL: Repository, https://github.com/EasyCam/TransCoder.git
|
|
11
|
+
Project-URL: Issues, https://github.com/EasyCam/TransCoder/issues
|
|
12
|
+
Project-URL: Changelog, https://github.com/EasyCam/TransCoder/blob/main/CHANGELOG.md
|
|
13
|
+
Keywords: translation,llm,ollama,multilingual,reflection,ai,machine-translation,nlp,local-llm
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Environment :: Web Environment
|
|
16
|
+
Classifier: Framework :: Flask
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: Intended Audience :: Science/Research
|
|
19
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
20
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
21
|
+
Classifier: Operating System :: OS Independent
|
|
22
|
+
Classifier: Programming Language :: Python :: 3
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
28
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
29
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
30
|
+
Requires-Python: >=3.8
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
Requires-Dist: flask>=2.0.0
|
|
34
|
+
Requires-Dist: flask-cors>=3.0.0
|
|
35
|
+
Requires-Dist: ollama>=0.1.0
|
|
36
|
+
Requires-Dist: langdetect>=1.0.0
|
|
37
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
38
|
+
Requires-Dist: waitress>=2.1.0
|
|
39
|
+
Provides-Extra: web
|
|
40
|
+
Requires-Dist: flask>=2.0.0; extra == "web"
|
|
41
|
+
Requires-Dist: flask-cors>=3.0.0; extra == "web"
|
|
42
|
+
Requires-Dist: waitress>=2.1.0; extra == "web"
|
|
43
|
+
Provides-Extra: vector-db
|
|
44
|
+
Requires-Dist: numpy>=1.20.0; extra == "vector-db"
|
|
45
|
+
Requires-Dist: faiss-cpu>=1.7.0; extra == "vector-db"
|
|
46
|
+
Requires-Dist: sentence-transformers>=2.0.0; extra == "vector-db"
|
|
47
|
+
Provides-Extra: evaluation
|
|
48
|
+
Requires-Dist: sacrebleu>=2.0.0; extra == "evaluation"
|
|
49
|
+
Requires-Dist: bert-score>=0.3.0; extra == "evaluation"
|
|
50
|
+
Requires-Dist: rouge-score>=0.1.0; extra == "evaluation"
|
|
51
|
+
Requires-Dist: nltk>=3.8.0; extra == "evaluation"
|
|
52
|
+
Provides-Extra: terminology
|
|
53
|
+
Requires-Dist: pandas>=1.3.0; extra == "terminology"
|
|
54
|
+
Requires-Dist: openpyxl>=3.0.0; extra == "terminology"
|
|
55
|
+
Provides-Extra: gui
|
|
56
|
+
Requires-Dist: PySide6>=6.4.0; extra == "gui"
|
|
57
|
+
Provides-Extra: all
|
|
58
|
+
Requires-Dist: flask>=2.0.0; extra == "all"
|
|
59
|
+
Requires-Dist: flask-cors>=3.0.0; extra == "all"
|
|
60
|
+
Requires-Dist: ollama>=0.1.0; extra == "all"
|
|
61
|
+
Requires-Dist: langdetect>=1.0.0; extra == "all"
|
|
62
|
+
Requires-Dist: python-dotenv>=1.0.0; extra == "all"
|
|
63
|
+
Requires-Dist: waitress>=2.1.0; extra == "all"
|
|
64
|
+
Requires-Dist: numpy>=1.20.0; extra == "all"
|
|
65
|
+
Requires-Dist: faiss-cpu>=1.7.0; extra == "all"
|
|
66
|
+
Requires-Dist: sentence-transformers>=2.0.0; extra == "all"
|
|
67
|
+
Requires-Dist: sacrebleu>=2.0.0; extra == "all"
|
|
68
|
+
Requires-Dist: bert-score>=0.3.0; extra == "all"
|
|
69
|
+
Requires-Dist: rouge-score>=0.1.0; extra == "all"
|
|
70
|
+
Requires-Dist: nltk>=3.8.0; extra == "all"
|
|
71
|
+
Requires-Dist: pandas>=1.3.0; extra == "all"
|
|
72
|
+
Requires-Dist: openpyxl>=3.0.0; extra == "all"
|
|
73
|
+
Requires-Dist: PySide6>=6.4.0; extra == "all"
|
|
74
|
+
Provides-Extra: dev
|
|
75
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
76
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
77
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
78
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
79
|
+
Requires-Dist: build>=0.10.0; extra == "dev"
|
|
80
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
81
|
+
Dynamic: license-file
|
|
82
|
+
|
|
83
|
+
# TransCoder
|
|
84
|
+
|
|
85
|
+
[](https://badge.fury.io/py/transcoder-llm)
|
|
86
|
+
[](https://www.python.org/downloads/)
|
|
87
|
+
[](https://opensource.org/licenses/MIT)
|
|
88
|
+
|
|
89
|
+
**Multilingual Parallel Translation Platform with Reflection-based Improvement using Local LLMs**
|
|
90
|
+
|
|
91
|
+
TransCoder is a powerful translation platform that leverages local Large Language Models (LLMs) through Ollama, featuring innovative **Reflection-based Translation** methods that significantly improve translation quality through AI self-evaluation and iterative refinement.
|
|
92
|
+
|
|
93
|
+
## Key Features
|
|
94
|
+
|
|
95
|
+
### 🌟 Core Innovations
|
|
96
|
+
|
|
97
|
+
- **三省吾身模式 (Three Reflections Mode)**: Translation → AI Reflection → Improvement cycle
|
|
98
|
+
- **千锤百炼模式 (Iterative Refinement Mode)**: Configurable 1-10 iteration optimization for maximum quality
|
|
99
|
+
|
|
100
|
+
### 🚀 Main Features
|
|
101
|
+
|
|
102
|
+
- **Multilingual Parallel Translation**: Translate to multiple languages simultaneously
|
|
103
|
+
- **14 Language Variants**: Including Chinese variants (Simplified, Traditional, Classical)
|
|
104
|
+
- **Local LLM Support**: Works with Ollama (Qwen, Llama, Mistral, etc.)
|
|
105
|
+
- **Translation Memory**: FAISS-based vector database for consistency
|
|
106
|
+
- **Terminology Management**: Professional term consistency across translations
|
|
107
|
+
- **Quality Evaluation**: BLEU, BERTScore, ROUGE metrics
|
|
108
|
+
|
|
109
|
+
## Installation
|
|
110
|
+
|
|
111
|
+
### From PyPI (Recommended)
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
pip install transcoder-llm
|
|
115
|
+
|
|
116
|
+
# With all features
|
|
117
|
+
pip install transcoder-llm[all]
|
|
118
|
+
|
|
119
|
+
# With specific features
|
|
120
|
+
pip install transcoder-llm[web] # Web interface
|
|
121
|
+
pip install transcoder-llm[vector-db] # Translation memory
|
|
122
|
+
pip install transcoder-llm[evaluation] # Quality metrics
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### From Source
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
git clone https://github.com/EasyCam/TransCoder.git
|
|
129
|
+
cd TransCoder
|
|
130
|
+
pip install -e .
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Quick Start
|
|
134
|
+
|
|
135
|
+
### 1. Install and Start Ollama
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Install Ollama (macOS/Linux)
|
|
139
|
+
curl -fsSL https://ollama.ai/install.sh | sh
|
|
140
|
+
|
|
141
|
+
# Download a model
|
|
142
|
+
ollama pull qwen3:0.6b
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### 2. Start TransCoder
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Web interface
|
|
149
|
+
transcoder web
|
|
150
|
+
|
|
151
|
+
# Or with production server
|
|
152
|
+
transcoder web --production
|
|
153
|
+
|
|
154
|
+
# CLI translation
|
|
155
|
+
transcoder cli -i input.txt -t en,ja,ko -o output.txt
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### 3. Python API
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from transcoder import TransCoderAPI
|
|
162
|
+
|
|
163
|
+
api = TransCoderAPI(model="qwen3:0.6b")
|
|
164
|
+
|
|
165
|
+
# Simple translation
|
|
166
|
+
result = api.translate("Hello world", "en", ["zh-cn", "ja"])
|
|
167
|
+
print(result.data["translations"])
|
|
168
|
+
|
|
169
|
+
# Reflection mode (三省吾身)
|
|
170
|
+
result = api.translate_with_reflection(
|
|
171
|
+
"Hello world", "en", "zh-cn"
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
# Iterative refinement (千锤百炼)
|
|
175
|
+
result = api.translate_iterative(
|
|
176
|
+
"Hello world", "en", "zh-cn", iterations=3
|
|
177
|
+
)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Translation Modes
|
|
181
|
+
|
|
182
|
+
### Simple Mode
|
|
183
|
+
Fast one-pass translation for everyday use.
|
|
184
|
+
|
|
185
|
+
### Reflection Mode (三省吾身)
|
|
186
|
+
```
|
|
187
|
+
Initial Translation → AI Reflection Analysis → Improved Translation
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
The AI analyzes translation quality from four dimensions:
|
|
191
|
+
- **Accuracy**: Is the meaning fully preserved?
|
|
192
|
+
- **Fluency**: Is the expression natural?
|
|
193
|
+
- **Style**: Is the tone appropriate?
|
|
194
|
+
- **Terminology**: Are terms translated correctly?
|
|
195
|
+
|
|
196
|
+
### Iterative Refinement (千锤百炼)
|
|
197
|
+
```
|
|
198
|
+
Initial → Reflect → Improve → Reflect → Improve → ... → Final
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Configure 1-10 iterations to balance quality vs. speed.
|
|
202
|
+
|
|
203
|
+
## API Reference
|
|
204
|
+
|
|
205
|
+
### REST API
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# Translation
|
|
209
|
+
POST /api/translate
|
|
210
|
+
{
|
|
211
|
+
"source_text": "Hello world",
|
|
212
|
+
"source_lang": "en",
|
|
213
|
+
"target_langs": ["zh-cn", "ja"]
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
# Reflection
|
|
217
|
+
POST /api/translate/reflect
|
|
218
|
+
{
|
|
219
|
+
"source_text": "Hello world",
|
|
220
|
+
"translation": "你好世界",
|
|
221
|
+
"source_lang": "en",
|
|
222
|
+
"target_lang": "zh-cn"
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
# Improvement
|
|
226
|
+
POST /api/translate/improve
|
|
227
|
+
{
|
|
228
|
+
"source_text": "Hello world",
|
|
229
|
+
"current_translation": "你好世界",
|
|
230
|
+
"reflection": "...",
|
|
231
|
+
"source_lang": "en",
|
|
232
|
+
"target_lang": "zh-cn"
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Python API
|
|
237
|
+
|
|
238
|
+
```python
|
|
239
|
+
from transcoder import TransCoderAPI
|
|
240
|
+
|
|
241
|
+
api = TransCoderAPI()
|
|
242
|
+
|
|
243
|
+
# Translate
|
|
244
|
+
result = api.translate(text, source_lang, target_langs)
|
|
245
|
+
|
|
246
|
+
# With reflection
|
|
247
|
+
result = api.translate_with_reflection(text, source_lang, target_lang)
|
|
248
|
+
|
|
249
|
+
# Iterative
|
|
250
|
+
result = api.translate_iterative(text, source_lang, target_lang, iterations=3)
|
|
251
|
+
|
|
252
|
+
# Evaluate quality
|
|
253
|
+
result = api.evaluate_translation(source, translated, reference)
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Supported Languages
|
|
257
|
+
|
|
258
|
+
| Code | Language |
|
|
259
|
+
|------|----------|
|
|
260
|
+
| zh-cn | Chinese (Simplified) |
|
|
261
|
+
| zh-tw | Chinese (Traditional) |
|
|
262
|
+
| zh-classical-cn | Classical Chinese (Simplified) |
|
|
263
|
+
| zh-classical-tw | Classical Chinese (Traditional) |
|
|
264
|
+
| en | English |
|
|
265
|
+
| ja | Japanese |
|
|
266
|
+
| ko | Korean |
|
|
267
|
+
| es | Spanish |
|
|
268
|
+
| fr | French |
|
|
269
|
+
| de | German |
|
|
270
|
+
| ru | Russian |
|
|
271
|
+
| ar | Arabic |
|
|
272
|
+
| pt | Portuguese |
|
|
273
|
+
|
|
274
|
+
## Project Structure
|
|
275
|
+
|
|
276
|
+
```
|
|
277
|
+
transcoder/
|
|
278
|
+
├── __init__.py # Package exports
|
|
279
|
+
├── cli.py # Command-line interface
|
|
280
|
+
├── api.py # Unified Python API
|
|
281
|
+
├── core.py # Core services
|
|
282
|
+
├── app.py # Flask web application
|
|
283
|
+
└── templates/ # HTML templates
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Development
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
# Install dev dependencies
|
|
290
|
+
pip install -e ".[dev]"
|
|
291
|
+
|
|
292
|
+
# Run tests
|
|
293
|
+
pytest tests/
|
|
294
|
+
|
|
295
|
+
# Run linter
|
|
296
|
+
ruff check transcoder/
|
|
297
|
+
|
|
298
|
+
# Build package
|
|
299
|
+
python -m build
|
|
300
|
+
|
|
301
|
+
# Upload to PyPI
|
|
302
|
+
./upload_pypi.sh
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## License
|
|
306
|
+
|
|
307
|
+
MIT License - See [LICENSE](LICENSE) for details.
|
|
308
|
+
|
|
309
|
+
## Citation
|
|
310
|
+
|
|
311
|
+
If you use TransCoder in your research, please cite:
|
|
312
|
+
|
|
313
|
+
```bibtex
|
|
314
|
+
@software{transcoder2024,
|
|
315
|
+
title = {TransCoder: Multilingual Parallel Translation Platform with Reflection-based Improvement},
|
|
316
|
+
author = {TransCoder Team},
|
|
317
|
+
year = {2024},
|
|
318
|
+
url = {https://github.com/EasyCam/TransCoder}
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## Contributing
|
|
323
|
+
|
|
324
|
+
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# TransCoder
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/transcoder-llm)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
**Multilingual Parallel Translation Platform with Reflection-based Improvement using Local LLMs**
|
|
8
|
+
|
|
9
|
+
TransCoder is a powerful translation platform that leverages local Large Language Models (LLMs) through Ollama, featuring innovative **Reflection-based Translation** methods that significantly improve translation quality through AI self-evaluation and iterative refinement.
|
|
10
|
+
|
|
11
|
+
## Key Features
|
|
12
|
+
|
|
13
|
+
### 🌟 Core Innovations
|
|
14
|
+
|
|
15
|
+
- **三省吾身模式 (Three Reflections Mode)**: Translation → AI Reflection → Improvement cycle
|
|
16
|
+
- **千锤百炼模式 (Iterative Refinement Mode)**: Configurable 1-10 iteration optimization for maximum quality
|
|
17
|
+
|
|
18
|
+
### 🚀 Main Features
|
|
19
|
+
|
|
20
|
+
- **Multilingual Parallel Translation**: Translate to multiple languages simultaneously
|
|
21
|
+
- **14 Language Variants**: Including Chinese variants (Simplified, Traditional, Classical)
|
|
22
|
+
- **Local LLM Support**: Works with Ollama (Qwen, Llama, Mistral, etc.)
|
|
23
|
+
- **Translation Memory**: FAISS-based vector database for consistency
|
|
24
|
+
- **Terminology Management**: Professional term consistency across translations
|
|
25
|
+
- **Quality Evaluation**: BLEU, BERTScore, ROUGE metrics
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
### From PyPI (Recommended)
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install transcoder-llm
|
|
33
|
+
|
|
34
|
+
# With all features
|
|
35
|
+
pip install transcoder-llm[all]
|
|
36
|
+
|
|
37
|
+
# With specific features
|
|
38
|
+
pip install transcoder-llm[web] # Web interface
|
|
39
|
+
pip install transcoder-llm[vector-db] # Translation memory
|
|
40
|
+
pip install transcoder-llm[evaluation] # Quality metrics
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### From Source
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
git clone https://github.com/EasyCam/TransCoder.git
|
|
47
|
+
cd TransCoder
|
|
48
|
+
pip install -e .
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Quick Start
|
|
52
|
+
|
|
53
|
+
### 1. Install and Start Ollama
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Install Ollama (macOS/Linux)
|
|
57
|
+
curl -fsSL https://ollama.ai/install.sh | sh
|
|
58
|
+
|
|
59
|
+
# Download a model
|
|
60
|
+
ollama pull qwen3:0.6b
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 2. Start TransCoder
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Web interface
|
|
67
|
+
transcoder web
|
|
68
|
+
|
|
69
|
+
# Or with production server
|
|
70
|
+
transcoder web --production
|
|
71
|
+
|
|
72
|
+
# CLI translation
|
|
73
|
+
transcoder cli -i input.txt -t en,ja,ko -o output.txt
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 3. Python API
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from transcoder import TransCoderAPI
|
|
80
|
+
|
|
81
|
+
api = TransCoderAPI(model="qwen3:0.6b")
|
|
82
|
+
|
|
83
|
+
# Simple translation
|
|
84
|
+
result = api.translate("Hello world", "en", ["zh-cn", "ja"])
|
|
85
|
+
print(result.data["translations"])
|
|
86
|
+
|
|
87
|
+
# Reflection mode (三省吾身)
|
|
88
|
+
result = api.translate_with_reflection(
|
|
89
|
+
"Hello world", "en", "zh-cn"
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
# Iterative refinement (千锤百炼)
|
|
93
|
+
result = api.translate_iterative(
|
|
94
|
+
"Hello world", "en", "zh-cn", iterations=3
|
|
95
|
+
)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Translation Modes
|
|
99
|
+
|
|
100
|
+
### Simple Mode
|
|
101
|
+
Fast one-pass translation for everyday use.
|
|
102
|
+
|
|
103
|
+
### Reflection Mode (三省吾身)
|
|
104
|
+
```
|
|
105
|
+
Initial Translation → AI Reflection Analysis → Improved Translation
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The AI analyzes translation quality from four dimensions:
|
|
109
|
+
- **Accuracy**: Is the meaning fully preserved?
|
|
110
|
+
- **Fluency**: Is the expression natural?
|
|
111
|
+
- **Style**: Is the tone appropriate?
|
|
112
|
+
- **Terminology**: Are terms translated correctly?
|
|
113
|
+
|
|
114
|
+
### Iterative Refinement (千锤百炼)
|
|
115
|
+
```
|
|
116
|
+
Initial → Reflect → Improve → Reflect → Improve → ... → Final
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Configure 1-10 iterations to balance quality vs. speed.
|
|
120
|
+
|
|
121
|
+
## API Reference
|
|
122
|
+
|
|
123
|
+
### REST API
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Translation
|
|
127
|
+
POST /api/translate
|
|
128
|
+
{
|
|
129
|
+
"source_text": "Hello world",
|
|
130
|
+
"source_lang": "en",
|
|
131
|
+
"target_langs": ["zh-cn", "ja"]
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
# Reflection
|
|
135
|
+
POST /api/translate/reflect
|
|
136
|
+
{
|
|
137
|
+
"source_text": "Hello world",
|
|
138
|
+
"translation": "你好世界",
|
|
139
|
+
"source_lang": "en",
|
|
140
|
+
"target_lang": "zh-cn"
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
# Improvement
|
|
144
|
+
POST /api/translate/improve
|
|
145
|
+
{
|
|
146
|
+
"source_text": "Hello world",
|
|
147
|
+
"current_translation": "你好世界",
|
|
148
|
+
"reflection": "...",
|
|
149
|
+
"source_lang": "en",
|
|
150
|
+
"target_lang": "zh-cn"
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Python API
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
from transcoder import TransCoderAPI
|
|
158
|
+
|
|
159
|
+
api = TransCoderAPI()
|
|
160
|
+
|
|
161
|
+
# Translate
|
|
162
|
+
result = api.translate(text, source_lang, target_langs)
|
|
163
|
+
|
|
164
|
+
# With reflection
|
|
165
|
+
result = api.translate_with_reflection(text, source_lang, target_lang)
|
|
166
|
+
|
|
167
|
+
# Iterative
|
|
168
|
+
result = api.translate_iterative(text, source_lang, target_lang, iterations=3)
|
|
169
|
+
|
|
170
|
+
# Evaluate quality
|
|
171
|
+
result = api.evaluate_translation(source, translated, reference)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Supported Languages
|
|
175
|
+
|
|
176
|
+
| Code | Language |
|
|
177
|
+
|------|----------|
|
|
178
|
+
| zh-cn | Chinese (Simplified) |
|
|
179
|
+
| zh-tw | Chinese (Traditional) |
|
|
180
|
+
| zh-classical-cn | Classical Chinese (Simplified) |
|
|
181
|
+
| zh-classical-tw | Classical Chinese (Traditional) |
|
|
182
|
+
| en | English |
|
|
183
|
+
| ja | Japanese |
|
|
184
|
+
| ko | Korean |
|
|
185
|
+
| es | Spanish |
|
|
186
|
+
| fr | French |
|
|
187
|
+
| de | German |
|
|
188
|
+
| ru | Russian |
|
|
189
|
+
| ar | Arabic |
|
|
190
|
+
| pt | Portuguese |
|
|
191
|
+
|
|
192
|
+
## Project Structure
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
transcoder/
|
|
196
|
+
├── __init__.py # Package exports
|
|
197
|
+
├── cli.py # Command-line interface
|
|
198
|
+
├── api.py # Unified Python API
|
|
199
|
+
├── core.py # Core services
|
|
200
|
+
├── app.py # Flask web application
|
|
201
|
+
└── templates/ # HTML templates
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Development
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
# Install dev dependencies
|
|
208
|
+
pip install -e ".[dev]"
|
|
209
|
+
|
|
210
|
+
# Run tests
|
|
211
|
+
pytest tests/
|
|
212
|
+
|
|
213
|
+
# Run linter
|
|
214
|
+
ruff check transcoder/
|
|
215
|
+
|
|
216
|
+
# Build package
|
|
217
|
+
python -m build
|
|
218
|
+
|
|
219
|
+
# Upload to PyPI
|
|
220
|
+
./upload_pypi.sh
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
MIT License - See [LICENSE](LICENSE) for details.
|
|
226
|
+
|
|
227
|
+
## Citation
|
|
228
|
+
|
|
229
|
+
If you use TransCoder in your research, please cite:
|
|
230
|
+
|
|
231
|
+
```bibtex
|
|
232
|
+
@software{transcoder2024,
|
|
233
|
+
title = {TransCoder: Multilingual Parallel Translation Platform with Reflection-based Improvement},
|
|
234
|
+
author = {TransCoder Team},
|
|
235
|
+
year = {2024},
|
|
236
|
+
url = {https://github.com/EasyCam/TransCoder}
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Contributing
|
|
241
|
+
|
|
242
|
+
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
|