Views
No views yet
unsloth/tinyllama-bnb-4bit for pharmaceutical question answering, developed using a 3-stage fine-tuning pipeline with Unsloth.pharma_instruction_dataset.jsonl.pharma_preference_dataset.jsonl to align with preferred responses.unsloth/tinyllama-bnb-4bit1from unsloth import FastLanguageModel
2import torch
3
4# Load model
5model, tokenizer = FastLanguageModel.from_pretrained(
6 model_name = "ragpalgit/pharma-assistant-v3", # YOUR MODEL_ID
7 max_seq_length = 512,
8 dtype = None,
9 load_in_4bit = True,
10)
11
12# Example inference (using generate_answer helper from notebook)
13instruction = "Explain metformin in simple language."
14prompt = f"### Instruction:
15{instruction}
16
17### Response:
18"
19
20inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
21
22with torch.inference_mode():
23 output = model.generate(
24 **inputs,
25 max_new_tokens=150,
26 do_sample=True,
27 temperature=0.7,
28 top_p=0.9,
29 repetition_penalty=1.1,
30 pad_token_id=tokenizer.eos_token_id,
31 eos_token_id=tokenizer.eos_token_id,
32 )
33
34input_tokens = inputs["input_ids"].shape[-1]
35generated_tokens = output[0][input_tokens:]
36print(tokenizer.decode(generated_tokens, skip_special_tokens=True).strip())