Sparse Rewards Can Self-Train Dialogue Agents
Barrett Martin Lattimer, Varun Gangal, Ryan McDonald, Yi Yang
contact: blattimer@asapp.com
paper: https://arxiv.org/abs/2409.04617
This repo runs JOSH, the ToolWOZ, and τ-bench dataset. This repo also contains ways of logging training and preference-annotated episodes from user-simulator interactions and LORA-driven preference tuning of small LLMs from such preference annotated experience.
Setup
- Run the following in a new env
pip install josh-train
or
pip install -e .
-
Unzip the
dataset.zipfile in thedatafolder -
Set up your openai credentials
export OPENAI_API_KEY= # api_key
export OPENAI_ORGANIZATION= # api_org
If you're running Llama or another local model, you will also need to set HF_TOKEN much in the same way. Wherever you see HF_KEY please replace it by your huggingface token.
Running ToolWOZ
You can run ToolWOZ normally by doing the following
python josh_train/main.py
Increase the --max_concurrency depending on your api rate limits
JOSH on ToolWOZ
Enable JOSH on ToolWOZ by adding the --josh flag, and make the running of JOSH print updates by also adding --josh_debug
One example of a more involved JOSH prompt would be the following
python josh_train/main.py --josh --josh_debug --max_concurrency 20 --seed 20 --task_split train --temperature 1.0 --agent_strategy react --user_mode goal --model gpt-4o-mini --end_index 10 --beam_size 8
Running τ-bench
We have added a clone of τ-bench to this repo with two run files, one for normal τ-bench testing and another for JOSH rollouts on τ-bench
To run τ-bench normally you can do
python tau-bench-eval/run.py
JOSH on τ-bench
To run JOSH on τ-bench you can do
python tau-bench-eval/run.py --josh --debug
Using JOSH
A class of JOSH is provided in this repo to be very flexible and work for a wide variety of user/agent interactions. To use JOSH yourself, you can start with the following code snippet
from josh_train.josh import JOSH, BaseJOSHAgent, BaseRewards, BaseJOSHUser
def add_error_message(agent):
agent.messages.append({'role':'assistant', 'content':'Error: Agent ran out of retries.'})
return agent
def step_agent(agent:BaseJOSHAgent, **kwargs):
pass_to_customer = agent.step(**kwargs)
return agent, pass_to_customer
def step_user(user:BaseJOSHUser, agent:BaseJOSHAgent):
agent, end_conversation = user.step(agent)
return agent, end_conversation
josh = JOSH(
rewards=BaseRewards(['say hello', 'say hello', 'say hello']),
agent_step=step_agent,
user_step=step_user,
add_error_message=add_error_message,
root_agent = BaseJOSHAgent(),
user = BaseJOSHUser(),
debug=True
)
for _ in range(10):
max_reward, all_done = josh.step()
if all_done:
break
print(max_reward)
print(josh.training_examples)
All classes can be built on top of, and expanded for further use.
MT-Bench
(If you want to later evaluate MTBench)
unzip mtbencheval.zip
Citation
Please cite if you enjoyed this work!
@article{lattimer2024sparse,
title={Sparse Rewards Can Self-Train Dialogue Agents},
author={Lattimer, Barrett Martin and Gangal, Varun and McDonald, Ryan and Yang, Yi},
journal={arXiv preprint arXiv:2409.04617},
year={2024}
}
Metadata
Release files for josh-train 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| josh_train-0.1.4.tar.gz | 25.2 MB | Without provenance | Details for josh_train-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| josh_train-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for josh_train-0.1.4-py3-none-any.whl |
Total release size: 50.4 MB
Release files / josh_train-0.1.4.tar.gz
| Download URL | josh_train-0.1.4.tar.gz |
|---|---|
| Size | 25.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d7186a185795f5f49f27961e509a45dbc22b30737184836a03a8f14e837adfda
|
|
BLAKE2b-256 checksum How to use checksums |
a36cd5638f90588c59651daadd9ef410b7dd753931bec9c6ec49f7643a1232a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.6
|
Release files / josh_train-0.1.4-py3-none-any.whl
| Download URL | josh_train-0.1.4-py3-none-any.whl |
|---|---|
| Size | 25.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e905d1d28e28cb809011d3b5651ecb45eda5721df08cd1126d50c4990af205fa
|
|
BLAKE2b-256 checksum How to use checksums |
319992aef5ac6b47503853b14f9c17e37a0f464b68be35b7a160d5b220a4a164
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.6
|
Security for josh-train 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.