trl transformers reinforcement-learning

TRL Model

This is a TRL language model that has been fine-tuned with reinforcement learning to guide the model outputs according to a value, function, or human feedback. The model can be used for text generation.

Usage

To use this model for inference, first install the TRL library:

python -m pip install trl

You can then generate text as follows:

from transformers import pipeline

generator = pipeline("text-generation", model="romman8//tmp/tmpffgavixx/nlp-lab-2023-seq2seq/R-best-fine-tuned-bart-base-full-ft-reward_short_sentences_and_words-2023-07-13T06-49-08")
outputs = generator("Hello, my llama is cute")

If you want to use the model for training or to obtain the outputs from the value head, load the model as follows:

from transformers import AutoTokenizer
from trl import AutoModelForCausalLMWithValueHead

tokenizer = AutoTokenizer.from_pretrained("romman8//tmp/tmpffgavixx/nlp-lab-2023-seq2seq/R-best-fine-tuned-bart-base-full-ft-reward_short_sentences_and_words-2023-07-13T06-49-08")
model = AutoModelForCausalLMWithValueHead.from_pretrained("romman8//tmp/tmpffgavixx/nlp-lab-2023-seq2seq/R-best-fine-tuned-bart-base-full-ft-reward_short_sentences_and_words-2023-07-13T06-49-08")

inputs = tokenizer("Hello, my llama is cute", return_tensors="pt")
outputs = model(**inputs, labels=inputs["input_ids"])