Downloads · 30 days
9
1% of all-time downloads
Anxo/erisk26-task1-patient-06-adapter
erisk26-task1-patient-06-adapter is a text generation model from Anxo. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as other.
This repository contains a PEFT/LoRA adapter for a simulated patient persona intended for eRisk 2026 Task 1.
Downloads · 30 days
9
1% of all-time downloads
All-time downloads
952
Public
Repo size
99.3 MB
Likes
0
Public
Click a slice to open those files.
.pt54.7 MB · 38%
From the Hugging Face model README
This repository contains a PEFT/LoRA adapter for a simulated patient persona intended for eRisk 2026 Task 1.
This adapter is designed to be used with:
meta-llama/Meta-Llama-3-8B-Instruct⚠️ The base model is typically gated. Participants must have access to the base model on Hugging Face and be authenticate.
For eRisk 2026 Task 1, participants must NOT modify the system prompt below.
This is part of the task protocol to ensure comparable behavior across participants.
Use exactly:
"You are a simulated patient. Act realistically based on your internal training. Ensure contextual realism. Avoid overly detailed or formal speech. Keep natural speaking style (e.g., short answers, hesitations, casual expressions). Do not mention you are an AI."
Notes:
adapter_model.safetensors / adapter_config.jsonPeftModel.from_pretrained(...).conv_interact.pypip install -U "transformers>=4.40" peft accelerate torch
hf auth login
python conv_interact.py
Below is a minimal snippet showing how to load the base model + this adapter.
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
# --- CONFIGURATION ---
BASE_MODEL_ID = "meta-llama/Meta-Llama-3-8B-Instruct"
ADAPTER_PATH = "<REPLACE_WITH_THIS_REPO_NAME>"
# 1. Load Tokenizer & Fix Padding
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL_ID)
tokenizer.pad_token_id = tokenizer.eos_token_id
tokenizer.padding_side = 'left' # Crucial for generation
# 2. Load Base Model (Force float16 for compatibility)
base_model = AutoModelForCausalLM.from_pretrained(
BASE_MODEL_ID,
torch_dtype=torch.float16,
device_map="auto",
)
# 3. Load the Patient Adapter
print(f"Loading Adapter from {ADAPTER_PATH}...")
model = PeftModel.from_pretrained(base_model, ADAPTER_PATH)
# 4. Initialize History with the "Generic" Prompt
# DO NOT CHANGE SYSTEM PROMPT. It is crucial for ensuring the patient behaves as intended.
# Important: IT WILL BE CONSIDERED AS CHEATING!!
messages = [
{"role": "system", "content": "You are a simulated patient. Act realistically based on your internal training. Ensure contextual realism. Avoid overly detailed or formal speech. Keep natural speaking style (e.g., short answers, hesitations, casual expressions). Do not mention you are an AI."},
]
terminators = [
tokenizer.eos_token_id,
tokenizer.convert_tokens_to_ids("<|eot_id|>")
]
print("--- Patient Loaded. Type 'quit' to exit. ---")
while True:
user_input = input("Doctor: ")
if user_input.lower() == 'quit':
break
# 1. Update history
messages.append({"role": "user", "content": user_input})
# 2. Format history & Create Attention Mask
# return_dict=True gives us the 'attention_mask' automatically
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt",
return_dict=True
).to(model.device)
# 3. Generate response
# explicitly passing attention_mask prevents the warning you saw earlier
with torch.no_grad():
outputs = model.generate(
input_ids=inputs.input_ids,
attention_mask=inputs.attention_mask,
max_new_tokens=256,
eos_token_id=terminators,
pad_token_id=tokenizer.eos_token_id,
do_sample=True,
temperature=0.6,
top_p=0.9,
)
# 4. Decode response
# We slice [input_len:] to ensure we don't print the prompt back to the user
response_tokens = outputs[0][inputs.input_ids.shape[-1]:]
assistant_text = tokenizer.decode(response_tokens, skip_special_tokens=True)
print(f"Patient: {assistant_text}")
# 5. Append assistant response to history
messages.append({"role": "assistant", "content": assistant_text})
To reduce run-to-run variability during development:
do_sample=False for deterministic debugging (not necessarily for final experiments)meta-llama/Meta-Llama-3-8B-Instruct.If you use this adapter in academic work, please cite the eRisk overview paper and/or the task description as appropriate.
Maintained by IRLab-UDC (eRisk organizers).
For issues, open a GitHub/HF issue in the corresponding repository or contact the task organizers.