Instructions to use Timegravity/tamil-lm-2b-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Timegravity/tamil-lm-2b-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Timegravity/tamil-lm-2b-base") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Timegravity/tamil-lm-2b-base") model = AutoModelForMultimodalLM.from_pretrained("Timegravity/tamil-lm-2b-base", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Timegravity/tamil-lm-2b-base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Timegravity/tamil-lm-2b-base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Timegravity/tamil-lm-2b-base", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/Timegravity/tamil-lm-2b-base
- SGLang
How to use Timegravity/tamil-lm-2b-base with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Timegravity/tamil-lm-2b-base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Timegravity/tamil-lm-2b-base", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Timegravity/tamil-lm-2b-base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Timegravity/tamil-lm-2b-base", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use Timegravity/tamil-lm-2b-base with Docker Model Runner:
docker model run hf.co/Timegravity/tamil-lm-2b-base
Upload tools/eval/routing_check.py with huggingface_hub
Browse files- tools/eval/routing_check.py +26 -0
tools/eval/routing_check.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Routing regression (ruling 2026-09-07): run after every serving change. No model is loaded.
|
| 2 |
+
Usage: .venv/bin/python eval/routing_check.py (exit 1 on any failure)"""
|
| 3 |
+
import json, os, sys
|
| 4 |
+
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 5 |
+
import serve as S
|
| 6 |
+
units = S.load_units()
|
| 7 |
+
cases = [json.loads(l) for l in open("eval/routing_cases.jsonl", encoding="utf-8") if l.strip()]
|
| 8 |
+
fails = 0
|
| 9 |
+
for c in cases:
|
| 10 |
+
stage, lit = S.decide_route(c["query"], units)
|
| 11 |
+
ok = stage == c["expected_stage"]
|
| 12 |
+
detail = ""
|
| 13 |
+
if ok and stage == "literature":
|
| 14 |
+
u = lit["unit"]
|
| 15 |
+
if "expected_unit" in c and str(u.get("number")) != str(c["expected_unit"]): ok = False
|
| 16 |
+
if "work_en" in c and u.get("work_en") != c["work_en"]: ok = False
|
| 17 |
+
if "section_adhikaram" in c and (u.get("section") or {}).get("adhikaram") != c["section_adhikaram"]: ok = False
|
| 18 |
+
if "title_contains" in c:
|
| 19 |
+
sec = u.get("section") or {}
|
| 20 |
+
hay = " ".join([str(sec.get("poem_title", "")), " ".join(u.get("text") or [])[:200]])
|
| 21 |
+
if c["title_contains"] not in hay: ok = False
|
| 22 |
+
detail = f" -> {u.get('work_en')} #{u.get('number')} ({lit['kind']}, {lit['mode']})"
|
| 23 |
+
print(("PASS " if ok else "FAIL ") + f"{c['query']:45s} expected {c['expected_stage']:11s} got {stage}{detail}")
|
| 24 |
+
fails += 0 if ok else 1
|
| 25 |
+
print(f"{len(cases) - fails}/{len(cases)} routing cases pass")
|
| 26 |
+
sys.exit(1 if fails else 0)
|