--- base_model: unsloth/gemma-2-9b tags: - text-generation-inference - transformers - unsloth - gemma2 - trl - local-finetuning license: apache-2.0 language: - en - te datasets: - eswardivi/Telugu_InstructData # widget: # - text: "### Task\nGenerate a SQL query to answer the following question:\n`How many heads of the departments are older than 56?`\n\n### Database Schema\nThe query will run on a database with the following schema:\nCREATE TABLE head (age INTEGER)\n\n### Answer\nGiven the database schema, here is the SQL query that answers `How many heads of the departments are older than 56?`:\n```sql" # example_title: "One Table" # - text: "### Task\nGenerate a SQL query to answer the following question:\n`How many departments are led by heads who are not mentioned?`\n\n### Database Schema\nThe query will run on a database with the following schema:\nCREATE TABLE management (department_id VARCHAR);\nCREATE TABLE department (department_id VARCHAR)\n\n### Answer\nGiven the database schema, here is the SQL query that answers `How many departments are led by heads who are not mentioned?`:\n```sql" # example_title: "Two Tables" --- # Thanks for being patient! 💜💜 # Model Card for Model ID A fine-tuned version of Gemma2 9B for the Telugu Language Instruct on `eswardivi/Telugu_InstructData` dataset using [Unsloth](https://github.com/unslothai/unsloth). [](https://github.com/unslothai/unsloth) ## Model Details ### Model Description This model has been finetuned with `eswardivi/Telugu_InstructData` on `unsloth/gemma-2-9b`. This is to ensure there is a raise in Telugu Language Model usage in daily applications. This model will respond in english text where as the content is in telugu language. For example instead of `ఎలా ఉన్నావ్?` it will respond with `ela unnav?`. This is to ensure the model is not using more tokens for unicode characters. - **Developed by:** pavankumarbalijepalli - **Model type:** CASUAL_LM - **Language(s) (NLP):** English, Telugu - **License:** MIT - **Finetuned from model:** [unsloth/gemma-2-9b](https://huggingface.co/unsloth/gemma-2-9b) ### Model Sources - **Repository:** [HappyDevCorp/ai-ft-tellm](https://github.com/HappyDevCorp/ai-ft-tellm/blob/main/finetunes/Gemma2_(9B)_Alpaca.ipynb) ## Uses Model is supposed to be used for the cases where you have a natural language question in telugu language to get a response in return in telugu language. The context should be below 8192 tokens. The output will be generated in telugu. ### Downstream Use ```python # WITH UNSLOTH - RECOMMENDED from unsloth import FastLanguageModel max_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally! dtype = ( None ) load_in_4bit = True model, tokenizer = FastLanguageModel.from_pretrained( model_name="pavankumarbalijepalli/telLM-gemma2-9b", # YOUR MODEL YOU USED FOR TRAINING max_seq_length=max_seq_length, dtype=dtype, load_in_4bit=load_in_4bit, ) FastLanguageModel.for_inference(model) # Enable native 2x faster inference prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request. ### Instruction: {} ### Input: {} ### Response: {}""" inputs = tokenizer( [ prompt.format( "Naa peru enti?", "Pavan Kumar ninnu aduguthunnadu", "", ) ], return_tensors="pt", ).to("cuda") outputs = model.generate(**inputs, max_new_tokens=64, use_cache=True) tokenizer.batch_decode(outputs) ``` ```python # WITHOUT UNSLOTH - NOT RECOMMENDED from peft import AutoPeftModelForCausalLM from transformers import AutoTokenizer model = AutoPeftModelForCausalLM.from_pretrained( "pavankumarbalijepalli/telLM-gemma2-9b", load_in_4bit = load_in_4bit, ) tokenizer = AutoTokenizer.from_pretrained("pavankumarbalijepalli/telLM-gemma2-9b") prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request. ### Instruction: {} ### Input: {} ### Response: {}""" inputs = tokenizer( [ alpaca_prompt.format( "Naa peru enti?", # instruction "Pavan Kumar ninnu aduguthunnadu", # input "", # output - leave this blank for generation! ) ], return_tensors="pt", ).to("cuda") outputs = model.generate(**inputs, max_new_tokens=64, use_cache=True) tokenizer.batch_decode(outputs) ``` ### Out-of-Scope Use __Generating Unintended Code:__ While the model can converse in telugu language, it may not be robust enough to handle complex logic or edge cases. Using it to generate critical production code could lead to errors or unexpected behavior in databases. __Security Risks:__ `will_add_soon`. __Beyond its Training Scope:__ The model is trained on telugu Language. Using it for a different languages could lead to inaccurate or nonsensical responses. ## Bias, Risks, and Limitations __Bias and Fairness:__ The model's training data may contain biases that are reflected in the responses. This could lead to unfair or discriminatory outcomes, especially if the data is not carefully curated. __Interpretability and Explainability:__ Language models are often "black boxes" where it's difficult to understand how they learn a specific language, in this case Telugu. This lack of interpretability makes it challenging to debug errors or ensure the generated queries are safe and efficient. __Replacing Human Expertise:__ `will_add_soon` ### Recommendations Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. ## Training Details ### Training Data ``` @misc {divi_eswar_chowdary_2025, author = { {Divi Eswar Chowdary} }, title = { Telugu_InstructData (Revision b734b7d) }, year = 2025, url = { https://huggingface.co/datasets/eswardivi/Telugu_InstructData }, doi = { 10.57967/hf/4666 }, publisher = { Hugging Face } } ``` ## Evaluation ### Testing Data, Factors & Metrics #### Testing Data Used eswardivi/Telugu_InstructData and split the data into training and testing datasets. The holdout dataset is used for testing the model. ``` ############# WILL UPDATE SOON ############# #### Factors The complexity of the questions are calculated using the number of tables per question, number of joins, group by, and sub queries per answer. This complexity is used to prepare the test data by stratifying the split around the complexity. #### Metrics * __Execution Success:__ This metric is used to find out if the generated query is executable without arising any errors. For this, a sqllite3 connection is made to the memory, and using context the dummy tables are created. Then the predicted SQL is executed. This checks out if the generated query is in proper syntax, and if the model is hallucinating any new columns. * __Inference Time:__ This metric is used to find out which model is providing results in less amount of time. This combined with the execution success, gives the efficiency of the model. - ### Results * __Execution Success:__ Finetuned Phi-2 has 29% more success rate than the SQLCoder-7b-2 * __Inference Time:__ Finetuned Phi-2 has 41% increased inference speed than SQLCoder-7b-2 #### Summary * __Reduced Inference Time and Memory Footprint:__ The fine-tuned Phi-2 model demonstrated a reduction in inference time and memory usage compared to the DeFog SQLCoder. This is attributed to Phi-2's smaller size and the efficiency of quantization techniques employed during fine-tuning. This finding implies that NL2SQL models can be deployed on lower-powered devices like laptops or even mobile phones, potentially democratizing access to this technology for a wider range of users. * __Competitive Performance on Easy and Medium Queries:__ The fine-tuned Phi-2 achieved comparable performance to the DeFog SQLCoder in terms of accuracy on easy, medium, and hard difficulty queries. This indicates that Phi-2, despite its smaller size, can effectively handle a significant portion of real-world NL2SQL tasks, especially for simpler queries. * __Challenges with Complex Queries:__ While Phi-2 performed well on easier queries, it encountered challenges with complex queries, exhibiting a drop in execution success compared to the DeFog SQLCoder. This highlights the trade-off between model size and complexity, suggesting that larger models might still be necessary for tackling highly intricate tasks. * __Potential for Further Improvement:__ The fine-tuning process employed in this study can be further optimized by exploring different hyperparameter configurations and potentially investigating alternative fine-tuning techniques like adapter-based methods. This optimization has the potential to improve the model's performance on complex queries while maintaining its efficiency. ``` ## Environmental Impact Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700). - **Hardware Type:** RTX 4070 PCIE 12GB X 1 - **Hours used:** 14 Hours - **Cloud Provider:** Private Local Machine - **Compute Region:** Asia-East-1 - **Carbon Emitted:** 1.81 kg eq. CO2 ## Citation **BibTeX:** ``` @misc {pavan_kumar_balijepalli_2025, author = { {Pavan Kumar Balijepalli} }, title = { telLM-gemma2-9b-16bit (Revision 7befd21) }, year = 2025, url = { https://huggingface.co/pavankumarbalijepalli/telLM-gemma2-9b-16bit }, doi = { 10.57967/hf/4674 }, publisher = { Hugging Face } } ```