Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- uses: actions/setup-python@v4
with:
python-version: "3.9"
python-version: "3.11"
cache: "pip"

- name: Install Dependencies
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:

- uses: actions/setup-python@v4
with:
python-version: "3.9"
python-version: "3.11"
cache: "pip"

- name: Install Dependencies
Expand All @@ -66,7 +66,7 @@ jobs:
run: pre-commit run mypy --all-file

build-and-test:
name: "Build and Test Python 3.9"
name: "Build and Test Python 3.11"
runs-on: ubuntu-latest
if: always()
timeout-minutes: 20
Expand All @@ -76,7 +76,7 @@ jobs:
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: "3.9"
python-version: "3.11"
cache: "pip"

- name: Install Dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.9.15
python-version: 3.11
cache: "pip"
- name: Installing the Documentation requirements
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
build-and-test:
name: "Build and Test Python 3.9"
name: "Build and Test Python 3.11"
runs-on: ubuntu-latest
if: always()
timeout-minutes: 20
Expand All @@ -16,7 +16,7 @@ jobs:
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: "3.9"
python-version: "3.11"
cache: "pip"

- name: Install Dependencies
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repos:
rev: 22.6.0
hooks:
- id: black
language_version: python3.9
language_version: python3.11
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
![docs](https://img.shields.io/github/actions/workflow/status/iai-group/UserSimCRS/build_docs.yaml?label=docs&branch=main)
![Tests](https://img.shields.io/github/actions/workflow/status/iai-group/UserSimCRS/merge.yaml?label=Tests&branch=main)
![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/NoB0/cd558f4b76df656b67277f8ae214b7e0/raw/coverage.UserSimCRS.main.json)
![Python version](https://img.shields.io/badge/python-3.9-blue)
![Python version](https://img.shields.io/badge/python-3.11-blue)

UserSimCRS is an extensible user simulation toolkit for evaluating conversational recommender systems.

Expand All @@ -29,7 +29,7 @@ We refer to the [documentation](https://iai-group.github.io/UserSimCRS/main) for

## Installation

The recommended version of Python is 3.9.
UserSimCRS requires Python 3.11+.
The easiest way to install UserSimCRS and all of its dependencies is by using pip:

```shell
Expand Down
2 changes: 0 additions & 2 deletions config/default/config_default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,4 @@ historical_ratings_ratio: 0.8

dialogues: data/datasets/moviebot/annotated_dialogues.json
intent_classifier: "cosine"
# If using the DIET classifier the following file needs to be provided.
# rasa_dialogues: data/agents/moviebot/annotated_dialogues_rasa_agent.yml

18 changes: 6 additions & 12 deletions data/datasets/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
# Dialogue files

The YAML files required to train the Rasa DIET classifier can be generated from the annotated dialogues saved in the correct format.
The generation of these files can be done with this command:
This folder contains dialogue files used for configuring a user simulator. For each dataset supported, annotated dialogues in JSON format are provided, along with prompts for LLM-based NLU and NLG components.

```shell
cd usersimcrs/utils
python -m annotation_converter_rasa -source PathToAnnotatedDialoguesFile -destination PathToDestinationFolder
```
The datasets currently supported are:

It creates the following files:

- `<originalname>_reformat.yaml`: The original file saved as a yaml file
- `<originalname>_types_w_examples.yaml`: Slots and example values extracted from the dialogues
- `<originalname>_rasa_agent.yaml`: Examples of agent utterances for all possible intents/actions that the agent can take
- `<originalname>_rasa_user.yaml`: Similar to the agent file, but for users
* MovieBot: dialogues related to movie recommendations obtained with IAI MovieBot v1.
* [ReDial](https://redialdata.github.io/website/): dialogues related to movie recommendations obtained with crowdsourcing.
* [IARD](https://github.com/wanlingcai1997/umap_2020_IARD): subset of ReDial dialogues related to movie recommendations.
* [INSPIRED](https://github.com/sweetpeach/Inspired): dialogues related to movie recommendations obtained with crowdsourcing.
3 changes: 0 additions & 3 deletions docs/source/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Simulator parameters
* `historical_ratings_ratio`: Ratio ([0..1]) of ratings to be used as historical data.
* `dialogues`: Path to domain config file.
* `intent_classifier`: Intent classifier model to be used. Only supports DialogueKit intent classifiers.
* `rasa_dialogues`: File with Rasa annotated dialogues. Only needed when using a DIET intent classifier.
* `debug`: Flag (boolean) to activate debug mode.

Configuration example
Expand Down Expand Up @@ -71,8 +70,6 @@ Below is the default configuration to run simulation with the IAI MovieBot as th

dialogues: data/agents/moviebot/annotated_dialogues.json
intent_classifier: "cosine"
# If using the DIET classifier the following file needs to be provided.
# rasa_dialogues: data/agents/moviebot/annotated_dialogues_rasa_agent.yml

debug: False

2 changes: 1 addition & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Installation
============

The recommended version of Python is 3.9.
UserSimCRS requires Python 3.11+.
The easiest way to install UserSimCRS and all of its dependencies is by using pip:

.. code-block:: shell
Expand Down
3 changes: 2 additions & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ torch==2.0.1
openai==1.30.5
ollama==0.3.1
pandas==2.2.2
git+https://github.com/iai-group/DialogueKit.git
dialoguekit==0.1.1
scikit-learn >= 0.24
setuptools<=70.0.0
4 changes: 2 additions & 2 deletions usersimcrs/core/information_need.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def generate_random_information_need(
target_item.properties.keys()
)
num_constraints = random.randint(1, len(informable_slots))
for slot in random.sample(informable_slots, num_constraints):
for slot in random.sample(list(informable_slots), num_constraints):
constraints[slot] = target_item.get_property(slot)

requestable_slots = set(
domain.get_requestable_slots()
).symmetric_difference(constraints.keys())
num_requests = random.randint(1, len(requestable_slots))
requests = random.sample(requestable_slots, num_requests)
requests = random.sample(list(requestable_slots), num_requests)

return InformationNeed([target_item], constraints, requests)

Expand Down
2 changes: 1 addition & 1 deletion usersimcrs/items/ratings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def user_item_sampler(
"""
# Determine the number of items to use as historical data for a given user.
nb_historical_items = int(historical_ratio * len(item_ratings))
return random.sample(item_ratings.keys(), nb_historical_items)
return random.sample(list(item_ratings.keys()), nb_historical_items)


class Ratings:
Expand Down
5 changes: 0 additions & 5 deletions usersimcrs/run_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@ def parse_args() -> argparse.Namespace:
choices=["cosine", "diet"],
help="Intent classifier model to be used. Defaults to cosine.",
)
parser.add_argument(
"--rasa_dialogues",
type=str,
help="Path to the Rasa annotated dialogues file.",
)
parser.add_argument(
"-d",
"--debug",
Expand Down
34 changes: 0 additions & 34 deletions usersimcrs/utils/annotation_converter_rasa.py

This file was deleted.

41 changes: 2 additions & 39 deletions usersimcrs/utils/simulation_utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""Utility functions to run the simulation."""

import json
from typing import Any, Dict, Set, Tuple, Type
from typing import Any, Dict, Tuple, Type

import confuse
import yaml
from dialoguekit.core.intent import Intent
from dialoguekit.core.utterance import Utterance
from dialoguekit.nlg import ConditionalNLG
Expand All @@ -16,7 +15,6 @@
DisjointDialogueActExtractor,
)
from dialoguekit.nlu.intent_classifier import IntentClassifier
from dialoguekit.nlu.models.diet_classifier_rasa import IntentClassifierRasa
from dialoguekit.nlu.models.intent_classifier_cosine import (
IntentClassifierCosine,
)
Expand Down Expand Up @@ -131,7 +129,7 @@ def _get_agenda_based_simulator_config(

ratings = Ratings(item_collection)
ratings.load_ratings_csv(file_path=config["ratings"].get())
historical_ratings, ground_truth_ratings = ratings.create_split(
historical_ratings, _ = ratings.create_split(
config["historical_ratings_ratio"].get(0.8)
)

Expand Down Expand Up @@ -200,9 +198,6 @@ def get_NLU(config: confuse.Configuration) -> NLU:
return NLU(
DisjointDialogueActExtractor(classifier, slot_value_annotators=[])
)
elif intent_classifier == "diet":
classifier = train_rasa_diet_classifier(config)
return NLU(DisjointDialogueActExtractor(classifier, [classifier]))
raise ValueError(
"Unsupported intent classifier. Check DialogueKit intent"
" classifiers."
Expand Down Expand Up @@ -242,35 +237,3 @@ def train_cosine_classifier(
intent_classifier = IntentClassifierCosine(intents=gt_intents)
intent_classifier.train_model(utterances=utterances, labels=gt_intents)
return intent_classifier


def train_rasa_diet_classifier(
config: confuse.Configuration,
) -> IntentClassifierRasa:
"""Trains a DIET classifier on Rasa annotated dialogues for NLU module.

Args:
config: Configuration generated from YAML configuration file.

Returns:
A trained Rasa DIET model for intent classification.
"""
# TODO: Move to DialogueKit as util function.
# See: https://github.com/iai-group/UserSimCRS/issues/92
intent_schema_file = config["intents"].get()
intent_schema = yaml.load(open(intent_schema_file), Loader=yaml.FullLoader)

agent_intents_str: Set[str] = set()
for v in intent_schema["user_intents"].values():
intents = v.get("expected_agent_intents", []) or []
agent_intents_str.update(intents)
# agent_intents_str = intent_schema["agent_elicit_intents"]
# agent_intents_str.extend(intent_schema["agent_set_retrieval"])
agent_intents = [Intent(intent) for intent in agent_intents_str]
intent_classifier = IntentClassifierRasa(
agent_intents,
config["rasa_dialogues"].get(),
".rasa",
)
intent_classifier.train_model()
return intent_classifier
Loading