EDEN / examples /use_locally.py
Rybib's picture
Upload EDEN model and code
2f65125 verified
Raw
History Blame Contribute Delete
1.09 kB
"""Use EDEN through the local training engine instead of Transformers.
This loads a checkpoint produced by the EDEN trainer (a .pt file) and runs the
same enhancement pipeline used during development. Set EDEN_HOME so the engine
can find the tokenizer under $EDEN_HOME/eden_system/data/tokenizer.json.
Run from the repository root:
EDEN_HOME=/path/to/workspace python examples/use_locally.py /path/to/best.pt
"""
import os
import sys
from pathlib import Path
# Make the repository root importable when running this script directly.
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from eden import enhance_text, load_model_for_inference
checkpoint = Path(sys.argv[1]) if len(sys.argv) > 1 else None
model, tokenizer, config, device = load_model_for_inference(checkpoint, force_cpu=True)
for rough in [
"i relly wnt this sentance to sound more profesional",
"their are alot of reasons why this dont work proper",
]:
print("rough :", rough)
print("polished:", enhance_text(rough, model, tokenizer, config, device))
print()