translator

module
v0.0.0-...-8eb1a3c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2021 License: Apache-2.0

README

Translator

A simple self-hostable translation service, powered by spaGO.

Some notable features:

  • it doesn't rely on external translation services
  • no fees, no strings attached
  • it's self-contained: just build and run with minimal dependencies
  • tiny executable, simple configuration
  • REST (OpenAPI) and gRPC API
  • it works with spaGO models
    • let the program automatically download and convert models from Hugging Face Hub (reference: spaGO Hugging Face Importer)
    • and/or just provide your own models

Supported models

This project uses spaGO machine-learning/NLP library behind the hood. At present, BART and Marian models for conditional generation are supported. For more information please refer to spaGO BART Machine Translation README section.

Build and Run

The primary intended usage is to run it as a standalone program. You can get the code and build it like this:

git clone https://github.com/SpecializedGeneralist/translator.git
cd translator
go build -o translator cmd/translator/main.go

The translator program requires a configuration file to run. Please refer to the file sample-configuration.yaml included with this project to see an example.

Once you are done with your configuration definition, run:

./translator -c your-config.yaml

The program will first load the configured models from the given path. If a model is not found, the program will automatically attempt to download it from Hugging Face models hub, convert it to a spaGO model, and load it as well.

Eventually, the server will start and will be ready to accept requests. The configured endpoint can be used indifferently for REST (OpenAPI-defined) requests, or as gRPC service.

The folder pkg/api from this project provides the OpenAPI definition file (api.yaml) and also protobuf and gRPC-related definitions and code.

Use as Go package

This project is a Go module, so you can get and use it from your own code:

go get -u github.com/SpecializedGeneralist/translator

For example, a typical scenario is to import and use the included gRPC client:

import "github.com/SpecializedGeneralist/translator/pkg/api"

// ...

client := api.NewApiClient(conn)

// ...

Directories

Path Synopsis
cmd
pkg
api
Package api is a reverse proxy.
Package api is a reverse proxy.
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL