Translation
Transformers
Safetensors
English
t5
text2text-generation
NLTOFOL
NL
FOL
semantic-parsing
first-order-logic
formal-logic
compositional-generalization
text-generation-inference
Instructions to use fvossel/t5-base-groves with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use fvossel/t5-base-groves with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("translation", model="fvossel/t5-base-groves")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("fvossel/t5-base-groves") model = AutoModelForSeq2SeqLM.from_pretrained("fvossel/t5-base-groves", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model:
|
| 3 |
+
- google-t5/t5-base
|
| 4 |
+
library_name: transformers
|
| 5 |
+
license: apache-2.0
|
| 6 |
+
datasets:
|
| 7 |
+
- fvossel/groves
|
| 8 |
+
language:
|
| 9 |
+
- en
|
| 10 |
+
pipeline_tag: translation
|
| 11 |
+
tags:
|
| 12 |
+
- NLTOFOL
|
| 13 |
+
- NL
|
| 14 |
+
- FOL
|
| 15 |
+
- semantic-parsing
|
| 16 |
+
- first-order-logic
|
| 17 |
+
- formal-logic
|
| 18 |
+
- compositional-generalization
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
# Model Card for fvossel/t5-base-nl-to-fol
|
| 22 |
+
|
| 23 |
+
This model is a fully fine-tuned version of [`google-t5/t5-base`](https://huggingface.co/google-t5/t5-base). It was trained to translate **natural language statements into First-Order Logic (FOL)** representations.
|
| 24 |
+
|
| 25 |
+
## Model Details
|
| 26 |
+
|
| 27 |
+
### Model Description
|
| 28 |
+
|
| 29 |
+
- **Developed by:** Vossel et al. at Osnabrück University
|
| 30 |
+
- **Funded by:** Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) 456666331
|
| 31 |
+
- **Model type:** Encoder-decoder sequence-to-sequence model (T5 architecture)
|
| 32 |
+
- **Language(s) (NLP):** English, FOL
|
| 33 |
+
- **License:** This model was fine-tuned from [`google/t5-base`](https://huggingface.co/google/t5-base), which is released under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0), and is itself released under the **Apache 2.0 License**.
|
| 34 |
+
- **Finetuned from model:** google/t5-base
|
| 35 |
+
|
| 36 |
+
## Uses
|
| 37 |
+
|
| 38 |
+
### Direct Use
|
| 39 |
+
|
| 40 |
+
This model is designed to translate natural language (NL) sentences into corresponding first-order logic (FOL) expressions. Use cases include:
|
| 41 |
+
|
| 42 |
+
- Automated semantic parsing and formalization of NL statements into symbolic logic.
|
| 43 |
+
- Supporting explainable AI systems that require symbolic reasoning based on language input.
|
| 44 |
+
- Research in neurosymbolic AI, logic-based natural language understanding, and formal verification.
|
| 45 |
+
- Integration into pipelines for natural language inference, question answering, or knowledge base population.
|
| 46 |
+
|
| 47 |
+
Users should verify and validate symbolic formulas generated by the model for correctness depending on the application.
|
| 48 |
+
|
| 49 |
+
### Downstream Use
|
| 50 |
+
|
| 51 |
+
This model can be further fine-tuned or adapted for domain-specific formalization tasks (e.g., legal, biomedical). Suitable for interactive systems requiring formal reasoning.
|
| 52 |
+
|
| 53 |
+
### Out-of-Scope Use
|
| 54 |
+
|
| 55 |
+
- Not designed for general natural language generation.
|
| 56 |
+
- May struggle with ambiguous, highly figurative, or out-of-domain input.
|
| 57 |
+
- Outputs should not be used as final decisions in critical areas without expert review.
|
| 58 |
+
|
| 59 |
+
### Recommendations
|
| 60 |
+
|
| 61 |
+
- Validate outputs carefully before use in critical applications.
|
| 62 |
+
- Be aware of possible biases from training data and synthetic data sources.
|
| 63 |
+
- Specialized for English NL and FOL; may not generalize to other languages or logics.
|
| 64 |
+
- Use human-in-the-loop workflows for sensitive tasks.
|
| 65 |
+
- Intended for research and prototyping, not standalone critical systems.
|
| 66 |
+
|
| 67 |
+
## How to Get Started with the Model
|
| 68 |
+
|
| 69 |
+
```python
|
| 70 |
+
import torch
|
| 71 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
| 72 |
+
|
| 73 |
+
# Load tokenizer and model
|
| 74 |
+
model_path = "fvossel/t5-base-nl-to-fol"
|
| 75 |
+
tokenizer = T5Tokenizer.from_pretrained(model_path)
|
| 76 |
+
model = T5ForConditionalGeneration.from_pretrained(model_path).to("cuda")
|
| 77 |
+
|
| 78 |
+
# Example NL input
|
| 79 |
+
nl_input = "All dogs are animals."
|
| 80 |
+
|
| 81 |
+
# Preprocess prompt
|
| 82 |
+
input_text = "translate English natural language statements into first-order logic (FOL): " + nl_input
|
| 83 |
+
inputs = tokenizer(input_text, return_tensors="pt", padding=True).to("cuda")
|
| 84 |
+
|
| 85 |
+
# Generate prediction
|
| 86 |
+
with torch.no_grad():
|
| 87 |
+
outputs = model.generate(
|
| 88 |
+
inputs["input_ids"],
|
| 89 |
+
max_length=256,
|
| 90 |
+
min_length=1,
|
| 91 |
+
num_beams=5,
|
| 92 |
+
length_penalty=2.0,
|
| 93 |
+
early_stopping=True,
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
# Decode and print result
|
| 97 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 98 |
+
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
## Training Details
|
| 102 |
+
|
| 103 |
+
### Training Data
|
| 104 |
+
|
| 105 |
+
The model was fine-tuned on the [groves dataset](https://huggingface.co/datasets/fvossel/groves).
|
| 106 |
+
|
| 107 |
+
### Training Procedure
|
| 108 |
+
|
| 109 |
+
The model was fully fine-tuned (no LoRA) from `google/t5-base` with:
|
| 110 |
+
|
| 111 |
+
- Prompt-based instruction tuning
|
| 112 |
+
- Single-GPU training with float32 precision
|
| 113 |
+
- Preprocessing replaced FOL quantifiers (e.g., `∀`) with tokens like `FORALL`
|
| 114 |
+
- Maximum input/output sequence length was 250 tokens
|
| 115 |
+
|
| 116 |
+
### Training Hyperparameters
|
| 117 |
+
|
| 118 |
+
- **Training regime:** bfloat16 precision
|
| 119 |
+
- **Batch size:** 8 (per device)
|
| 120 |
+
- **Learning rate:** 0.001
|
| 121 |
+
- **Number of epochs:** 12
|
| 122 |
+
- **Optimizer:** AdamW
|
| 123 |
+
- **Adam epsilon:** 1e-8
|
| 124 |
+
- **Scheduler:** Linear warmup with 500 steps
|
| 125 |
+
- **Gradient accumulation steps:** 1
|
| 126 |
+
- **Weight decay:** 0.01
|
| 127 |
+
- **LoRA:** Not used (full fine-tuning)
|
| 128 |
+
- **Task type:** SEQ_2_SEQ_LM
|
| 129 |
+
- **Early stopping patience:** 4 epochs
|
| 130 |
+
- **Evaluation strategy:** per epoch
|
| 131 |
+
- **Save strategy:** per epoch
|
| 132 |
+
- **Save total limit:** 12 checkpoints
|
| 133 |
+
- **Best model selection metric:** eval_loss
|