Upload 5 files
Browse files- README.md +43 -0
- config.json +43 -0
- generation_config.json +6 -0
- model.safetensors +3 -0
- tokenizer_config.json +12 -0
README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- trl
|
| 5 |
+
- ppo
|
| 6 |
+
- transformers
|
| 7 |
+
- reinforcement-learning
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# TRL Model
|
| 11 |
+
|
| 12 |
+
This is a [TRL language model](https://github.com/huggingface/trl) that has been fine-tuned with reinforcement learning to
|
| 13 |
+
guide the model outputs according to a value, function, or human feedback. The model can be used for text generation.
|
| 14 |
+
|
| 15 |
+
## Usage
|
| 16 |
+
|
| 17 |
+
To use this model for inference, first install the TRL library:
|
| 18 |
+
|
| 19 |
+
```bash
|
| 20 |
+
python -m pip install trl
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
You can then generate text as follows:
|
| 24 |
+
|
| 25 |
+
```python
|
| 26 |
+
from transformers import pipeline
|
| 27 |
+
|
| 28 |
+
generator = pipeline("text-generation", model="anirvankrishna/PPO/full_finetuning/best_model")
|
| 29 |
+
outputs = generator("Hello, my llama is cute")
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
If you want to use the model for training or to obtain the outputs from the value head, load the model as follows:
|
| 33 |
+
|
| 34 |
+
```python
|
| 35 |
+
from transformers import AutoTokenizer
|
| 36 |
+
from trl import AutoModelForCausalLMWithValueHead
|
| 37 |
+
|
| 38 |
+
tokenizer = AutoTokenizer.from_pretrained("anirvankrishna/PPO/full_finetuning/best_model")
|
| 39 |
+
model = AutoModelForCausalLMWithValueHead.from_pretrained("anirvankrishna/PPO/full_finetuning/best_model")
|
| 40 |
+
|
| 41 |
+
inputs = tokenizer("Hello, my llama is cute", return_tensors="pt")
|
| 42 |
+
outputs = model(**inputs, labels=inputs["input_ids"])
|
| 43 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation_function": "gelu_new",
|
| 3 |
+
"add_cross_attention": false,
|
| 4 |
+
"architectures": [
|
| 5 |
+
"GPT2LMHeadModel"
|
| 6 |
+
],
|
| 7 |
+
"attn_pdrop": 0.1,
|
| 8 |
+
"bos_token_id": 50256,
|
| 9 |
+
"dtype": "float32",
|
| 10 |
+
"embd_pdrop": 0.1,
|
| 11 |
+
"eos_token_id": 50256,
|
| 12 |
+
"initializer_range": 0.02,
|
| 13 |
+
"layer_norm_epsilon": 1e-05,
|
| 14 |
+
"model_type": "gpt2",
|
| 15 |
+
"n_ctx": 1024,
|
| 16 |
+
"n_embd": 1024,
|
| 17 |
+
"n_head": 16,
|
| 18 |
+
"n_inner": null,
|
| 19 |
+
"n_layer": 24,
|
| 20 |
+
"n_positions": 1024,
|
| 21 |
+
"n_special": 0,
|
| 22 |
+
"pad_token_id": null,
|
| 23 |
+
"predict_special_tokens": true,
|
| 24 |
+
"reorder_and_upcast_attn": false,
|
| 25 |
+
"resid_pdrop": 0.1,
|
| 26 |
+
"scale_attn_by_inverse_layer_idx": false,
|
| 27 |
+
"scale_attn_weights": true,
|
| 28 |
+
"summary_activation": null,
|
| 29 |
+
"summary_first_dropout": 0.1,
|
| 30 |
+
"summary_proj_to_labels": true,
|
| 31 |
+
"summary_type": "cls_index",
|
| 32 |
+
"summary_use_proj": true,
|
| 33 |
+
"task_specific_params": {
|
| 34 |
+
"text-generation": {
|
| 35 |
+
"do_sample": true,
|
| 36 |
+
"max_length": 50
|
| 37 |
+
}
|
| 38 |
+
},
|
| 39 |
+
"tie_word_embeddings": true,
|
| 40 |
+
"transformers_version": "5.0.0",
|
| 41 |
+
"use_cache": true,
|
| 42 |
+
"vocab_size": 50257
|
| 43 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 50256,
|
| 4 |
+
"eos_token_id": 50256,
|
| 5 |
+
"transformers_version": "5.0.0"
|
| 6 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:79df56b7d131e575d99d7b49272abfbaf166eadcbc487ba9c055bf1846a85668
|
| 3 |
+
size 1419327164
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<|endoftext|>",
|
| 5 |
+
"eos_token": "<|endoftext|>",
|
| 6 |
+
"errors": "replace",
|
| 7 |
+
"is_local": false,
|
| 8 |
+
"model_max_length": 1024,
|
| 9 |
+
"pad_token": "<|endoftext|>",
|
| 10 |
+
"tokenizer_class": "GPT2Tokenizer",
|
| 11 |
+
"unk_token": "<|endoftext|>"
|
| 12 |
+
}
|