You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

Model Description

BharatGPT-mini-indic is a fine-tuned version of BharatGPT-mini developed to enhance multilingual understanding and text generation for Indic languages. Built on a Transformer-based autoregressive architecture, the base model was pretrained on large-scale public text corpora using a self-supervised causal language modeling approach, enabling it to learn grammar, semantics, and contextual relationships across languages.

BharatGPT-mini-indic is further fine-tuned on Indic-language datasets to improve performance in regional language understanding, multilingual conversation, and natural language generation tasks. The model is well suited for applications such as conversational AI, question answering, summarization, intent detection, entity extraction, and multilingual virtual assistants, with a strong focus on Indian language use cases.

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

# -----------------------------------
# LOAD MODEL
# -----------------------------------

model_name = "CoRover/BharatGPT-mini-Indic"

tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

model.to(device)
model.eval()

# -----------------------------------
# SETTINGS
# -----------------------------------

FALLBACK_MESSAGE = "Sorry, I don't know the answer to that."

# Only block obvious garbage phrases
BAD_PHRASES = [
    "digital commerce solutions",
    "business operations effectively",
    "real-time data sources",
    "verification and privacy",
    "affordable price point",
    "ensuring that your ai",
    "platform based on ai technology",
]

print("Chat started (type 'exit' to quit)\n")

# -----------------------------------
# VALIDATION FUNCTION
# -----------------------------------

def is_invalid_response(question, response):

    q = question.lower().strip()
    r = response.lower().strip()

    # -----------------------------------
    # EMPTY RESPONSE
    # -----------------------------------

    if len(r) < 3:
        return True

    # -----------------------------------
    # IDENTITY / ENTITY QUESTIONS
    # -----------------------------------

    identity_patterns = [
        "who is",
        "what is",
        "tell me about",
        "who made",
        "who built",
        "who created",
        "what are",
    ]

    is_identity_question = any(
        pattern in q for pattern in identity_patterns
    )

    # -----------------------------------
    # ALLOW RELEVANT ENTITY ANSWERS
    # -----------------------------------

    if is_identity_question:

        important_words = [
            word for word in q.split()
            if len(word) > 2
        ]

        for word in important_words:
            if word in r:
                return False

    # -----------------------------------
    # BAD PHRASES
    # -----------------------------------

    for phrase in BAD_PHRASES:
        if phrase in r:
            return True

    # -----------------------------------
    # TOO LONG
    # -----------------------------------

    if len(r.split()) > 40:
        return True

    # -----------------------------------
    # TOO REPETITIVE
    # -----------------------------------

    words = r.split()

    if len(words) > 10:

        unique_ratio = len(set(words)) / len(words)

        if unique_ratio < 0.5:
            return True

    # -----------------------------------
    # BAD ENDINGS
    # -----------------------------------

    bad_endings = [
        "and",
        "or",
        "but",
        "because",
        "so",
    ]

    for ending in bad_endings:
        if r.endswith(ending):
            return True

    # -----------------------------------
    # TOO MANY SYMBOLS
    # -----------------------------------

    if response.count(":") > 3:
        return True

    # -----------------------------------
    # GENERAL RELEVANCE CHECK
    # -----------------------------------

    question_words = set(q.split())
    response_words = set(r.split())

    overlap = question_words.intersection(response_words)

    if len(overlap) == 0 and len(words) > 12:
        return True

    return False

# -----------------------------------
# CHAT LOOP
# -----------------------------------

while True:

    user_input = input("You: ")

    if user_input.lower() in ["exit", "quit"]:
        break

    # -----------------------------------
    # PROMPT
    # -----------------------------------

    prompt = f"""
You are a helpful AI assistant.

Rules:
- Give short factual answers.
- Do not generate advertisements.
- Do not invent fake information.
- If unsure, reply only:
"I don't know."

User: {user_input}
Assistant:
"""

    # -----------------------------------
    # TOKENIZE
    # -----------------------------------

    inputs = tokenizer(
        prompt,
        return_tensors="pt"
    ).to(device)

    # -----------------------------------
    # GENERATE
    # -----------------------------------

    with torch.no_grad():

        outputs = model.generate(
            **inputs,
            max_new_tokens=35,
            temperature=0.5,
            top_p=0.85,
            top_k=40,
            do_sample=True,
            repetition_penalty=1.2,
            no_repeat_ngram_size=3,
            pad_token_id=tokenizer.eos_token_id
        )

    # -----------------------------------
    # DECODE
    # -----------------------------------

    decoded = tokenizer.decode(
        outputs[0],
        skip_special_tokens=True
    )

    response = decoded[len(prompt):].strip()

    # Remove extra generated turns
    response = response.split("User:")[0].strip()

    # -----------------------------------
    # VALIDATE RESPONSE
    # -----------------------------------

    if is_invalid_response(user_input, response):
        response = FALLBACK_MESSAGE

    # -----------------------------------
    # PRINT RESPONSE
    # -----------------------------------

    print(f"Bot: {response}\n")

It is best suited for S-RAG (Secure Retrieval-Augmented Generation) or fine-tuning with your own data. For enhanced performance, integration with Conversational Agentic AI platform is recommended (though not mandatory). This platform enables the creation of multi-modal and multi-lingual AI Agents, Co-Pilots, and Virtual Assistants (such as ChatBots, VoiceBots, and VideoBots) using a sovereign AI and composite AI approach. It leverages classic NLP, grounded generative AI with BharatGPT, and Generally Available LLMs to deliver powerful, versatile AI solutions.

Usage and Limitations

Downloads last month
-
Safetensors
Model size
0.5B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for CoRover/BharatGPT-mini-Indic

Quantizations
1 model