Views
No views yet
1conda create --name hard2softPPO python=3.10
2conda activate hard2softPPO
3
4git clone https://github.com/yasaisen/hardPrompt2softPrompt.git
5pip install torch==2.4.1 torchvision==0.19.1 torchaudio==2.4.1 --index-url https://download.pytorch.org/whl/cu121
6pip install transformers==4.51.3, matplotlib
7
8huggingface-cli login1from hardPrompt2softPrompt.models.policyModel.modeling_policyModel import PrefixTuningPolicyModel
2
3model = PrefixTuningPolicyModel.from_pretrained(
4 model_name='google/gemma-3-1b-it',
5)
6
7messages = [
8 {
9 "role": "user",
10 "content": [{"type": "text", "text": '你覺得 YouTube 頻道中,最吸引你的類型是哪一種呢?'},]
11 }
12]
13
14messages_ids = model.chat_template_tokenizer(
15 messages=messages
16)
17
18response = model.generate_response(
19 messages_ids=messages_ids,
20 temperature=0.7,
21)
22print(response)