Instructions to use ai4bharat/Airavata with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ai4bharat/Airavata with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ai4bharat/Airavata")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ai4bharat/Airavata") model = AutoModelForCausalLM.from_pretrained("ai4bharat/Airavata") - llama-cpp-python
How to use ai4bharat/Airavata with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="ai4bharat/Airavata", filename="Airavata.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use ai4bharat/Airavata with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf ai4bharat/Airavata # Run inference directly in the terminal: llama-cli -hf ai4bharat/Airavata
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf ai4bharat/Airavata # Run inference directly in the terminal: llama-cli -hf ai4bharat/Airavata
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf ai4bharat/Airavata # Run inference directly in the terminal: ./llama-cli -hf ai4bharat/Airavata
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf ai4bharat/Airavata # Run inference directly in the terminal: ./build/bin/llama-cli -hf ai4bharat/Airavata
Use Docker
docker model run hf.co/ai4bharat/Airavata
- LM Studio
- Jan
- vLLM
How to use ai4bharat/Airavata with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ai4bharat/Airavata" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ai4bharat/Airavata", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ai4bharat/Airavata
- SGLang
How to use ai4bharat/Airavata with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ai4bharat/Airavata" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ai4bharat/Airavata", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ai4bharat/Airavata" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ai4bharat/Airavata", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Ollama
How to use ai4bharat/Airavata with Ollama:
ollama run hf.co/ai4bharat/Airavata
- Unsloth Studio new
How to use ai4bharat/Airavata with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for ai4bharat/Airavata to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for ai4bharat/Airavata to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for ai4bharat/Airavata to start chatting
- Docker Model Runner
How to use ai4bharat/Airavata with Docker Model Runner:
docker model run hf.co/ai4bharat/Airavata
- Lemonade
How to use ai4bharat/Airavata with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull ai4bharat/Airavata
Run and chat with the model
lemonade run user.Airavata-{{QUANT_TAG}}List all available models
lemonade list
Airavata
This model is a 7B OpenHathi model finetuned on IndicInstruct dataset which is a collection of instruction datasets (Anudesh, wikiHow, Flan v2, Dolly, Anthropic-HHH, OpenAssistant v1, and LymSys-Chat). Please check the corresponding huggingface dataset card for more details.
This was trained as part of the technical report Airavata: Introducing Hindi Instruction-tuned LLM. The codebase used to train and evaluate this model can be found at https://github.com/AI4Bharat/IndicInstruct.
Usage
Clone https://github.com/AI4Bharat/IndicInstruct and install the required dependencies. Then download or clone this model to the same machine.
Input Format
The model is trained to use the chat format similar to open-instruct code repository (note the newlines):
<|user|>
Your message here!
<|assistant|>
For best results, format all inputs in this manner. Make sure to include a newline after <|assistant|>, this can affect generation quality quite a bit.
Hyperparameters
We fine-tune OpenHathi base model on the aforementioned IndicInstruct dataset with LoRA. The hyperparameters for the LoRA fine-tuning are listed below:
- LoRA Rank: 16
- LoRA alpha: 32
- LoRA Dropout: 0.05
- LoRA Target Modules: ["q_proj", "v_proj", "k_proj", "down_proj", "gate_proj", "up_proj"]
- Epochs: 4
- Learning rate: 5e-4
- Batch Size: 128
- Floating Point Precision: bfloat16
We recommend the readers to check out our official blog post for more details on the model training, ablations and evaluation results.
Example
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
device = "cuda" if torch.cuda.is_available() else "cpu"
def create_prompt_with_chat_format(messages, bos="<s>", eos="</s>", add_bos=True):
formatted_text = ""
for message in messages:
if message["role"] == "system":
formatted_text += "<|system|>\n" + message["content"] + "\n"
elif message["role"] == "user":
formatted_text += "<|user|>\n" + message["content"] + "\n"
elif message["role"] == "assistant":
formatted_text += "<|assistant|>\n" + message["content"].strip() + eos + "\n"
else:
raise ValueError(
"Tulu chat template only supports 'system', 'user' and 'assistant' roles. Invalid role: {}.".format(
message["role"]
)
)
formatted_text += "<|assistant|>\n"
formatted_text = bos + formatted_text if add_bos else formatted_text
return formatted_text
def inference(input_prompts, model, tokenizer):
input_prompts = [
create_prompt_with_chat_format([{"role": "user", "content": input_prompt}], add_bos=False)
for input_prompt in input_prompts
]
encodings = tokenizer(input_prompts, padding=True, return_tensors="pt")
encodings = encodings.to(device)
with torch.inference_mode():
outputs = model.generate(encodings.input_ids, do_sample=False, max_new_tokens=250)
output_texts = tokenizer.batch_decode(outputs.detach(), skip_special_tokens=True)
input_prompts = [
tokenizer.decode(tokenizer.encode(input_prompt), skip_special_tokens=True) for input_prompt in input_prompts
]
output_texts = [output_text[len(input_prompt) :] for input_prompt, output_text in zip(input_prompts, output_texts)]
return output_texts
model_name = "ai4bharat/Airavata"
tokenizer = AutoTokenizer.from_pretrained(model_name, padding_side="left")
tokenizer.pad_token = tokenizer.eos_token
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16).to(device)
input_prompts = [
"मैं अपने समय प्रबंधन कौशल को कैसे सुधार सकता हूँ? मुझे पांच बिंदु बताएं।",
"मैं अपने समय प्रबंधन कौशल को कैसे सुधार सकता हूँ? मुझे पांच बिंदु बताएं और उनका वर्णन करें।",
]
outputs = inference(input_prompts, model, tokenizer)
print(outputs)
Citation
@article{gala2024airavata,
title = {Airavata: Introducing Hindi Instruction-tuned LLM},
author = {Jay Gala and Thanmay Jayakumar and Jaavid Aktar Husain and Aswanth Kumar M and Mohammed Safi Ur Rahman Khan and Diptesh Kanojia and Ratish Puduppully and Mitesh M. Khapra and Raj Dabre and Rudra Murthy and Anoop Kunchukuttan},
year = {2024},
journal = {arXiv preprint arXiv: 2401.15006}
}
Open LLM Leaderboard Evaluation Results
Detailed results can be found here
| Metric | Value |
|---|---|
| Avg. | 45.52 |
| AI2 Reasoning Challenge (25-Shot) | 46.50 |
| HellaSwag (10-Shot) | 69.26 |
| MMLU (5-Shot) | 43.90 |
| TruthfulQA (0-shot) | 40.62 |
| Winogrande (5-shot) | 68.82 |
| GSM8k (5-shot) | 4.02 |
- Downloads last month
- 671
Model tree for ai4bharat/Airavata
Dataset used to train ai4bharat/Airavata
Spaces using ai4bharat/Airavata 9
Paper for ai4bharat/Airavata
Evaluation results
- normalized accuracy on AI2 Reasoning Challenge (25-Shot)test set Open LLM Leaderboard46.500
- normalized accuracy on HellaSwag (10-Shot)validation set Open LLM Leaderboard69.260
- accuracy on MMLU (5-Shot)test set Open LLM Leaderboard43.900
- mc2 on TruthfulQA (0-shot)validation set Open LLM Leaderboard40.620
- accuracy on Winogrande (5-shot)validation set Open LLM Leaderboard68.820
- accuracy on GSM8k (5-shot)test set Open LLM Leaderboard4.020