Text Generation
PEFT
Safetensors
Marathi
lora
qlora
education
k12
indian-languages
cbse
ncert
bharatllm
foundryailabs
conversational
Instructions to use FoundryAILabs/bharat-marathi-7b-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use FoundryAILabs/bharat-marathi-7b-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/mistral-7b-instruct-v0.3-bnb-4bit") model = PeftModel.from_pretrained(base_model, "FoundryAILabs/bharat-marathi-7b-lora") - Notebooks
- Google Colab
- Kaggle
Upload BharatLLM adapter
Browse files- README.md +87 -0
- adapter_config.json +50 -0
- adapter_model.safetensors +3 -0
- chat_template.jinja +87 -0
- tokenizer.json +0 -0
- tokenizer_config.json +17 -0
README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- mr
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
library_name: peft
|
| 6 |
+
base_model: mistralai/Mistral-7B-Instruct-v0.3
|
| 7 |
+
tags:
|
| 8 |
+
- lora
|
| 9 |
+
- qlora
|
| 10 |
+
- education
|
| 11 |
+
- k12
|
| 12 |
+
- indian-languages
|
| 13 |
+
- cbse
|
| 14 |
+
- ncert
|
| 15 |
+
- bharatllm
|
| 16 |
+
- foundryailabs
|
| 17 |
+
datasets:
|
| 18 |
+
- FoundryAILabs/k12-indian-curriculum-4.9m
|
| 19 |
+
pipeline_tag: text-generation
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
# BharatLLM Marathi -- K-12 Education LoRA
|
| 23 |
+
|
| 24 |
+
A **QLoRA adapter** for Mistral-7B, fine-tuned on **CBSE/NCERT K-12 curriculum** data in **Marathi** (मराठी).
|
| 25 |
+
|
| 26 |
+
Part of the **BharatLLM** project: 13 LoRA adapters (12 K-12 languages + 1 BTech Engineering).
|
| 27 |
+
|
| 28 |
+
## Model Details
|
| 29 |
+
|
| 30 |
+
| Property | Value |
|
| 31 |
+
|----------|-------|
|
| 32 |
+
| **Base Model** | mistralai/Mistral-7B-Instruct-v0.3 |
|
| 33 |
+
| **Method** | QLoRA (4-bit quantization + LoRA, r=64) |
|
| 34 |
+
| **Trainable Parameters** | 167,772,160 (2.26% of 7.4B) |
|
| 35 |
+
| **Training Library** | Unsloth |
|
| 36 |
+
| **Language** | Marathi (मराठी) |
|
| 37 |
+
| **Domain** | K-12 Education (CBSE/NCERT, Grades 6-12) |
|
| 38 |
+
| **Training Data** | ~408K curriculum-aligned Q&A pairs |
|
| 39 |
+
| **License** | Apache 2.0 |
|
| 40 |
+
|
| 41 |
+
## Quick Start (Unsloth -- Fastest)
|
| 42 |
+
|
| 43 |
+
```python
|
| 44 |
+
from unsloth import FastLanguageModel
|
| 45 |
+
|
| 46 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 47 |
+
model_name="FoundryAILabs/bharat-marathi-7b-lora",
|
| 48 |
+
max_seq_length=2048,
|
| 49 |
+
load_in_4bit=True,
|
| 50 |
+
)
|
| 51 |
+
FastLanguageModel.for_inference(model)
|
| 52 |
+
|
| 53 |
+
inputs = tokenizer("[INST] What is photosynthesis? [/INST]", return_tensors="pt").to("cuda")
|
| 54 |
+
outputs = model.generate(**inputs, max_new_tokens=512)
|
| 55 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
## Using with HuggingFace Transformers
|
| 59 |
+
|
| 60 |
+
```python
|
| 61 |
+
from peft import PeftModel
|
| 62 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 63 |
+
|
| 64 |
+
base = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-Instruct-v0.3", load_in_4bit=True, device_map="auto")
|
| 65 |
+
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.3")
|
| 66 |
+
model = PeftModel.from_pretrained(base, "FoundryAILabs/bharat-marathi-7b-lora")
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
## All BharatLLM Models
|
| 70 |
+
|
| 71 |
+
| Model | Language | Type |
|
| 72 |
+
|-------|----------|------|
|
| 73 |
+
| [FoundryAILabs/bharat-english-7b-lora](https://huggingface.co/FoundryAILabs/bharat-english-7b-lora) | English | K-12 |
|
| 74 |
+
| [FoundryAILabs/bharat-hindi-7b-lora](https://huggingface.co/FoundryAILabs/bharat-hindi-7b-lora) | Hindi | K-12 |
|
| 75 |
+
| [FoundryAILabs/bharat-bengali-7b-lora](https://huggingface.co/FoundryAILabs/bharat-bengali-7b-lora) | Bengali | K-12 |
|
| 76 |
+
| [FoundryAILabs/bharat-telugu-7b-lora](https://huggingface.co/FoundryAILabs/bharat-telugu-7b-lora) | Telugu | K-12 |
|
| 77 |
+
| [FoundryAILabs/bharat-tamil-7b-lora](https://huggingface.co/FoundryAILabs/bharat-tamil-7b-lora) | Tamil | K-12 |
|
| 78 |
+
| [FoundryAILabs/bharat-kannada-7b-lora](https://huggingface.co/FoundryAILabs/bharat-kannada-7b-lora) | Kannada | K-12 |
|
| 79 |
+
| [FoundryAILabs/bharat-malayalam-7b-lora](https://huggingface.co/FoundryAILabs/bharat-malayalam-7b-lora) | Malayalam | K-12 |
|
| 80 |
+
| [FoundryAILabs/bharat-marathi-7b-lora](https://huggingface.co/FoundryAILabs/bharat-marathi-7b-lora) | Marathi | K-12 |
|
| 81 |
+
| [FoundryAILabs/bharat-gujarati-7b-lora](https://huggingface.co/FoundryAILabs/bharat-gujarati-7b-lora) | Gujarati | K-12 |
|
| 82 |
+
| [FoundryAILabs/bharat-odia-7b-lora](https://huggingface.co/FoundryAILabs/bharat-odia-7b-lora) | Odia | K-12 |
|
| 83 |
+
| [FoundryAILabs/bharat-punjabi-7b-lora](https://huggingface.co/FoundryAILabs/bharat-punjabi-7b-lora) | Punjabi | K-12 |
|
| 84 |
+
| [FoundryAILabs/bharat-urdu-7b-lora](https://huggingface.co/FoundryAILabs/bharat-urdu-7b-lora) | Urdu | K-12 |
|
| 85 |
+
| [FoundryAILabs/bharat-btech-7b-lora](https://huggingface.co/FoundryAILabs/bharat-btech-7b-lora) | English | BTech Engineering |
|
| 86 |
+
|
| 87 |
+
**Website**: [foundryailabs.io](https://foundryailabs.io) | **GitHub**: [github.com/foundryailabs/BharatLLM](https://github.com/foundryailabs/BharatLLM)
|
adapter_config.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": {
|
| 6 |
+
"base_model_class": "MistralForCausalLM",
|
| 7 |
+
"parent_library": "transformers.models.mistral.modeling_mistral",
|
| 8 |
+
"unsloth_fixed": true
|
| 9 |
+
},
|
| 10 |
+
"base_model_name_or_path": "unsloth/mistral-7b-instruct-v0.3-bnb-4bit",
|
| 11 |
+
"bias": "none",
|
| 12 |
+
"corda_config": null,
|
| 13 |
+
"ensure_weight_tying": false,
|
| 14 |
+
"eva_config": null,
|
| 15 |
+
"exclude_modules": null,
|
| 16 |
+
"fan_in_fan_out": false,
|
| 17 |
+
"inference_mode": true,
|
| 18 |
+
"init_lora_weights": true,
|
| 19 |
+
"layer_replication": null,
|
| 20 |
+
"layers_pattern": null,
|
| 21 |
+
"layers_to_transform": null,
|
| 22 |
+
"loftq_config": {},
|
| 23 |
+
"lora_alpha": 16,
|
| 24 |
+
"lora_bias": false,
|
| 25 |
+
"lora_dropout": 0,
|
| 26 |
+
"megatron_config": null,
|
| 27 |
+
"megatron_core": "megatron.core",
|
| 28 |
+
"modules_to_save": null,
|
| 29 |
+
"peft_type": "LORA",
|
| 30 |
+
"peft_version": "0.18.1",
|
| 31 |
+
"qalora_group_size": 16,
|
| 32 |
+
"r": 64,
|
| 33 |
+
"rank_pattern": {},
|
| 34 |
+
"revision": null,
|
| 35 |
+
"target_modules": [
|
| 36 |
+
"q_proj",
|
| 37 |
+
"v_proj",
|
| 38 |
+
"k_proj",
|
| 39 |
+
"up_proj",
|
| 40 |
+
"o_proj",
|
| 41 |
+
"down_proj",
|
| 42 |
+
"gate_proj"
|
| 43 |
+
],
|
| 44 |
+
"target_parameters": null,
|
| 45 |
+
"task_type": "CAUSAL_LM",
|
| 46 |
+
"trainable_token_indices": null,
|
| 47 |
+
"use_dora": false,
|
| 48 |
+
"use_qalora": false,
|
| 49 |
+
"use_rslora": false
|
| 50 |
+
}
|
adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e4b5e0aca90f0800527b1e3c6e6c96da0bbed1755ae43f92ebf0af76a71da120
|
| 3 |
+
size 671149168
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- if messages[0]["role"] == "system" %}
|
| 2 |
+
{%- set system_message = messages[0]["content"] %}
|
| 3 |
+
{%- set loop_messages = messages[1:] %}
|
| 4 |
+
{%- else %}
|
| 5 |
+
{%- set loop_messages = messages %}
|
| 6 |
+
{%- endif %}
|
| 7 |
+
{%- if not tools is defined %}
|
| 8 |
+
{%- set tools = none %}
|
| 9 |
+
{%- endif %}
|
| 10 |
+
{%- set user_messages = loop_messages | selectattr("role", "equalto", "user") | list %}
|
| 11 |
+
|
| 12 |
+
{#- This block checks for alternating user/assistant messages, skipping tool calling messages #}
|
| 13 |
+
{%- set ns = namespace() %}
|
| 14 |
+
{%- set ns.index = 0 %}
|
| 15 |
+
{%- for message in loop_messages %}
|
| 16 |
+
{%- if not (message.role == "tool" or message.role == "tool_results" or (message.tool_calls is defined and message.tool_calls is not none)) %}
|
| 17 |
+
{%- if (message["role"] == "user") != (ns.index % 2 == 0) %}
|
| 18 |
+
{{- raise_exception("After the optional system message, conversation roles must alternate user/assistant/user/assistant/...") }}
|
| 19 |
+
{%- endif %}
|
| 20 |
+
{%- set ns.index = ns.index + 1 %}
|
| 21 |
+
{%- endif %}
|
| 22 |
+
{%- endfor %}
|
| 23 |
+
|
| 24 |
+
{{- bos_token }}
|
| 25 |
+
{%- for message in loop_messages %}
|
| 26 |
+
{%- if message["role"] == "user" %}
|
| 27 |
+
{%- if tools is not none and (message == user_messages[-1]) %}
|
| 28 |
+
{{- "[AVAILABLE_TOOLS] [" }}
|
| 29 |
+
{%- for tool in tools %}
|
| 30 |
+
{%- set tool = tool.function %}
|
| 31 |
+
{{- '{"type": "function", "function": {' }}
|
| 32 |
+
{%- for key, val in tool.items() if key != "return" %}
|
| 33 |
+
{%- if val is string %}
|
| 34 |
+
{{- '"' + key + '": "' + val + '"' }}
|
| 35 |
+
{%- else %}
|
| 36 |
+
{{- '"' + key + '": ' + val|tojson }}
|
| 37 |
+
{%- endif %}
|
| 38 |
+
{%- if not loop.last %}
|
| 39 |
+
{{- ", " }}
|
| 40 |
+
{%- endif %}
|
| 41 |
+
{%- endfor %}
|
| 42 |
+
{{- "}}" }}
|
| 43 |
+
{%- if not loop.last %}
|
| 44 |
+
{{- ", " }}
|
| 45 |
+
{%- else %}
|
| 46 |
+
{{- "]" }}
|
| 47 |
+
{%- endif %}
|
| 48 |
+
{%- endfor %}
|
| 49 |
+
{{- "[/AVAILABLE_TOOLS]" }}
|
| 50 |
+
{%- endif %}
|
| 51 |
+
{%- if loop.last and system_message is defined %}
|
| 52 |
+
{{- "[INST] " + system_message + "\n\n" + message["content"] + "[/INST]" }}
|
| 53 |
+
{%- else %}
|
| 54 |
+
{{- "[INST] " + message["content"] + "[/INST]" }}
|
| 55 |
+
{%- endif %}
|
| 56 |
+
{%- elif message.tool_calls is defined and message.tool_calls is not none %}
|
| 57 |
+
{{- "[TOOL_CALLS] [" }}
|
| 58 |
+
{%- for tool_call in message.tool_calls %}
|
| 59 |
+
{%- set out = tool_call.function|tojson %}
|
| 60 |
+
{{- out[:-1] }}
|
| 61 |
+
{%- if not tool_call.id is defined or tool_call.id|length != 9 %}
|
| 62 |
+
{{- raise_exception("Tool call IDs should be alphanumeric strings with length 9!") }}
|
| 63 |
+
{%- endif %}
|
| 64 |
+
{{- ', "id": "' + tool_call.id + '"}' }}
|
| 65 |
+
{%- if not loop.last %}
|
| 66 |
+
{{- ", " }}
|
| 67 |
+
{%- else %}
|
| 68 |
+
{{- "]" + eos_token }}
|
| 69 |
+
{%- endif %}
|
| 70 |
+
{%- endfor %}
|
| 71 |
+
{%- elif message["role"] == "assistant" %}
|
| 72 |
+
{{- " " + message["content"]|trim + eos_token}}
|
| 73 |
+
{%- elif message["role"] == "tool_results" or message["role"] == "tool" %}
|
| 74 |
+
{%- if message.content is defined and message.content.content is defined %}
|
| 75 |
+
{%- set content = message.content.content %}
|
| 76 |
+
{%- else %}
|
| 77 |
+
{%- set content = message.content %}
|
| 78 |
+
{%- endif %}
|
| 79 |
+
{{- '[TOOL_RESULTS] {"content": ' + content|string + ", " }}
|
| 80 |
+
{%- if not message.tool_call_id is defined or message.tool_call_id|length != 9 %}
|
| 81 |
+
{{- raise_exception("Tool call IDs should be alphanumeric strings with length 9!") }}
|
| 82 |
+
{%- endif %}
|
| 83 |
+
{{- '"call_id": "' + message.tool_call_id + '"}[/TOOL_RESULTS]' }}
|
| 84 |
+
{%- else %}
|
| 85 |
+
{{- raise_exception("Only user and assistant roles are supported, with the exception of an initial optional system message!") }}
|
| 86 |
+
{%- endif %}
|
| 87 |
+
{%- endfor %}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": true,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<s>",
|
| 5 |
+
"clean_up_tokenization_spaces": false,
|
| 6 |
+
"eos_token": "</s>",
|
| 7 |
+
"is_local": false,
|
| 8 |
+
"legacy": false,
|
| 9 |
+
"model_max_length": 32768,
|
| 10 |
+
"pad_token": "[control_768]",
|
| 11 |
+
"padding_side": "left",
|
| 12 |
+
"sp_model_kwargs": {},
|
| 13 |
+
"spaces_between_special_tokens": false,
|
| 14 |
+
"tokenizer_class": "TokenizersBackend",
|
| 15 |
+
"unk_token": "<unk>",
|
| 16 |
+
"use_default_system_prompt": false
|
| 17 |
+
}
|