Views
No views yet
AGNDM/Fine-tuned_NLP_Qwen_0.5BQwen/Qwen2.5-0.5B-Instructallenai/qasperpip install -U transformers peft accelerate torch1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3from peft import PeftModel
4
5base_model_id = "Qwen/Qwen2.5-0.5B-Instruct"
6adapter_id = "AGNDM/Fine-tuned_NLP_Qwen_0.5B"
7
8tokenizer = AutoTokenizer.from_pretrained(base_model_id, trust_remote_code=True)
9base_model = AutoModelForCausalLM.from_pretrained(
10 base_model_id,
11 torch_dtype=torch.float16,
12 device_map="auto"
13)
14model = PeftModel.from_pretrained(base_model, adapter_id)
15
16prompt = (
17 "You are a helpful scientific QA assistant. "
18 "Answer the question based only on the provided paper content.\n\n"
19 "### Paper Context\n"
20 "<paper context here>\n\n"
21 "### Question\n"
22 "What is the main contribution?\n\n"
23 "### Answer\n"
24)
25
26inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
27with torch.no_grad():
28 outputs = model.generate(**inputs, max_new_tokens=128, do_sample=False)
29
30print(tokenizer.decode(outputs[0], skip_special_tokens=True))Qwen/Qwen2.5-0.5B-Instructr=16, alpha=32, dropout=0.051 x gradient_accumulation_steps(16) = 1620481@inproceedings{Dasigi2021ADO,
2 title={A Dataset of Information-Seeking Questions and Answers Anchored in Research Papers},
3 author={Pradeep Dasigi and Kyle Lo and Iz Beltagy and Arman Cohan and Noah A. Smith and Matt Gardner},
4 year={2021}
5}