Views
No views yet
allenai/OLMo-2-0325-32B-Instruct. It was trained to translate natural language statements into First-Order Logic (FOL) representations.allenai/OLMo-2-0325-32B-Instruct, which is released under the Apache 2.0 License. These adapter weights are also released under the Apache 2.0 License.1import torch
2from peft import PeftModel
3from transformers import AutoModelForCausalLM, AutoTokenizer
4
5base_model_name = "allenai/OLMo-2-0325-32B-Instruct"
6lora_weights = "fvossel/OLMo-2-0325-32B-Instruct-nl-to-fol"
7
8tokenizer = AutoTokenizer.from_pretrained(base_model_name, trust_remote_code=True)
9if tokenizer.pad_token is None:
10 tokenizer.pad_token = tokenizer.eos_token
11tokenizer.padding_side = "left"
12
13model = AutoModelForCausalLM.from_pretrained(base_model_name, trust_remote_code=True, device_map="auto")
14model = PeftModel.from_pretrained(model, lora_weights, device_map="auto")
15
16def formatting_func(text):
17 return tokenizer.apply_chat_template(
18 [
19 {
20 "role": "system",
21 "content": (
22 "You are a helpful AI assistant that translates Natural Language (NL) text "
23 "into First-Order Logic (FOL) using only the given quantors and junctors: "
24 "∀ (for all), ∃ (there exists), ¬ (not), ∧ (and), ∨ (or), → (implies), "
25 "↔ (if and only if), ⊕ (xor). "
26 "Start your answer with '𝜙=' followed by the FOL-formula. Do not include any other text."
27 ),
28 },
29 {"role": "user", "content": text},
30 ],
31 tokenize=False,
32 add_generation_prompt=False,
33 )
34
35input_text = "All dogs are animals."
36prompt = formatting_func(input_text)
37inputs = tokenizer(prompt, return_tensors="pt", padding=True)
38outputs = model.generate(**inputs, max_new_tokens=100)
39print(tokenizer.decode(outputs[0], skip_special_tokens=True))ddp_find_unused_parameters=Falseddp_backend="nccl"