Skip to content

251 expand preference model#252

Open
dkkdark wants to merge 11 commits into
mainfrom
251-expand-preference-model
Open

251 expand preference model#252
dkkdark wants to merge 11 commits into
mainfrom
251-expand-preference-model

Conversation

@dkkdark

@dkkdark dkkdark commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@dkkdark dkkdark linked an issue Jun 2, 2026 that may be closed by this pull request
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Current Branch Main Branch
Coverage Badge Coverage Badge

Comment thread usersimcrs/simulator/llm/prompt/stop_prompt.py Outdated
Comment thread usersimcrs/simulator/llm/prompt/utterance_generation_prompt.py Outdated
Comment thread usersimcrs/simulator/user_simulator.py Outdated
Comment thread usersimcrs/user_modeling/persona.py Outdated
Comment on lines +177 to +182
def get_preference_summary(self, max_preferences: int = 10) -> str:
"""Returns a compact preference summary for prompts."""
return ""

def update_from_dialogue(self, dialogue) -> None:
"""Updates preferences from dialogue if supported by the model."""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these be abstract?
Also, update_from_dialogue is currently empty.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: docstrings do not follow guidelines.

r"\bwithout\b.*\b{value}\b",
r"\b{value}\s+(?:heavy|packed)\b",
)
POSITIVE_PATTERNS = (

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the easiest solution so far
I think we could use llm to extract prefs in the future

continue
self._item_preferences.set_preference(KEY_ITEM_ID, item_id, rating)

def _collect_slot_value_ratings(self) -> Dict[str, Dict[str, List[float]]]:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is later used to compute the user’s long term preference score for each slot value pair


self._update_session_preference(slot, value, score)

def _update_existing_preference(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks up the current score for slot=value
checks whether the new signal is positive or negative
moves the score by one UPDATE_STEP in that direction
increments the count for that preference

preference_store.set_preference(slot, value, new_score)
preference_counts[key] = max(1, old_count) + 1

def _update_session_preference(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the session preference already exists, it updates it using the normal step-based rule
if it is new, it creates it in the session layer with an initial score of 2 * UPDATE_STEP

+ session_count
)

def _extract_matched_values(self, text_lower: str) -> List[Tuple[str, str]]:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks for known preference values already stored in the model
then it looks for possible values from the item catalog


self._apply_text_update(text)

def _rank_preferences(self) -> List[Tuple[str, str, float]]:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it combines long-term and session preferences
if the same slot=value exists in both, the session version overrides the long-term one

),
)

def get_preference_summary(self, max_preferences: int = 20) -> str:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the prompt

@dkkdark dkkdark requested a review from NoB0 June 9, 2026 17:03

@NoB0 NoB0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial comments


@abstractmethod
def get_preference_summary(self, max_preferences: int = 10) -> str:
"""Returns a compact preference summary for prompts."""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Docstring does not follow guidelines (e.g., missing args and raises sections).

Comment on lines +177 to +182
def get_preference_summary(self, max_preferences: int = 10) -> str:
"""Returns a compact preference summary for prompts."""
return ""

def update_from_dialogue(self, dialogue) -> None:
"""Updates preferences from dialogue if supported by the model."""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: docstrings do not follow guidelines.

item_collection=item_collection,
preference_model=preference_model,
)
self._preference_model = self.preference_model

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant, you can simple use self.preference_model.

Comment on lines +50 to +67
@property
def _preference_context(self) -> str:
"""Returns current preference context for the prompt."""
if not self.preference_model:
return ""

preference_summary = self.preference_model.get_preference_summary()
if not preference_summary:
return ""

return (
"USER PREFERENCES: "
f"{preference_summary}\n"
"Treat these preferences as soft background tastes, not as new "
"requirements. Use them to shape what the user accepts, "
"rejects, asks to avoid, or follows up on. Do not force every "
"liked preference into the opening request.\n"
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would be better to leave specific prompt class define the way the preferences are described in the prompt. For example, currently the stop prompt and utterance generation prompt use you while this prompt uses the user (possible misalignment and confusion for the model).

return (
self._initial_prompt
+ "\n"
+ self._preference_context

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Why note have a "\n" after like for the other elements of the prompt?

Comment on lines +79 to +81
persona_text = (
self.persona.persona_description or stringified_characteristics
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: you could avoid the creation of stringified_characteristics if the persona_description exist (similar comment for stop_prompt.py)

Comment on lines +74 to +80
def get_preference_summary(self, max_preferences: int = 10) -> str:
"""Returns an empty summary until PKG prompt support is added."""
return ""

def update_from_dialogue(self, dialogue) -> None:
"""PKG-backed dialogue updates are not implemented yet."""
return None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: docstrings do not follow guidelines.

Comment on lines +102 to +108
def get_preference_summary(self, max_preferences: int = 10) -> str:
"""Returns an empty summary for non-structured preferences."""
return ""

def update_from_dialogue(self, dialogue) -> None:
"""Simple preferences do not update from dialogue."""
return None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: docstrings do not follow guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expand Preference model

2 participants