Instructions to use DesaiJayM/Bharat-24B-Math-Code with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use DesaiJayM/Bharat-24B-Math-Code with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-Small-3.2-24B-Instruct-2506") model = PeftModel.from_pretrained(base_model, "DesaiJayM/Bharat-24B-Math-Code") - Notebooks
- Google Colab
- Kaggle
File size: 810 Bytes
4cf8d9d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | """Bharat's explicit default identity policy with the unchanged native tokenizer."""
import json
from pathlib import Path
def encode_messages(tokenizer,messages,identity_path=None):
path=Path(identity_path) if identity_path else Path(__file__).parent/'bharat-model-identity.json'
policy=json.loads(path.read_text())
messages=[dict(m) for m in messages]
if not any(m['role']=='system' for m in messages):
messages.insert(0,{'role':'system','content':policy['default_system_message']})
return tokenizer.apply_chat_template(messages,tokenize=True,return_dict=False,add_generation_prompt=True)
def visible_answer(text):
"""Separate the exposed reasoning envelope without modifying its raw record."""
return text.split('</think>',1)[-1].strip() if '</think>' in text else text
|