Views
No views yet
1from huggingface_hub import login
2from transformers import AutoTokenizer, AutoModelForCausalLM
3from peft import PeftModel
4
5
6tokenizer = AutoTokenizer.from_pretrained("unsloth/SmolLM2-1.7B-Instruct",)
7base_model = AutoModelForCausalLM.from_pretrained(
8 "unsloth/SmolLM2-1.7B-Instruct",
9 device_map={"": 0}
10)
11
12model = PeftModel.from_pretrained(base_model,"DSTI/DS-RLHF-1.7B")
13
14
15prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
16
17### Instruction:
18{}
19
20### Input:
21{}
22
23### Response:
24{}"""
25
26
27inputs = tokenizer(
28 [
29 prompt.format(
30 "You are an AI assistant that helps people find information",
31 "What is the k-Means Clustering algorithm and what is it's purpose?",
32 "",
33 )
34 ],
35 return_tensors="pt",
36).to("cuda")
37
38
39from transformers import TextStreamer
40
41text_streamer = TextStreamer(tokenizer)
42_ = model.generate(**inputs, streamer=text_streamer, max_new_tokens=1800)1@misc{DS-RLHF-1.7B,
2 title = {ORPO (Odds Ratio Preference Optimization) on data science–related samples},
3 author = {Rustam Shiriyev},
4 year = {2025}
5}