-
Notifications
You must be signed in to change notification settings - Fork 26.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add trajectory transformer #17141
Merged
LysandreJik
merged 4 commits into
huggingface:main
from
CarlCochet:add_trajectory_transformer
May 17, 2022
Merged
Add trajectory transformer #17141
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.py eol=lf | ||
*.rst eol=lf | ||
*.md eol=lf | ||
*.md eol=lf | ||
*.mdx eol=lf | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<!--Copyright 2022 The HuggingFace Team. All rights reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations under the License. | ||
--> | ||
|
||
# Trajectory Transformer | ||
|
||
## Overview | ||
|
||
The Trajectory Transformer model was proposed in [Offline Reinforcement Learning as One Big Sequence Modeling Problem](https://arxiv.org/abs/2106.02039) by Michael Janner, Qiyang Li, Sergey Levine. | ||
|
||
The abstract from the paper is the following: | ||
|
||
*Reinforcement learning (RL) is typically concerned with estimating stationary policies or single-step models, | ||
leveraging the Markov property to factorize problems in time. However, we can also view RL as a generic sequence | ||
modeling problem, with the goal being to produce a sequence of actions that leads to a sequence of high rewards. | ||
Viewed in this way, it is tempting to consider whether high-capacity sequence prediction models that work well | ||
in other domains, such as natural-language processing, can also provide effective solutions to the RL problem. | ||
To this end, we explore how RL can be tackled with the tools of sequence modeling, using a Transformer architecture | ||
to model distributions over trajectories and repurposing beam search as a planning algorithm. Framing RL as sequence | ||
modeling problem simplifies a range of design decisions, allowing us to dispense with many of the components common | ||
in offline RL algorithms. We demonstrate the flexibility of this approach across long-horizon dynamics prediction, | ||
imitation learning, goal-conditioned RL, and offline RL. Further, we show that this approach can be combined with | ||
existing model-free algorithms to yield a state-of-the-art planner in sparse-reward, long-horizon tasks.* | ||
|
||
Tips: | ||
|
||
This Transformer is used for deep reinforcement learning. To use it, you need to create sequences from | ||
actions, states and rewards from all previous timesteps. This model will treat all these elements together | ||
as one big sequence (a trajectory). | ||
|
||
This model was contributed by [CarlCochet](https://huggingface.co/CarlCochet). The original code can be found [here](https://github.com/jannerm/trajectory-transformer). | ||
|
||
## TrajectoryTransformerConfig | ||
|
||
[[autodoc]] TrajectoryTransformerConfig | ||
|
||
|
||
## TrajectoryTransformerModel | ||
|
||
[[autodoc]] TrajectoryTransformerModel | ||
- forward |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,6 +116,7 @@ | |
t5, | ||
tapas, | ||
tapex, | ||
trajectory_transformer, | ||
transfo_xl, | ||
trocr, | ||
unispeech, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed to add this for Windows because fix-copies and fixup were incorrectly modifying index.mdx and serialization.mdx (in docs/source/en)