File size: 2,733 Bytes
128fd5b
 
41fd3b6
128fd5b
 
 
41fd3b6
 
 
f9b8ea3
 
 
b3dd938
f9b8ea3
128fd5b
 
 
 
 
 
 
 
8a1cc5d
128fd5b
41fd3b6
128fd5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9a99b42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128fd5b
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
language:
- en
license: apache-2.0
tags:
- generated_from_trainer
- tex2log
- log2tex
- foc

widget:
- text: "translate to nl: all x1.(_explanation(x1) -> -_equal(x1))"
- text: "translate to fol: All chains are bad."

model-index:
- name: t5-small-text2log
  results: []
---

<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->

# T5 (small) fine-tuned on Text2Log

This model is a fine-tuned version of [t5-small](https://huggingface.co/t5-small) on an Text2Log dataset.
It achieves the following results on the evaluation set:
- Loss: 0.0313

## Model description

More information needed

## Intended uses & limitations

More information needed

## Training and evaluation data

More information needed

## Training procedure

### Training hyperparameters

The following hyperparameters were used during training:
- learning_rate: 5e-05
- train_batch_size: 8
- eval_batch_size: 8
- seed: 42
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- num_epochs: 6

### Training results

| Training Loss | Epoch | Step   | Validation Loss |
|:-------------:|:-----:|:------:|:---------------:|
| 0.0749        | 1.0   | 21661  | 0.0509          |
| 0.0564        | 2.0   | 43322  | 0.0396          |
| 0.0494        | 3.0   | 64983  | 0.0353          |
| 0.0425        | 4.0   | 86644  | 0.0332          |
| 0.04          | 5.0   | 108305 | 0.0320          |
| 0.0381        | 6.0   | 129966 | 0.0313          |

### Usage:
```py
from transformers import AutoTokenizer, T5ForConditionalGeneration

MODEL_CKPT = "mrm8488/t5-small-finetuned-text2log"

model = T5ForConditionalGeneration.from_pretrained(MODEL_CKPT).to(device)
tokenizer = AutoTokenizer.from_pretrained(MODEL_CKPT)

def translate(text):
    inputs = tokenizer(text, padding="longest", max_length=64, return_tensors="pt")
    input_ids = inputs.input_ids.to(device)
    attention_mask = inputs.attention_mask.to(device)

    output = model.generate(input_ids, attention_mask=attention_mask, early_stopping=False, max_length=64)

    return tokenizer.decode(output[0], skip_special_tokens=True)

prompt_nl_to_fol = "translate to fol: "
prompt_fol_to_nl = "translate to nl: "
example_1 = "Every killer leaves something."
example_2 = "all x1.(_woman(x1) -> exists x2.(_emotion(x2) & _experience(x1,x2)))"

print(translate(prompt_nl_to_fol + example_1)) # all x1.(_killer(x1) -> exists x2._leave(x1,x2))
print(translate(prompt_fol_to_nl + example_2)) # Every woman experiences emotions.
```

### Framework versions

- Transformers 4.17.0.dev0
- Pytorch 1.10.0+cu111
- Datasets 1.18.3
- Tokenizers 0.11.0