Views
No views yet
Qwen2ForClassifier model, a modified version of the Qwen2 model for classification tasks, which is used to guide chain-of-thought reasoning.1import classifier_lib
2import torch
3
4model_loading_kwargs = dict(attn_implementation="flash_attention_2", torch_dtype=torch.bfloat16, use_cache=False)
5classifier = classifier_lib.Qwen2ForClassifier.from_pretrained("VGS-AI/DeepSeek-VM-1.5B", **model_loading_kwargs)input_ids, you can use the following code snippet:1import torch
2
3device = torch.device("cuda")
4# your input_ids
5input_ids = torch.tensor([151646, 151644, 18, 13, 47238, ...], dtype=torch.long, device=device)
6attention_mask = torch.ones_like(input_ids)
7classifier_outputs = classifier(input_ids.unsqueeze(0), attention_mask=attention_mask.unsqueeze(0))
8# use last index of the sequence
9scores = classifier_outputs.success_probs.squeeze(0)[-1].item()