Menu

From Heuristics to Fine-Tuning: Teaching a Model to Use Tools
πŸ“°

From Heuristics to Fine-Tuning: Teaching a Model to Use Tools

DEV CommunityΒ·Ayush ShekharΒ·7 months ago
#aZLyhCdW
#ai#machinelearning#tool#model#regex
Long article (1354 words) β€” no AI summary yet.
Reading 0:00
15s threshold

How I replaced 200 lines of regex with a fine-tuned 7B model β€” and why it was worth it.

The Problem

I built an autonomous AI agent with 9 tools: web search, calculator, weather, Wikipedia, translation, and more. The first question every request must answer is deceptively simple:

Which tool should I use?

My first solution was a heuristic classifier β€” a function called classify_query() that uses regex patterns to detect intent:

# 200+ lines of patterns like this: _SEARCH_INDICATORS = re . compile ( r " \b(latest|current|news|today|recent|who won|score|price| " r " stock|update|happening|trending|release|launched)\b " , re . IGNORECASE )

_KNOWLEDGE_INDICATORS = re . compile ( r " \b(explain|what is|how does|define|difference between| " r " why do|concept of|overview|meaning of|works)\b " , re . IGNORECASE )

Enter fullscreen mode

Exit fullscreen mode

It worked.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.