Vastu Shastra QA Model

A fine-tuned version of LFM2.5-1.2B-Instruct for answering questions about Vastu Shastra, the traditional Indian system of architecture and space design.

What it does

This model is trained to answer questions about Vastu Shastra principles using retrieved context from authoritative Vastu texts. It is designed to work in a RAG (Retrieval Augmented Generation) pipeline where relevant text chunks are retrieved and passed alongside the user's question.

Training involved two stages:

  • SFT (Supervised Fine-Tuning) on Vastu QA pairs in RAFT format
  • DPO (Direct Preference Optimization) to align responses toward detailed, grounded answers and away from vague or hallucinated ones

How to use

Installation

pip install transformers peft torch

Inference

from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch

base_model_id = "LiquidAI/LFM2.5-1.2B-Instruct"
adapter_id = "Prahaladha/vastu-lfm2-dpo"

tokenizer = AutoTokenizer.from_pretrained(base_model_id, trust_remote_code=True)

base_model = AutoModelForCausalLM.from_pretrained(
    base_model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True,
)
model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()

def ask_vastu(question, retrieved_chunk):
    user_content = f"""{question}

Here are the relevant excerpts from the Vastu scripture to answer the question:
<vastu_doc>
{retrieved_chunk}
</vastu_doc>"""

    messages = [{"role": "user", "content": user_content}]
    prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
    inputs = tokenizer(prompt, return_tensors="pt").to(model.device)

    with torch.no_grad():
        outputs = model.generate(
            **inputs,
            max_new_tokens=300,
            temperature=0.7,
            do_sample=True,
            pad_token_id=tokenizer.eos_token_id,
        )

    return tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)

# Example
chunk = "The kitchen should be placed in the Southeast direction as it is governed by Agni (fire element)..."
answer = ask_vastu("Where should the kitchen be placed?", chunk)
print(answer)

With your own RAG pipeline

The model expects the retrieved Vastu chunk to be injected inside <vastu_doc> tags in the user message. At inference time your pipeline should:

  1. Embed the user query
  2. Retrieve the top-k relevant chunks from your Vastu vector store
  3. Pass question + retrieved chunk to the model as shown above

Limitations

  • Designed for Vastu Shastra domain only — general questions outside this domain may not be answered well
  • Works best when a relevant retrieved chunk is provided — without context quality degrades
  • Trained on English translations of Vastu texts only
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

Model tree for Prahaladha/vastu-lfm2-dpo

Finetuned
(149)
this model