@protectqa/tcl-nli-service
v0.1.0
Published
TCL NLI scoring HTTP service (Mistral-backed).
Readme
TCL NLI Service (Mistral 7B)
A simple NLI (Natural Language Inference) service using Mistral 7B for TCL framework.
Setup
Get Mistral API Key:
- Sign up at https://mistral.ai
- Get your API key from the dashboard
Install dependencies:
npm installSet environment variables:
export MISTRAL_API_KEY="your-api-key" export MISTRAL_MODEL="mistral-small-latest" # or mistral-tiny, mistral-medium export PORT=8081Run:
npm start
Deploy to Railway
- Create new Railway service
- Set Root Directory:
packages/tcl-nli-service - Set environment variables:
MISTRAL_API_KEY= your Mistral API keyMISTRAL_MODEL=mistral-small-latest(optional)PORT= Railway will auto-assign
- Get the Railway URL and set in TCL Core:
TCL_NLI_ENDPOINT=https://your-nli-service.up.railway.app
API Contract
POST /score
Request:
{
"pairs": [
{
"task": "contradiction",
"a": "text A",
"b": "text B",
"key": "unique-key"
}
]
}Response:
{
"scores": [
{
"key": "unique-key",
"score": 0.85
}
]
}Cost Considerations
Mistral 7B pricing (approximate):
- mistral-tiny: ~$0.14 per 1M input tokens
- mistral-small: ~$0.60 per 1M input tokens
- mistral-medium: ~$2.70 per 1M input tokens
For NLI tasks, mistral-tiny or mistral-small should be sufficient and cost-effective.
Comparison
| Model | Speed | Cost | Accuracy | Best For | |-------|-------|------|----------|----------| | Mistral 7B | Slower | Higher | Good | Complex reasoning | | Dedicated NLI | Fast | Lower | Excellent | Production NLI |
Recommendation
For production, consider:
- Short term: Use Mistral 7B (this service)
- Long term: Use dedicated NLI models (Hugging Face, Cohere, etc.) for better cost/performance
