Skip to content

Switch NLU model from Sonnet to Haiku for cost efficiency#16

Merged
ArturoGomezGz merged 1 commit into
masterfrom
feat/switch-nlu-model-haiku
Jun 10, 2026
Merged

Switch NLU model from Sonnet to Haiku for cost efficiency#16
ArturoGomezGz merged 1 commit into
masterfrom
feat/switch-nlu-model-haiku

Conversation

@ArturoGomezGz

Copy link
Copy Markdown
Collaborator

What changes

Replaces the Claude model used for NLU command classification in NaturalLanguageRouter.java from claude-sonnet-4-6 to claude-haiku-4-5.

File changed: MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/telegram/nlu/NaturalLanguageRouter.java

Why

Command classification is a lightweight, structured task: the input is a short user message and the output is a fixed JSON schema with a known set of commands. It does not require the reasoning depth of Sonnet.

Switching to Haiku reduces cost by ~3x:

  • claude-sonnet-4-6: ~$0.00185/msg
  • claude-haiku-4-5: ~$0.00062/msg

For a bot handling hundreds of messages per day, this translates to significant monthly savings with no expected quality degradation on this task.

Test plan

  • Send a natural-language message to the Telegram bot (e.g. "muestrame la tarea 18") and verify it routes to the correct command (task, id=18).
  • Test edge cases: missing params (e.g. "actualiza el estado de la tarea" without an id) — bot should ask for the missing param.
  • Test an unrecognised message — bot should fall back to unknown gracefully.
  • Check application logs to confirm requests are hitting claude-haiku-4-5 and not returning errors.
  • Confirm no regression in existing Telegram bot command flows (start, help, my_projects, my_tasks, task_status, comment).

Generated with Claude Code

Command classification is a lightweight task (short input, structured JSON
output) that does not require the full reasoning power of Sonnet. Haiku
handles it correctly at ~3× lower cost per message.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ArturoGomezGz ArturoGomezGz merged commit f7e6912 into master Jun 10, 2026
3 checks passed
@ArturoGomezGz ArturoGomezGz deleted the feat/switch-nlu-model-haiku branch June 10, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant