12

Github GitHub - SpecializedGeneralist/translator: A simple self-hostable Machine...

 3 years ago
source link: https://github.com/SpecializedGeneralist/translator
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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 mod download
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)

// ...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK