Views
No views yet
.png)
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4# Load tokenizer and model
5model_name = "bharatgenai/Param-1-2.9B-Instruct"
6tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=False)
7model = AutoModelForCausalLM.from_pretrained(
8 model_name,
9 trust_remote_code=True,
10 device_map="auto"
11)
12
13# Conversation Input
14conversation = [
15 {
16 "content": "You are helpful assistant.",
17 "role": "system"
18 },
19 {
20 "content": "What is the BharatGen Mission?",
21 "role": "user"
22 }
23]
24
25# padding special token
26inputs = tokenizer.apply_chat_template(
27 conversation=conversation,
28 return_tensors="pt",
29 add_generation_prompt=True
30)
31inputs = inputs.to(model.device)
32
33# --- Generate output ---
34with torch.no_grad():
35 output = model.generate(
36 inputs,
37 max_new_tokens=300,
38 do_sample=True,
39 top_k=50,
40 top_p=0.95,
41 temperature=0.6,
42 eos_token_id=tokenizer.eos_token_id,
43 use_cache=False
44 )
45
46# Get only the generated tokens (exclude the prompt length)
47generated_tokens = output[0][inputs.shape[-1]:]
48generated_text = tokenizer.decode(generated_tokens, skip_special_tokens=True)
49
50print("Assistant Output:\n", generated_text)| Task | Param 1 (PT) | Gemma2-2B (PT) | llama3.2-3B (distill PT) | granite-3.1-2B (PT) | granite-3.1-3B (PT) | qwen-2.5-3B (PT) |
|---|---|---|---|---|---|---|
| ARC Challenge | 46.7 | 49.7 | 46.0 | 47.2 | 45.2 | 47.4 |
| ARC Easy | 74.6 | 80.3 | 71.7 | 76.8 | 75.8 | 73.2 |
| HellaSwag | 71.4 | 73.0 | 73.7 | 75.5 | 72.6 | 73.6 |
| HellaSwag Hi | 44.1 | 38.6 | 40.0 | 31.0 | 28.5 | 32.9 |
| MMLU En | 41.4 | 47.1 | 53.9 | 47.8 | 41.0 | 64.9 |
| MMLU Hi | 30.7 | 30.0 | 35.0 | 29.0 | 25.7 | 38.32 |
| PIQA | 79.3 | 78.3 | 77.31 | 79.4 | 78.2 | 78.84 |
| TriviaQA | 38.5 | 32.9 | 50.83 | 26.2 | 27.5 | 42.27 |
| TruthfulQA - Gen (BLEU) | 38.2 | 29.7 | 21.8 | 34.0 | 36.7 | 36.96 |
| TruthfulQA - MC1 Acc | 28.0 | 24.0 | 25.3 | 26.1 | 26.4 | 32.07 |
| TruthfulQA - MC2 Acc | 43.8 | 36.2 | 39.2 | 39.0 | 39.9 | 48.95 |
| SuperGLUE - boolq | 70.6 | 73.7 | 72.7 | 71.0 | 68.5 | 77.27 |
| SuperGLUE - rte | 62.5 | 61.7 | 54.5 | 69.3 | 54.9 | 75.09 |
| SuperGLUE - WiC | 49.5 | 49.5 | 50.0 | 50.3 | 52.3 | 61.75 |
| SuperGLUE - multirc | 56.9 | 55.9 | 57.2 | 57.2 | 57.2 | 39.52 |
Notes:
- Benchmarks reflect zero-shot performance post-SFT.
- PT = Pretrained