Views
No views yet
| 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 |
1from transformers import AutoTokenizer, T5ForConditionalGeneration
2
3MODEL_CKPT = "mrm8488/t5-small-finetuned-text2log"
4
5model = T5ForConditionalGeneration.from_pretrained(MODEL_CKPT).to(device)
6tokenizer = AutoTokenizer.from_pretrained(MODEL_CKPT)
7
8def translate(text):
9 inputs = tokenizer(text, padding="longest", max_length=64, return_tensors="pt")
10 input_ids = inputs.input_ids.to(device)
11 attention_mask = inputs.attention_mask.to(device)
12
13 output = model.generate(input_ids, attention_mask=attention_mask, early_stopping=False, max_length=64)
14
15 return tokenizer.decode(output[0], skip_special_tokens=True)
16
17prompt_nl_to_fol = "translate to fol: "
18prompt_fol_to_nl = "translate to nl: "
19example_1 = "Every killer leaves something."
20example_2 = "all x1.(_woman(x1) -> exists x2.(_emotion(x2) & _experience(x1,x2)))"
21
22print(translate(prompt_nl_to_fol + example_1)) # all x1.(_killer(x1) -> exists x2._leave(x1,x2))
23print(translate(prompt_fol_to_nl + example_2)) # Every woman experiences emotions.