Views
No views yet
["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"]pip install transformers torch1from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
2import torch
3
4model_path = "kawchar85/SmolLM2-135M-Instruct-TIFA"
5
6# Load model and tokenizer
7tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
8model = AutoModelForCausalLM.from_pretrained(
9 model_path,
10 torch_dtype=torch.float16,
11 trust_remote_code=True,
12 device_map="auto"
13)
14
15# Create pipeline
16pipe = pipeline(
17 "text-generation",
18 model=model,
19 tokenizer=tokenizer,
20 device=0 if torch.cuda.is_available() else -1,
21 return_full_text=False,
22)
23
24# Generate evaluation questions
25description = "khaki triangles and azure crescents"
26user_msg = (
27 f"Create 4 questions to evaluate a text-to-image model's faithfulness to this description: "
28 f'"{description}".\n'
29 "The first question should have 'no' as the answer, "
30 "the second and third questions should have answers that are a single word directly taken "
31 "from the description, and the fourth question should have 'yes' as the answer."
32)
33
34messages = [{"role": "user", "content": user_msg}]
35
36output = pipe(
37 messages,
38 max_new_tokens=256,
39 do_sample=False,
40)
41
42print(output[0]["generated_text"])Q1: Are the triangles green?
Choices: ['no', 'yes']
Answer: no
Q2: What color are the triangles?
Choices: ['blue', 'red', 'khaki', 'green']
Answer: khaki
Q3: What shape are the objects?
Choices: ['squares', 'circles', 'crescents', 'triangles']
Answer: crescents
Q4: Are there azure crescents in the image?
Choices: ['no', 'yes']
Answer: yes1@misc{smollm2-135m-it-tifa-2025,
2 title={SmolLM2-135M-Instruct-TIFA: A Fine-tuned Model for Text-to-Image Faithfulness Assessment},
3 author={kawchar85},
4 year={2025},
5 url={https://huggingface.co/kawchar85/SmolLM2-135M-Instruct-TIFA}
6}