RagaLakshana LLM

A domain-specialized language model for Indian classical music theory, trained to articulate the Lakshana β€” the defining grammatical and aesthetic characteristics β€” of ragas in both the Hindustani and Carnatic traditions.


Overview

Indian classical music operates through a sophisticated theoretical framework that has been codified, transmitted, and elaborated upon over more than two millennia. At the heart of this system lies the concept of Raga β€” a term derived from the Sanskrit root raΓ±j (to color, to illuminate), denoting a melodic entity with prescribed scalar, ornamental, and emotional properties. Unlike the Western concept of a musical scale or mode, a raga is understood as a living musical personality (jΔ«va) governed by a body of rules collectively called Raga Lakshana (literally, "the signs of a raga").

RagaLakshana LLM is a fine-tuned large language model trained to reason about, explain, and apply these theoretical principles. It draws on instruction pairs covering the full spectrum of raga theory β€” from foundational concepts (Sapta Swaras, Thaats, Melakartas) to nuanced analytical tasks (raga identification from melodic fragments, distinguishing structurally similar ragas, generating grammatically correct swara sequences).

The model is designed to serve as an accessible scholarly interlocutor β€” a resource for students, musicians, researchers, and enthusiasts seeking structured, accurate exposition of Indian classical music theory.


Theoretical Foundations

The Sapta Swara System

Indian music recognizes seven primary swaras (notes) β€” Sa, Ri/Re, Ga, Ma, Pa, Dha, Ni β€” derived from ancient Vedic chanting traditions and systematized in treatises such as the Natya Shastra of Bharata Muni (c. 2nd century BCE – 2nd century CE) and the Sangita Ratnakara of Sarangadeva (13th century CE). These seven notes, with their komal (flattened) and tivra (sharpened) variants, yield twelve distinct pitches β€” structurally homologous to the Western chromatic scale but theoretically grounded in a different ontological tradition, where pitches are understood in relation to a fixed tonic (Sa) rather than as absolute frequencies.

Hindustani System: Thaats

The Hindustani tradition of North India organizes ragas under ten parent scales called Thaats, as codified by Vishnu Narayan Bhatkhande in the early 20th century. Each thaat is a heptatonic scale; ragas classified under a thaat need not use all seven notes but must derive their notes from that scalar set. The ten Thaats are: Bilawal, Kalyan, Khamaj, Bhairav, Purvi, Marwa, Kafi, Asavari, Bhairavi, and Todi.

Carnatic System: 72 Melakartas

The Carnatic tradition of South India employs an exhaustive classificatory system of 72 Melakarta parent ragas, each a complete heptatonic scale. This system, attributed to the musicologist Venkatamakhin (17th century), generates all possible combinations of the twelve pitches arranged in ascending heptatonic order. Janya (derived) ragas are understood as subsets or modifications of Melakarta scales.

Raga Lakshana: The Grammar of Raga

Each raga is characterized by a set of defining properties:

  • Arohana / Avarohana β€” the ascending and descending scalar patterns, which may be asymmetric or vakra (zigzag)
  • Vadi β€” the most prominent note (analogous to a tonic or dominant)
  • Samvadi β€” the second most important note, typically a fourth or fifth away from the Vadi
  • Pakad / Swarup β€” characteristic melodic phrases that immediately identify the raga
  • Jati β€” classification by note count: Audava (5), Shadava (6), or Sampurna (7)
  • Rasa β€” the aesthetic emotion or mood evoked (based on the Navarasa framework)
  • Samay β€” prescribed time of performance (dawn, morning, midday, evening, night, midnight)
  • Ritu β€” associated season
  • Vivadi Swara β€” dissonant note relationships to avoid

Capabilities

This model has been trained to perform the following tasks with scholarly precision:

Raga Profiling β€” Provide complete Lakshana for a named raga, including all structural, aesthetic, and contextual properties across both Hindustani and Carnatic traditions.

Swara Sequence Generation β€” Produce grammatically valid melodic phrases in a specified raga, respecting its ascending/descending rules, vakra movements, and characteristic ornaments.

Raga Identification β€” Analyze a given sequence of swaras and determine the raga it belongs to, with reasoning based on Lakshana criteria.

Comparative Analysis β€” Distinguish between structurally similar ragas that are frequently confused β€” such as Yaman and Bihag (both using tivra Ma), Marwa and Puriya (shared scalar identity, different emotional character), or Bhimpalasi and Bageshri (similar Vadi-Samvadi relationships).

Theoretical Exposition β€” Explain abstract concepts in raga theory: the significance of Vadi-Samvadi, the Shadja-Pancham Bhava (consonance of Sa-Pa), the function of Vivadi swaras, the role of Alap in raga elaboration, and the developmental arc from Alap to Jhala in Hindustani music.

Cross-Traditional Mapping β€” Identify structural correspondences between Hindustani and Carnatic ragas (e.g., Yaman ↔ Kalyani; Bhairavi ↔ Sindhu Bhairavi; Todi ↔ Hanumatodi).


How to Use

from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model_id = "sgattup/RagaLakshanaLLM"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.float16,
    device_map="auto"
)

PROMPT = """You are an expert in Indian classical music and Raga Lakshana β€” the grammar and characteristics of ragas. Answer questions about ragas, swara sequences, raga identification, Thaats, Melakartas, and Indian music theory with precision and depth.

### Question:
{}

### Answer:
"""

def ask(question, max_tokens=600):
    prompt = PROMPT.format(question)
    inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
    outputs = model.generate(
        **inputs,
        max_new_tokens=max_tokens,
        temperature=0.7,
        do_sample=True
    )
    response = tokenizer.decode(outputs[0], skip_special_tokens=True)
    return response.split("### Answer:")[-1].strip()

# Example queries
print(ask("What are the arohana and avarohana of Raga Yaman, and what makes it distinct from Raga Bihag?"))
print(ask("Generate a valid melodic phrase (swara sequence) in Raga Darbari Kanada."))
print(ask("Explain the significance of Vadi and Samvadi in raga grammar."))
print(ask("What is the Pakad of Raga Bhimpalasi and what time is it traditionally performed?"))
print(ask("How does the 72 Melakarta system differ from the Thaat system?"))

Illustrative Model Outputs

Q: What distinguishes Raga Yaman from Raga Bihag?

Both Yaman and Bihag employ tivra (sharp) Ma as a defining element, which causes confusion among students of Indian classical music. However, the two ragas diverge substantially in their structural and emotional character. Yaman uses only tivra Ma in both ascent and descent, employing all seven notes in a straight scalar pattern β€” making it one of the most structurally transparent ragas in the Hindustani canon. Bihag, by contrast, uses both shuddha Ma (in descent) and tivra Ma (as a fleeting ornament in ascent), omits Re and Dha in the ascending line, and has a distinctly intimate, romantic affect compared to Yaman's expansive, twilight grandeur. Yaman is associated with early evening; Bihag is a late-night raga. The Pakad of Yaman centers on the phrase Ni Re Ga Ma' (tivra) Pa, while Bihag's characteristic phrase is Ga Ma' (tivra) Ga Ma (shuddha) Ga...

Q: What defines Raga Malkauns as a pentatonic raga?

Raga Malkauns (Hindol in some Carnatic nomenclature, though distinct from the Carnatic Malkauns) is a Audava (pentatonic) raga in the Bhairavi Thaat, using five notes: Sa, Komal Ga, Shuddha Ma, Komal Dha, and Komal Ni β€” conspicuously omitting both Re and Pa. The absence of Pancham (Pa) is particularly significant: Pa is considered the most consonant note relative to Sa (the Shadja-Pancham Bhava), and its deliberate omission creates a suspended, introspective character without a stable resting point above the tonic. Three of the five used notes are komal (flattened), lending the raga a distinctly dark, meditative, and powerful aesthetic β€” associated with Vira Rasa (heroic sentiment) and Raudra Rasa (fierce sentiment). Its Vadi is Ma and Samvadi is Sa, and it is performed in the late night hours...


Ragas Covered

Hindustani Tradition: Yaman, Yaman Kalyan, Bihag, Bhairav, Bhairavi, Todi, Multani, Darbari Kanada, Malkauns, Bhimpalasi, Bageshri, Khamaj, Marwa, Puriya, Puriya Dhanashri, Megh Malhar, Miyan ki Malhar, Kedar, Bhupali, Durga, Shree, Lalit, Hameer, Kalyan, Chhayanat, Gurjari Todi, Miyan ki Todi, Jog, and more.

Carnatic Tradition: Mayamalavagowla, Kalyani (Mechakalyani), Shankarabharanam, Hanumatodi, Kharaharapriya, Natabhairavi, Bhairavi, Mohanam, Hindolam, Charukesi, Kambhoji, Saveri, Nattai, Arabhi, Varali, Chakravakam, Hemavathi, and more.


Model Specifications

Parameter Value
Base Model LLaMA 3.2 3B (unsloth/llama-3.2-3B-bnb-4bit)
Fine-tuning Method QLoRA (Quantized Low-Rank Adaptation) via Unsloth
Quantization 4-bit NF4 with double quantization
LoRA Rank 16
LoRA Alpha 32
Target Modules q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
Training Epochs 3
Learning Rate 2e-4 (AdamW 8-bit optimizer)
Max Sequence Length 2048 tokens
Training Hardware Google Colab T4 GPU (free tier)
Dataset Size 35+ carefully curated raga lakshana instruction pairs
Prompt Format Custom system prompt + Question/Answer instruction template
Language English
License Apache 2.0

Limitations and Scope

  • Dataset scale: The current version is trained on 35+ instruction pairs β€” sufficient for foundational raga theory but limited in coverage of uncommon or regional ragas. Performance on highly specialized queries may be inconsistent.
  • Language: Responses are in English only. Swara names appear in their romanized forms. Telugu and Sanskrit terms are used where standard in musicological discourse.
  • Generative variability: The model may occasionally produce swara sequences that subtly violate a raga's Lakshana. Users with performance expertise should verify generated phrases against authoritative sources.
  • Tradition coverage: Greater emphasis is placed on prominent Hindustani ragas in this version. Carnatic coverage will expand in future iterations.
  • Not a substitute for a Guru: Indian classical music is an oral tradition. This model provides theoretical exposition, not the embodied, nuanced transmission that a human teacher provides.

Future Directions

  • Expand dataset to 500+ instruction pairs covering rare ragas, regional variants, and compositional analysis
  • Add support for Telugu and Hindi language responses
  • Develop a specialized Carnatic Lakshana variant covering the 72 Melakarta system in depth
  • Integrate Konakol/Solkattu rhythmic knowledge for a complete music theory model
  • Deploy an interactive HuggingFace Space for live raga identification and swara generation

Training Code and Dataset

Training code and data: github.com/sai-educ/indian-culture-llm


Citation

If this model contributes to your research or educational work, please cite:

@misc{RagaLakshanaLLM2026,
  author       = {sgattup},
  title        = {RagaLakshana LLM: A Fine-Tuned Language Model for Indian Classical Music Theory},
  year         = {2026},
  publisher    = {HuggingFace},
  howpublished = {\url{https://huggingface.co/sgattup/RagaLakshanaLLM}}
}

This model was developed as part of an ongoing initiative to apply modern natural language processing to the preservation, accessibility, and scholarly study of Indian classical music traditions.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support