bellafc commited on
Commit
a879288
·
verified ·
1 Parent(s): 5ddf35c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +3 -9
README.md CHANGED
@@ -47,28 +47,22 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
47
  from peft import PeftModel
48
 
49
  base_model = "microsoft/Phi-3-medium-128k-instruct"
50
- lora_model = "bellafc/IPAD/Distinguisher_PTCV" # or Distinguisher_RC
51
 
52
  tokenizer = AutoTokenizer.from_pretrained(base_model)
53
  model = AutoModelForCausalLM.from_pretrained(base_model, torch_dtype="auto", device_map="auto")
54
  model = PeftModel.from_pretrained(model, lora_model)
55
 
56
- # For RC, text should in this format: "Can LLM generate the input text {text to-be detected} through the prompt {prompt generated by Prompt Inverter (PI)}?"
57
- # For PTCV, text should in this format: "Text2 is generated by LLM, determine whether text1 is also generated by LLM with a similar prompt. Text1: {text to-be detected}. Text2: {Regenerated text}"
58
-
59
- text = "Text2 is generated by LLM, determine whether text1 is also generated by LLM with a similar prompt. Text1: ... . Text2: ... ."
60
  gen = model.generate(
61
  **inputs,
62
- max_new_tokens=10,
63
  output_scores=True,
64
  return_dict_in_generate=True
65
  )
66
 
67
  generated_text = tokenizer.decode(gen.sequences[0], skip_special_tokens=True)
68
- probs = softmax(gen.scores[0], dim=-1)
69
- yes_token_id = tokenizer(" yes", add_special_tokens=False).input_ids[0]
70
  print("Generated:", generated_text)
71
- print(f"P('yes') = {probs[0, yes_token_id].item():.4f}")
72
  ```
73
 
74
  ### 🧩 Distinguishers
 
47
  from peft import PeftModel
48
 
49
  base_model = "microsoft/Phi-3-medium-128k-instruct"
50
+ lora_model = "bellafc/IPAD/Prompt_Inverter" # or Distinguisher_RC
51
 
52
  tokenizer = AutoTokenizer.from_pretrained(base_model)
53
  model = AutoModelForCausalLM.from_pretrained(base_model, torch_dtype="auto", device_map="auto")
54
  model = PeftModel.from_pretrained(model, lora_model)
55
 
56
+ # For PI, text should in this format: "What is the prompt that generates the input text {text to-be-detected}?
57
+ text = "What is the prompt that generates the input text ... ?"
 
 
58
  gen = model.generate(
59
  **inputs,
 
60
  output_scores=True,
61
  return_dict_in_generate=True
62
  )
63
 
64
  generated_text = tokenizer.decode(gen.sequences[0], skip_special_tokens=True)
 
 
65
  print("Generated:", generated_text)
 
66
  ```
67
 
68
  ### 🧩 Distinguishers