Skip to content

This repository contains a server for generating distinct paraphrases using round-trip multilingual neural machine translation.

Notifications You must be signed in to change notification settings

mzilinec/paraphrase-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Paraphrasing server

This repository contains a server for generating distinct paraphrases using round-trip multilingual neural machine translation.

Installation

virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt

Running from the command line

  • Start tensorflow serving tensorflow_model_server --port=9000 --model_name=transformer --model_base_path=$PWD/export
  • Start REST paraphrasing server
cd paraf-app
export DATA_DIR="path to vocab file from your trained model"
export LANGUAGES="space delimited languages from vocab, in original order"
export FLASK_APP="main.py"
flask run

Running as a service

  • Set the model directory and CUDA path in systemd/tfserving.service
  • Set the environment variables and port in systemd/uwsgi-paraf.service
  • Copy the systemd files
cp systemd/tfserving.service /etc/systemd/system/tfserving.service && \
cp systemd/uwsgi-paraf.service /etc/systemd/system/uwsgi-paraf.service && \
cp systemd/uwsgi-paraf.socket /etc/systemd/system/uwsgi-paraf.socket
  • Enable the services
systemctl daemon-reload && \
systemctl enable tfserving.service && \
systemctl enable uwsgi-paraf.service && \
systemctl enable uwsgi-paraf.socket

Usage

The server supports GET and POST with two parameters, text and lang.
The request

curl -H 'Content-Type: application/json' \
     -XPOST -d \
     '{"text": "Hi, how are you doing today?", "lang": "en"}' \
     localhost:5000/translate

will produce paraphrases from round-trip translation for each supported language:

{
    "de":"Hello, how's it today?",
    "en":"Hi, how are you doing today?",
    "es":"Hello, how are you today?",
    "hu":"Hey, how are you today?",
    "lt":"Hello, how are you today?",
    "ru":"Hey, how are you doing today?"
}

Disclaimer

This server was created at the Institute of Formal and Applied Linguistics, Charles University.

About

This repository contains a server for generating distinct paraphrases using round-trip multilingual neural machine translation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages