from transformers import AutoModelForCausalLM, AutoTokenizer model_id = "oscardean/smollm2-135m-text2cypher" tokenizer = AutoTokenizer.from_pretrained(model_id)model = AutoModelForCausalLM.from_pretrained(model_id) messages = [ { "role": "system", "content": ( "You translate natural-language questions into Cypher queries. " "Use only the supplied graph schema and return only the Cypher query." ), }, { "role": "user", "content": ( "Graph schema:\n" "Person {name: STRING}\n" "Movie {title: STRING, year: INTEGER}\n" "(Person)-[:DIRECTED]->(Movie)\n\n" "Question:\n" "Which movies did Christopher Nolan direct before 2010?" ), },] inputs = tokenizer.apply_chat_template( messages, tokenize=True, add_generation_prompt=True, return_tensors="pt",) outputs = model.generate( inputs, max_new_tokens=192, do_sample=False,) prediction = tokenizer.decode( outputs[0, inputs.shape[1]:], skip_special_tokens=True,) print(prediction)