Views
No views yet
Binary classification: given a consumer utterance from a JTBD interview, determine whether it describes a trigger event — something that initiated or prompted the person to seek a solution. Output 'yes' or 'no'.1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3
4# Load base model
5model = AutoModelForCausalLM.from_pretrained(
6 "mistralai/Mistral-7B-Instruct-v0.2",
7 torch_dtype=torch.bfloat16,
8 device_map="auto",
9)
10
11# Load T2L adapter
12model = PeftModel.from_pretrained(
13 model,
14 "michaelarutyunov/jtbd-t2l-jobtrigger",
15)
16
17# Use for inference
18prompt = "<s>[INST] [UTTERANCE]: Your utterance here\nDoes this contain a job_trigger? Answer yes or no.\nAnswer: [/INST]"
19inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
20outputs = model.generate(**inputs, max_new_tokens=5)
21response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
22print(response)q_proj and v_proj (attention layers).
Can be stacked with a D2L adapter (targets down_proj) for combined knowledge:1model.load_adapter("path/to/d2l_adapter", adapter_name="d2l")
2model.load_adapter("path/to/t2l_job_trigger", adapter_name="t2l")
3model.set_adapter(["d2l", "t2l_job_trigger"])