Tamil News Classifier (Qwen2.5-7B)
A fine-tuned version of Qwen/Qwen2.5-7B-Instruct made to classify regional Tamil Nadu news stories into standardized topic categories across Tamil and English publications.
Model Details
- Base Model:
Qwen/Qwen2.5-7B-Instruct
- Fine-tuned using:
unsloth/Qwen2.5-7B-Instruct-bnb-4bit (4-bit quantized for training efficiency)
- Languages Supported: Tamil and English
Available Formats
| Format |
Use case |
| GGUF (Q4_K_M) |
Ollama / llama.cpp |
| LoRA adapter (safetensors) |
Python / Transformers + Unsloth |
Supported News Categories (Taxonomy)
The model is trained to classify news articles into the following domains and standardized labels:
1. State Politics & Governance
- Elections & Voting: Polls, candidates, voting, election campaigns, seat sharing, alliances, manifestos (தேர்தல் மற்றும் பிரச்சாரம்)
- Party Politics & Statements: Political leaders' statements, criticisms, party meetings, party appointments (கட்சி அரசியல் மற்றும் அறிக்கைகள்)
- Govt Schemes & Welfare: Welfare schemes, subsidies, pensions, scheme launches, beneficiaries (அரசு நலத்திட்டங்கள்)
- Govt Orders & Administration: Government orders (GOs), cabinet decisions, transfers, collectors, administrative decisions (அரசாணை மற்றும் நிர்வாகம்)
- Budget & Finance: State and union budget, fiscal deficit, revenue, government debt (பட்ஜெட் மற்றும் நிதி)
- Taxes & Revenue: GST, commercial taxes, property tax, tax policy, revenue collections (வரிகள் மற்றும் வருவாய்)
- Protests & Agitations: Public protests, strikes, union agitations, demands, rallies (போராட்டம் மற்றும் ஆர்ப்பாட்டம்)
- Labour Welfare: Wages, labour unions, employee rights, working conditions (தொழிலாளர் நலம்)
2. National & International
- National News: Union Government, Parliament, Prime Minister, central policies, interstate affairs (மத்திய அரசு மற்றும் தேசிய செய்திகள்)
- World Affairs: Foreign countries, global news, diaspora, international diplomacy (சர்வதேச மற்றும் உலக செய்திகள்)
3. Local Bodies & Civic Infrastructure
- Local Bodies & Civic: Municipal corporations, panchayats, ward works, civic complaints (உள்ளாட்சி மற்றும் நகராட்சி)
- Water Supply: Drinking water, water shortage, Metro Water, pipeline works (குடிநீர் விநியோகம்)
- Electricity & Power: Power cuts, TNEB, electricity tariff, transformers, power grid (மின்சாரம் மற்றும் மின்வாரியம்)
- Sanitation & Waste: Garbage clearance, solid waste, trash bins, cleanliness drives, sanitation workers (துப்புரவு மற்றும் கழிவு மேலாண்மை)
- Sewage & Drainage: Underground drainage, sewage overflow, storm water drains, sewage treatment (கழிவுநீர் மற்றும் வடிகால்)
- Roads & Highways: Road works, potholes, highways, bridges, flyovers, toll plazas (சாலைகள் மற்றும் பாலங்கள்)
- Public Buses: Government buses, MTC, SETC, TNSTC, bus fares, bus terminus, omnibus (பேருந்து போக்குவரத்து)
- Metro Rail: Chennai Metro, CMRL, metro trains, underground stations, Phase 2 (மெட்ரோ ரயில்)
- Railways: Trains, new railway tracks, railway stations, Vande Bharat, train timings (ரயில்வே செய்திகள்)
- Aviation & Airports: Airports, flights, airlines, air passenger services (விமானம் மற்றும் விமான நிலையம்)
4. Environment & Disasters
- Weather Forecasts: Rain predictions, weather department warnings, heat waves, temperatures (வானிலை எச்சரிக்கை)
- Floods & Waterlogging: Flood damage, overflowing rivers, rain waterlogging, flood relief (வெள்ளம் மற்றும் மழை பாதிப்பு)
- Natural Disasters: Cyclones, landslides, earthquakes, natural calamity rescue (இயற்கைப் பேரிடர்கள்)
- Environment & Pollution: Air pollution, water pollution, plastic ban, lakes, conservation (சுற்றுச்சூழல் மற்றும் மாசுபாடு)
- Wildlife & Animals: Wild elephants, leopards, animal attacks, wildlife sanctuaries (வனவிலங்குகள்)
- Forests: Forest department, reserved forests, tree planting, forest fires (காடுகள்)
5. Accidents & Safety
- Road Accidents: Vehicle collisions, road deaths, highway accidents, pedestrian accidents (சாலை விபத்துகள்)
- Fire Accidents: Fire breakouts, cylinder explosions, firecracker factory fires, commercial fires (தீ விபத்துகள்)
- Industrial Accidents: Factory boiler blasts, chemical leaks, workplace mishaps, quarry accidents (தொழிற்சாலை விபத்துகள்)
- General Accidents: Drowning, electrocution, wall collapses, falls, lightning strikes, stampedes (பொது விபத்துகள் மற்றும் அசம்பாவிதங்கள்)
6. Crime & Justice
- Violent Crime: Murder, assault, kidnapping, physical violence, gang clashes (கொலை மற்றும் வன்முறை)
- Sexual Offences: Sexual abuse, harassment, POCSO, molestation, eve-teasing (பாலியல் குற்றங்கள் மற்றும் துன்புறுத்தல்)
- Theft & Robbery: Theft, burglary, chain snatching, house break-ins (திருட்டு மற்றும் கொள்ளை)
- Cybercrime: Hacking, malware, ransomware, data breach, phishing, SIM swap, deepfakes, morphing (சைபர் குற்றங்கள்)
- Fraud & Scams: Ponzi schemes, fake job scams, investment fraud, chit funds, loan scams (நிதி மோசடி மற்றும் ஏமாற்றுதல்)
- Corruption & Vigilance: DVAC raids, bribery arrests, ED raids, IT searches, anti-corruption cases (ஊழல் மற்றும் லஞ்ச ஒழிப்பு)
- Narcotics & Drugs: Ganja, synthetic drugs, drug peddling, narcotic seizures (போதைப்பொருள் கடத்தல்)
- Alcohol & TASMAC: TASMAC liquor sales, illicit arrack, alcohol policy (மது மற்றும் டாஸ்மாக்)
- Police & Law Enforcement: Police investigations, arrests, encounters, police department matters (காவல்துறை நடவடிக்கை)
- Courts & Verdicts: High Court, Supreme Court, bail hearings, petitions, judicial verdicts (நீதிமன்றம் மற்றும் தீர்ப்புகள்)
- Defence & Military: Army, navy, air force, military recruitment, border security (பாதுகாப்பு மற்றும் ராணுவம்)
7. Entertainment & Arts
- Cinema News: Film actors, directors, movie shootings, movie announcements (சினிமா செய்திகள்)
- Box Office: Movie collections, ticket sales, theater occupancy, release business (பாக்ஸ் ஆபிஸ் வசூல்)
- Film Reviews: Movie reviews, trailer/teaser reviews, film critique, ratings (திரைப்பட விமர்சனம்)
- TV & Serials: TV serials, reality shows, television channels (தொலைக்காட்சி மற்றும் தொடர்கள்)
- Music & Audio: Film songs, musical concerts, composers, audio launches (இசை மற்றும் பாடல்கள்)
- OTT & Streaming: Web series, OTT releases, streaming platforms (ஓடிடி மற்றும் வெப் தொடர்கள்)
8. Sports
- Cricket: IPL, international matches, cricketers, cricket scores, tournaments (கிரிக்கெட்)
- Other Sports: Football, hockey, athletics, chess, badminton, kabaddi, sports medals (பிற விளையாட்டுகள்)
9. Business & Economy
- Business & Industry: Manufacturing, factories, companies, investments, trade, startups (வணிகம் மற்றும் தொழில்)
- Stock Market: Sensex, Nifty, share trading, equity markets (பங்குச்சந்தை)
- Banking & Loans: Banks, RBI, interest rates, loans, banking services (வங்கி மற்றும் கடன்கள்)
- Commodity Prices: Gold rate, silver rate, petrol and diesel prices, vegetable prices (பொருட்களின் விலை நிலவரம்)
- Real Estate & Housing: Land registration, guideline value, CMDA approvals, housing board (ரியல் எஸ்டேட்)
- Jobs & Recruitment: Government employment, exam recruitment, job fairs, vacancies (வேலைவாய்ப்பு)
10. Education
- School Education: Schools, syllabus, school teachers, school students, mid-day meals (பள்ளிக் கல்வி)
- Higher Education: Universities, colleges, degree courses, admissions, student counseling (உயர்கல்வி)
- Exams & Results: Board examinations, 10th/12th results, NEET, entrance exams, hall tickets (தேர்வுகள் மற்றும் முடிவுகள்)
11. Agriculture & Marine
- Agriculture & Farming: Crops, paddy, harvest, MSP, farmers, fertilizers (விவசாயம் மற்றும் பயிர்கள்)
- Dams & Water Storage: Dam water levels, Mettur, Mullaiperiyar, water storage, dam release (அணைகள் மற்றும் நீர் இருப்பு)
- Irrigation & Canals: Farm irrigation channels, river water sharing, canal works (நீர்ப்பாசனம் மற்றும் கால்வாய்கள்)
- Fishermen Issues: Fishermen arrests, Sri Lankan navy, fishing rights (மீனவர் பிரச்சனைகள்)
- Fisheries & Marine: Fish production, fish market, fishing ban period, harbours (மீன்வளத்துறை)
12. Health & Mental Well-being
- Hospitals & Medical Care: Government hospitals, doctors, surgery, medical camps, health schemes (மருத்துவமனைகள் மற்றும் சிகிச்சை)
- Diseases & Epidemics: Dengue, viral fever, infections, vaccination drives, public health alerts (நோய்கள் மற்றும் தொற்றுகள்)
- Suicide & Mental Health: Suicide prevention, mental health support, distress helplines (தற்கொலை மற்றும் மனநலம்)
13. Religion, History & Heritage
- Astrology: Horoscope, rasi palan, numerology, panchangam (ஜோதிடம் மற்றும் ராசிபலன்)
- Temples & Spirituality: Temple pujas, consecrations, spiritual pilgrimages, mosques, churches (ஆன்மீகம் மற்றும் வழிபாட்டுத் தலங்கள்)
- Festivals & Celebrations: Pongal, Diwali, Dasara, local festivals, cultural celebrations (திருவிழாக்கள் மற்றும் கொண்டாட்டங்கள்)
- Tamil Language & Heritage: Tamil literature, books, folk arts, Tamil heritage (தமிழ் மொழி மற்றும் இலக்கியம்)
- Archaeology & Heritage: Keezhadi excavations, ancient idols, idol wing CID, historic monuments (தொல்லியல் மற்றும் வரலாற்று பாரம்பரியம்)
14. Science & Technology
- Technology & Gadgets: Mobile phones, artificial intelligence, software, internet, cybersecurity (தொழில்நுட்பம் மற்றும் சாதனங்கள்)
- Space & Astronomy: ISRO, rocket launches, satellite missions, space exploration (விண்வெளி மற்றும் வானியல்)
- Scientific Research: Scientific discoveries, laboratory research, inventions, science exhibitions (அறிவியல் ஆராய்ச்சி)
15. Society & Lifestyle
- Women Welfare: Women safety, self-help groups, women empowerment (பெண்கள் நலம்)
- Child Welfare: Child nutrition, child rights, protection of minors (குழந்தைகள் நலம்)
- Social Justice & Minorities: Caste welfare, SC/ST rights, reservation, transgender welfare (சமூகநீதி மற்றும் சமத்துவம்)
- Food & Dining: Restaurants, food safety, recipes, food hygiene (உணவு மற்றும் உணவகங்கள்)
- Lifestyle & Living: Fashion, fitness, living trends, home decor (வாழ்க்கை முறை)
- Tourism & Travel: Tourist spots, hill stations, travel guides, tourism department (சுற்றுலா)
- Human Interest: Inspiring human stories, unusual incidents, viral events, acts of kindness (மனித நேயம்)
- Obituaries & Tributes: Deaths, funeral ceremonies, memorial tributes, condolences (மறைவு மற்றும் இரங்கல்)
16. Fallback
- Other: Content that does not clearly fit into any of the above categories (மற்றவை)
Running with Ollama
- Download
Qwen2.5-7B-Instruct.Q4_K_M.gguf and Modelfile into your working folder.
- Build the local Ollama model:
ollama create news-classifier -f Modelfile
- Run classification on a Tamil headline:
ollama run news-classifier "Source: Daily Thanthi\nHeadline: சென்னையில் பலத்த மழை தொடங்கியது"
ollama run news-classifier "Headline: மேட்டூர் அணையில் இருந்து டெல்டா பாசனத்திற்கு கூடுதல் தண்ணீர் திறப்பு: விவசாயிகள் மகிழ்ச்சி"
ollama run news-classifier "சென்னை சேப்பாக்கம் மைதானத்தில் இந்தியா அபார வெற்றி: அஸ்வின் 6 விக்கெட்டுகள் வீழ்த்தி சாதனை"
ollama run news-classifier "ISRO successfully launches new navigation satellite aboard PSLV rocket from Sriharikota"
Why Fine-Tuned Qwen 2.5 7B (Decoder) Instead of an Encoder?
1. Dynamic Number of Labels vs Rigid Top-K / Thresholds
The Problem:
- Some articles have only 1 category:
- Headline: "அஸ்வின் 6 விக்கெட்டுகள் வீழ்த்தி சாதனை" -> Only
Cricket.
- Some articles have 2 or 3 categories:
- Headline: "ஆயுத பூஜை: கோயம்பேட்டில் எகிறியது மல்லிகை பூ விலை" ->
Festivals & Celebrations, Commodity Prices.
With an Encoder:
- If you pick Top-5, you will force 4 irrelevant categories onto a simple single-category article.
- If you use a probability threshold (e.g.
> 0.5), you face the threshold-calibration problem across 75 categories: frequent classes will easily pass 0.5, while rare classes (like Archaeology or Industrial Accidents) might only hit 0.35 and get missed.
With Qwen 2.5 (Decoder):
- Because it generates tokens autoregressively, it decides on its own when to stop. If an article only has 1 topic, it outputs that topic and immediately fires the
<|im_end|> stop token. If it has 2 topics, it writes both and stops.
2. Label-to-Label Conditioning (Autoregression)
Encoder (Independent binary heads):
- Each category probability is calculated completely independently of the other 74 categories. The model cannot say: "Since I already chose 'Festivals & Celebrations', does this headline also talk about 'Commodity Prices'?"
Decoder (Qwen 2.5):
- When generating
"Festivals & Celebrations, ", the subsequent generated tokens are conditioned on the fact that it already chose a festival, allowing it to logically decide the secondary category.
3. Understanding Metaphorical and Cryptic Tamil Headlines
Tamil newspaper headlines frequently use idioms, colloquialisms, and metaphors rather than direct words:
- Example: "கம்பி எண்ணும் மாஜி அமைச்சர்" (Literally: "Former minister counting bars" -> Meaning: arrested and sent to jail).
- An encoder looks for keywords like "கைது" (arrest) or "சிறை" (prison). Because the words "கம்பி" (iron rod) and "எண்ணும்" (counting) are used, an encoder often fails or gets confused.
- A large decoder model (Qwen 2.5) has deep linguistic reasoning and world knowledge to understand the metaphorical meaning immediately.
Pros and Cons Summary
Fine-Tuned Qwen 2.5 7B (Decoder):
- Pros:
- Autonomously decides whether to assign 1, 2, or 3 labels and stops cleanly.
- Superior reasoning on metaphorical Tamil headlines and complex regional acronyms.
- Captures relationships between primary and secondary categories.
- Cons:
- Requires 4.68 GB of storage and more RAM/compute during inference compared to an encoder.
Traditional Encoder (e.g., IndicBERT + Sigmoid Head):
- Pros:
- Extremely fast (a few milliseconds per headline) and runs easily on small CPUs.
- Much smaller file size (~500 MB).
- Cons:
- Hard to balance thresholds across 75 categories without extensive per-class tuning.
- Top-k approach adds irrelevant noise to single-category articles.
- Weaker reasoning on idioms and subtle context.
Usage — Python (Transformers + Unsloth)
Install
pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
pip install --no-deps trl peft accelerate bitsandbytes
Load model
from unsloth import FastLanguageModel
from peft import PeftModel
import torch
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="unsloth/Qwen2.5-7B-Instruct-bnb-4bit",
max_seq_length=2048,
dtype=None,
load_in_4bit=True,
)
model = PeftModel.from_pretrained(
model,
"Ganesh2003hsenag/tamil-news-classifier-qwen2.5-7b",
is_trainable=False,
)
FastLanguageModel.for_inference(model)
Classify
def classify(headline, summary="", source="Daily Thanthi"):
if summary.strip():
user_content = f"Source: {source}\nHeadline: {headline}\nSummary: {summary}"
else:
user_content = f"Source: {source}\nHeadline: {headline}"
messages = [
{"role": "system", "content": "You are an expert news classifier for Tamil Nadu news. Given the headline and details of an article, identify and output only the most accurate news category or categories."},
{"role": "user", "content": user_content}
]
prompt = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
inputs = tokenizer([prompt], return_tensors="pt").to("cuda")
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=15,
use_cache=True,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.pad_token_id
)
generated = outputs[0][inputs["input_ids"].shape[1]:]
return tokenizer.decode(generated, skip_special_tokens=True).strip()
# Example
print(classify("சென்னை சேப்பாக்கம் மைதானத்தில் இந்தியா அபார வெற்றி: அஸ்வின் 6 விக்கெட்டுகள் வீழ்த்தி சாதனை"))
# Output: Cricket
print(classify(
"ஆயுத பூஜை: கோயம்பேட்டில் அலைமோதிய கூட்டம்... எகிறியது மல்லிகை பூ விலை",
"சாமந்தி, அரளி உள்ளிட்ட பூஜைக்கான மற்ற மலர்களின் விலையும் கணிசமாக அதிகரித்துள்ளது."
))
# Output: Festivals & Celebrations, Commodity Prices
Training Details
| Setting |
Value |
| Base model |
Qwen/Qwen2.5-7B-Instruct |
| Quantized version used for training |
unsloth/Qwen2.5-7B-Instruct-bnb-4bit |
| Framework |
Unsloth + SFTTrainer |
| LoRA rank |
16 |
| LoRA alpha |
16 |
| Quantization |
4-bit (bnb) |
| Epochs |
1 |
| Learning rate |
2e-4 |
| Train/Val split |
85% / 15% |
Training Data [The training data was collected using the original newspaper scrapers and APIs, then classified using the Gemini API.]
Training data was available at: