Skip to content

251 expand preference model#252

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

251 expand preference model#252
dkkdark wants to merge 15 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 thread usersimcrs/user_modeling/preference_model.py Outdated
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 thread usersimcrs/user_modeling/preference_model.py Outdated
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 thread usersimcrs/simulator/llm/prompt/prompt.py
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 thread usersimcrs/user_modeling/pkg_preference_model.py
Comment thread usersimcrs/user_modeling/simple_preference_model.py
Comment thread usersimcrs/user_modeling/structured_preference_model.py
Comment on lines +24 to +58
NEGATIVE_PATTERNS = (
r"\b(?:avoid|nothing|not|no|without|not into|not too|too much)\b.*"
r"\b{value}\b",
r"\bnot interested in\b.*\b{value}\b",
r"\b(?:anything but|other than|except|rather than)\b.*\b{value}\b",
r"\bnot a[n]?\b.*\b{value}\b",
r"\bnot in\b.*\b{value}\b(?:\s+genre)?\b",
r"\bwithout\b.*\b{value}\b",
r"\b{value}\s+(?:heavy|packed)\b",
)
POSITIVE_PATTERNS = (
r"\b(?:like|love|prefer|enjoy)\b.*\b{value}\b",
r"\blooking for\b.*\b{value}\b",
r"\binterested in\b.*\b{value}\b",
r"\breally looking for\b.*\b{value}\b",
r"\bcan you recommend\b.*\b{value}\b",
r"\bcould you suggest\b.*\b{value}\b",
r"\b(?:with|about|featuring|set in|centered around|based on)\b.*"
r"\b{value}\b",
r"\bthemes? of\b.*\b{value}\b",
r"\bmore\b.*\b{value}\b",
r"\bwithin the\b.*\b{value}\b(?:\s+genre)?\b",
r"\bin the\b.*\b{value}\b(?:\s+genre)?\b",
r"\b{value}\b.*\bover other genres\b",
r"\b{value}\s+focused\b",
)
DIALOGUE_STOP_TOKENS = {
"exit",
"goodbye",
"bye",
"quit",
"stop",
"end",
"giveup",
}

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 this could be used for initialisation of preferences based on historical dialogues, particularly interesting in a scenario with multiple session.

Comment thread usersimcrs/user_modeling/structured_preference_model.py Outdated
Comment thread usersimcrs/user_modeling/structured_preference_model.py Outdated
Comment thread usersimcrs/user_modeling/structured_preference_model.py Outdated
Comment thread usersimcrs/user_modeling/structured_preference_model.py Outdated
@dkkdark dkkdark requested a review from NoB0 July 14, 2026 15:46
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