YAML Metadata Warning: empty or missing yaml metadata in repo card (https://huggingface.co/docs/hub/model-cards#model-card-metadata)

Telugu Chatbot (Mitrabot)

This model is a friendly Telugu chatbot based on the T5 architecture, fine-tuned for conversational responses in Telugu.

Model Description

  • Model Type: T5ForConditionalGeneration
  • Language: Telugu
  • Task: Conversational chatbot
  • Fine-tuning Data: [Link to your Hugging Face Dataset, e.g., ankitha29/telugu-colloquial-corpus]
  • Library: Transformers

Intended Use

This model is intended for generating conversational responses in Telugu. It can be used in chatbots, dialogue systems, and other applications where natural language interaction is desired.

Training Data

The model was fine-tuned on the [Link to your Hugging Face Dataset]. The dataset contains a variety of Telugu conversational phrases, idioms, rhymes, and poems.

Evaluation Metrics

[Describe how you evaluated your model. For example:]

The model was evaluated using [BLEU score, ROUGE score, or other relevant metrics]. Human evaluation was also used to assess the fluency and naturalness of the generated responses.

Usage

from transformers import T5ForConditionalGeneration, T5Tokenizer

model_name = "ankitha29/telugu-t5-colloquial"  # Replace with your actual model name
tokenizer = T5Tokenizer.from_pretrained(model_name)
model = T5ForConditionalGeneration.from_pretrained(model_name)

input_text = "ఏమి చేస్తున్నారు?"  #What are you doing? (Telugu)
input_ids = tokenizer(input_text, return_tensors="pt").input_ids

outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Use code with caution.
Markdown
Limitations
[Describe any limitations of your model. For example:]

The model may not perform well on topics outside of its training data. It may also generate incorrect or nonsensical responses in some cases.

License
[Specify the license under which your model is released, e.g., Apache 2.0, MIT]

Author
[Your Name or Organization Name]

**How to Prepare:**

1.  **Replace the Placeholders:** Replace all the bracketed placeholders (`[]`) with accurate information about your model, data, and evaluation.
2.  **Correct Model Class:** Ensure you use `T5ForConditionalGeneration` and `T5Tokenizer` in the code example.
3.  **Hugging Face Repository:** Put this code in a hugging face repository on “Model Card”.
Use code with caution.
Test the Code: Verify that the code example actually works by running it yourself.

3. Create a Hugging Face Space (Demo):

This involves creating a live, interactive demo of your chatbot using Gradio or Streamlit. A space is not necessary but does demonstrate the capabilties of the model.

Here's a Gradio app code and all of your prior code:

import gradio as gr
from transformers import T5ForConditionalGeneration, T5Tokenizer
from sentence_transformers import SentenceTransformer
import torch
import chromadb
from chromadb.utils import embedding_functions

# --- Load your model, tokenizer, and other components ---
model_name = "ankitha29/telugu-t5-colloquial"  # Replace this with your model name
model = T5ForConditionalGeneration.from_pretrained(model_name)
tokenizer = T5Tokenizer.from_pretrained(model_name)

if torch.cuda.is_available():
    device = "cuda"
else:
    device = "cpu"
model = model.to(device) #set device

embedding_model = SentenceTransformer('sentence-transformers/paraphrase-multilingual-mpnet-base-v2').to(device)


#Set up ChromaDB
chroma_ef = embedding_functions.SentenceTransformerEmbeddingFunction(
        model_name="sentence-transformers/paraphrase-multilingual-mpnet-base-v2",
        device=device
)

client = chromadb.Client()
collection_name = "telugu_rag"
collection = client.get_collection(name=collection_name, embedding_function=chroma_ef)
# ----- Your RAG Query Function -----
def rag_query(query, chat_history=None): #removed collection for simplification
    """
    Performs a RAG query and returns the chatbot's response.
    """
    query_lower = query.lower()

    # Handle greetings and simple questions directly (without RAG)
    if "namaskaram" in query_lower or "good morning" in query_lower or "hello" in query_lower or "hi" in query_lower:  # Basic Greeting Detection
        greeting_response = "Namaskaram! బాగున్నారా? (Baagunnaraa?) How are you?"  # Telugu Greeting
        return greeting_response
    elif "what is your name" in query_lower or "what's your name" in query_lower:
        name_response = "My name is Mitrabot (మిత్రబాట్)."
        return name_response


    # Embed the query
    query_embedding = embedding_model.encode(query)

    # Retrieve relevant chunks from ChromaDB
    results = collection.query(
        query_embeddings=[query_embedding],
        n_results=3  # Number of chunks to retrieve
    )

    retrieved_chunks = results["documents"][0]
    print(f"Retrieved Chunks: {retrieved_chunks}")  # Debugging


    # 3. Augment the query with retrieved chunks and chat history
    context = "\n".join(retrieved_chunks)


    # 4. Generate the answer using T5 - Chatbot Prompt
    prompt = f"""You are a friendly Telugu chatbot named Mitrabot (మిత్రబాట్). Use the following context to answer the user's question *in Telugu*. If the context doesn't contain enough information, respond politely in Telugu saying you don't know.

    Context: {context}

    Question: {query}

    Answer:"""

    input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(device)
    outputs = model.generate(input_ids,
                             max_length=256,  # Limit the response length
                             num_beams=5,  # Use beam search for better quality
                             no_repeat_ngram_size=2,  # Avoid repetitive phrases
                             temperature=0.7,  # Adjust temperature for creativity
                             early_stopping=True  # Add early_stopping
                             )

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

    return answer


# ----- Gradio Interface -----
iface = gr.ChatInterface(
    fn=rag_query,  # Your RAG query function
    title="Mitrabot: Your Friendly Telugu Chatbot",
    description="Ask me anything in Telugu or English!",
    examples=["What is a rhyme?", "Tell me a Telugu idiom"] # Example prompts
)

if __name__ == "__main__":
    iface.launch()
Downloads last month
1
Safetensors
Model size
60.5M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support