Loading…
Loading…
This repository contains a fine-tuned LoRA adapter based on the Sarvam-1 (2B) model, specialized to compose traditional, classical Telugu Sankeerthanas in the legendary style of saint-composer Tallapaka Annamacharya.
To run inference using this model, you need to install the dependencies including unsloth for ultra-fast performance.
pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
pip install torch transformers peft accelerate bitsandbytes deep-translator
from unsloth import FastLanguageModel
import torch
# Load the base model and the custom LoRA adapter
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "nithin093/annamacharya_sangeetha_sankeerthanalu",
max_seq_length = 2048,
dtype = None,
load_in_4bit = True,
)
FastLanguageModel.for_inference(model)
prompt = """Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
పద్మావతీ దేవి వైభవమును మరియు ఆమె కరుణను కీర్తిస్తూ ఒక మధురమైన అన్నమయ్య శైలి సంకీర్తన వ్రాయుము.
### Response:
"""
inputs = tokenizer([prompt], return_tensors = "pt").to("cuda")
outputs = model.generate(
**inputs,
max_new_tokens = 512,
use_cache = True,
temperature = 0.7,
top_p = 0.9,
repetition_penalty = 1.15
)
print(tokenizer.batch_decode(outputs, skip_special_tokens = True)[0])
Perfect for applications serving end-users who wish to prompt in English while expecting high-quality classical Telugu output.
from deep_translator import GoogleTranslator
def generate_sankeerthana_from_english(english_instruction):
# 1. Translate English prompt to Telugu
telugu_translation = GoogleTranslator(source='en', target='te').translate(english_instruction)
# 2. Format with the instruction-tuning template
formatted_prompt = f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
{telugu_translation}
### Response:
"""
# 3. Tokenize and generate
inputs = tokenizer([formatted_prompt], return_tensors = "pt").to("cuda")
outputs = model.generate(
**inputs,
max_new_tokens = 512,
use_cache = True,
temperature = 0.7,
top_p = 0.9,
repetition_penalty = 1.15
)
generated_output = tokenizer.batch_decode(outputs, skip_special_tokens = True)[0]
if "### Response:" in generated_output:
return generated_output.split("### Response:")[1].strip()
return generated_output
# Run the pipeline
english_prompt = "Write a classical sankeerthana about the divine beauty of Goddess Padmavati and her eternal love connection with Lord Venkateswara"
print(generate_sankeerthana_from_english(english_prompt))
sarvamai/sarvam-1keerthanas_instructions_3k.jsonl).Unsloth & trl.SFTTraineradamw_8bit2e-4r=16, alpha=16, Target modules including Attention & MLP projections.This project is licensed under the Apache-2.0 License.
sarvamai/sarvam-1