# LoRA Fine-tuning Configuration for Sanskrit Translation & Transliteration Enhancement base_model: Qwen/Qwen2.5-7B-Instruct # Use our custom chat template chat_template_jinja: "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0]['role'] == 'system' %}\n {{- messages[0]['content'] }}\n {%- else %}\n {{- 'You are a Sanskrit-English bilingual AI assistant created by Divax Shah (diabolic6045). You are specialized in Sanskrit language understanding and translation.' }}\n {%- endif %}\n {{- \"\\n\\n# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within XML tags:\\n\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n\\n\\nFor each function call, return a json object with function name and arguments within XML tags:\\n\\n{\\\"name\\\": , \\\"arguments\\\": }\\n<|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0]['role'] == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0]['content'] + '<|im_end|>\\n' }}\n {%- else %}\n {{- '<|im_start|>system\\nYou are a Sanskrit-English bilingual AI assistant created by Divax Shah (diabolic6045). You are specialized in Sanskrit language understanding and translation.<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) or (message.role == \"assistant\" and not message.tool_calls) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {{- '<|im_start|>' + message.role }}\n {%- if message.content %}\n {{- '\\n' + message.content }}\n {%- endif %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '\\n\\n{\\\"name\\\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- '}\\n' }}\n {%- endfor %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n\\n' }}\n {{- message.content }}\n {{- '\\n' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n{%- endif %}" datasets: - path: diabolic6045/Sanskrit-transliteration-chat-dataset type: chat_template field_messages: messages message_property_mappings: role: role content: content roles: system: - system user: - user assistant: - assistant val_set_size: 0.1 output_dir: ./outputs/sanskrit-chat-7b-lora # LoRA configuration adapter: lora lora_model_dir: sequence_len: 512 sample_packing: true eval_sample_packing: true # LoRA hyperparameters lora_r: 16 lora_alpha: 32 lora_dropout: 0.05 lora_target_modules: - gate_proj - down_proj - up_proj - q_proj - v_proj - k_proj - o_proj gradient_accumulation_steps: 4 micro_batch_size: 2 num_epochs: 3 optimizer: adamw_8bit lr_scheduler: cosine learning_rate: 0.00002 # Precision configuration bf16: auto tf32: false # Memory optimization gradient_checkpointing: true flash_attention: true # Training schedule warmup_ratio: 0.1 evals_per_epoch: 4 saves_per_epoch: 1 weight_decay: 0.0 logging_steps: 1 # Wandb configuration wandb_project: sanskrit-qwen wandb_entity: wandb_watch: wandb_name: sanskrit-qwen-7b-lora-chat wandb_log_model: # Resume from checkpoint resume_from_checkpoint: # Hub model ID (update with your username) # hub_model_id: your-username/Sanskrit-Qwen2.5-7B-LoRA-chat