YAML Metadata Warning:The pipeline tag "text2text-generation" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-ranking, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, image-text-to-image, image-text-to-video, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, video-to-video, other
Sanskrit D3PM Encoder-Decoder Model
Roman/IAST Sanskrit input to Devanagari output using a custom D3PM checkpoint.
This package is configured for the d3pm_encoder_decoder checkpoint stored in
best_model.pt.
Hugging Face model repo: bhsinghgrid/devflow2
Files Included
best_model.pt— trained checkpointmodel_settings.json— packaged runtime metadataconfig.py— runtime configinference.py— model loading + generation loopinference_api.py— simple Python API (predict)handler.py— Hugging Face Endpoint handlermodel/,diffusion/— architecture modulessanskrit_src_tokenizer.json,sanskrit_tgt_tokenizer.json— tokenizers
Quick Local Test
from inference_api import predict
print(predict("dharmo rakṣati rakṣitaḥ")["output"])
Runtime Settings
For local/API usage, the runtime first reads model_settings.json, then allows
optional environment variable overrides:
HF_MODEL_TYPE=d3pm_cross_attentionord3pm_encoder_decoderHF_INCLUDE_NEG=trueorfalseHF_NUM_STEPS= diffusion step count for the packaged checkpoint
Packaged settings for this repo:
export HF_MODEL_TYPE=d3pm_encoder_decoder
export HF_INCLUDE_NEG=false
export HF_NUM_STEPS=4
Use This Model In A Hugging Face Space
In your Space settings, set:
HF_CHECKPOINT_REPO=bhsinghgrid/devflow2HF_CHECKPOINT_FILE=best_model.pt
If your Space reads model metadata automatically, no extra model-type variables are required. If it does not, also set:
HF_DEFAULT_MODEL_TYPE=d3pm_encoder_decoder
HF_DEFAULT_INCLUDE_NEG=false
HF_DEFAULT_NUM_STEPS=4
Transformer-Style Usage (Custom Runtime)
This checkpoint is a custom D3PM architecture (.pt), not a native transformers
AutoModel format. Use it via the provided runtime:
import torch
from config import CONFIG
from inference import load_model, run_inference, _decode_clean
from model.tokenizer import SanskritSourceTokenizer, SanskritTargetTokenizer
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model, cfg = load_model("best_model.pt", CONFIG, device)
src_tok = SanskritSourceTokenizer(vocab_size=16000, max_len=cfg["model"]["max_seq_len"])
tgt_tok = SanskritTargetTokenizer(vocab_size=16000, max_len=cfg["model"]["max_seq_len"])
text = "dharmo rakṣati rakṣitaḥ"
ids = torch.tensor([src_tok.encode(text)], dtype=torch.long, device=device)
out = run_inference(model, ids, cfg)
print(_decode_clean(tgt_tok, out[0].tolist()))
If you need full transformers compatibility (AutoModel.from_pretrained),
export weights to a Hugging Face Transformers model format first.
Endpoint Payload
{
"inputs": "yadā mano nivarteta viṣayebhyaḥ svabhāvataḥ",
"parameters": {
"temperature": 0.7,
"top_k": 40,
"repetition_penalty": 1.2,
"diversity_penalty": 0.0,
"num_steps": 4,
"clean_output": true
}
}
Push This Folder To Model Hub
cd hf_model_repo_encoder_decoder
git add .
git commit -m "Add encoder-decoder T4 model package"
git push -u hf main