420adfc58447c72085380105a30efbc0351b5b4e
FastText Language ID Server
HTTP server that provides language identification using FastText models.
Quick Start
# Pull and run
docker run -p 8080:8080 mariozechner/fasttext-lid-server
# Test
curl "http://localhost:8080/detect?text=Hello%20world"
API
GET /detect
- Parameter:
text(required) - Response: JSON with language code and probability
{
"language": "en",
"probability": 0.987
}
- Errors:
- 400: Missing text parameter
- 500: Prediction failed
Docker
Using docker run
# Default settings
docker run -p 8080:8080 mariozechner/fasttext-lid-server
# Custom settings
docker run -p 9000:9000 \
-e PORT=9000 \
-e MODEL_FILE=/models/custom.ftz \
-v $(pwd)/models:/models \
mariozechner/fasttext-lid-server
Using docker compose
version: '3.8'
services:
lid-server:
image: mariozechner/fasttext-lid-server
ports:
- "${PORT:-8080}:${PORT:-8080}"
environment:
- MODEL_FILE=${MODEL_FILE:-lid.176.ftz}
- PORT=${PORT:-8080}
volumes:
- ./models:/models
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:${PORT:-8080}/detect?text=Hello%20world"]
interval: 5s
timeout: 5s
retries: 3
Run with:
# Default settings
docker compose up
# Custom port
PORT=9000 docker compose up
# Custom model
MODEL_FILE=/models/custom.ftz docker compose up
Building from Source
Prerequisites: CMake 3.14+, C++17 compiler
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
Run:
./fasttext_lid_server [model_path] [port]
Description
A simple server for fasttext based language identification
806 KiB
0 Stars
1 Watchers
0 Forks
Languages
C++
42.9%
CMake
22.5%
Shell
18.5%
Dockerfile
16.1%