Views
No views yet
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model = AutoModelForCausalLM.from_pretrained(
5 "cyqwill/sger-lfm2.5-name-matching",
6 torch_dtype=torch.bfloat16,
7 device_map="auto",
8)
9tokenizer = AutoTokenizer.from_pretrained("cyqwill/sger-lfm2.5-name-matching")
10
11prompt = (
12 "<|system|>\n"
13 "You are an expert system for KYC name matching in India. Determine if Name 1 and Name 2 refer to the same person. "
14 "Account for spelling variations, abbreviations, token reordering, merged tokens, and honorifics (-bhai, -ji).\n"
15 "<|user|>\n"
16 '[Few-Shot Examples]\n'
17 'Name 1: "kirtan singh" | Name 2: "singhkirtan" -> Yes\n'
18 'Name 1: "ramesh patel" | Name 2: "rameshbhai patel" -> Yes\n'
19 'Name 1: "vipin" | Name 2: "bipin" -> No\n'
20 '[Target]\n'
21 'Name 1: "अनिल रजनी यादव" | Name 2: "रजनी अनिल यादव" -> Match?\n'
22 "<|assistant|>\n"
23)
24inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
25out = model.generate(**inputs, max_new_tokens=8)
26print(tokenizer.decode(out[0][inputs.input_ids.shape[-1]:], skip_special_tokens=True))| 指标 | 数值 |
|---|---|
| Precision | 0.9997 |
| Recall | 0.9997 |
| F1 | 0.9997 |
| Accuracy | 0.9998 |