The model was fine-tuned using one quarter of the ConLL 2012 OntoNotes v5 dataset.
The prompts and expected outputs were constructed as described in [1].
1Instruct: I am an excelent linquist. The task is to label organization entities in the given sentence. Below are some examples
2
3Input: A spokesman for B. A. T said of the amended filings that,`` It would appear that nothing substantive has changed.
4Output: A spokesman for @@B. A. T## said of the amended filings that,`` It would appear that nothing substantive has changed.
5
6Input: Since NBC's interest in the Qintex bid for MGM / UA was disclosed, Mr. Wright has n't been available for comment.
7Output: Since @@NBC##'s interest in the @@Qintex## bid for @@MGM / UA## was disclosed, Mr. Wright has n't been available for comment.
8
9Input: You know news organizations demand total transparency whether you're General Motors or United States government /.
10Output: You know news organizations demand total transparency whether you're @@General Motors## or United States government /.
11
12Input: We respectfully invite you to watch a special edition of Across China.
13Output:
This model was trained using
SFT AutoTrain trainer. For more information, please visit
AutoTrain.
1{
2 "model": "microsoft/phi-2",
3 "valid_split": null,
4 "add_eos_token": false,
5 "block_size": 1024,
6 "model_max_length": 1024,
7 "padding": "right",
8 "trainer": "sft",
9 "use_flash_attention_2": false,
10 "disable_gradient_checkpointing": false,
11 "evaluation_strategy": "epoch",
12 "save_total_limit": 1,
13 "save_strategy": "epoch",
14 "auto_find_batch_size": false,
15 "mixed_precision": "bf16",
16 "lr": 0.0002,
17 "epochs": 1,
18 "batch_size": 1,
19 "warmup_ratio": 0.1,
20 "gradient_accumulation": 4,
21 "optimizer": "adamw_torch",
22 "scheduler": "linear",
23 "weight_decay": 0.01,
24 "max_grad_norm": 1.0,
25 "seed": 42,
26 "apply_chat_template": false,
27 "quantization": "int4",
28 "target_modules": null,
29 "merge_adapter": false,
30 "peft": true,
31 "lora_r": 16,
32 "lora_alpha": 32,
33 "lora_dropout": 0.05,
34 "dpo_beta": 0.1,
35}
1
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_path = "pahautelman/phi2-ner-v1"
5
6tokenizer = AutoTokenizer.from_pretrained(model_path)
7model = AutoModelForCausalLM.from_pretrained(
8 model_path
9).eval()
10
11prompt = 'Label the person entities in the given sentence: Russian President Vladimir Putin is due to arrive in Havana a few hours from now to become the first post-Soviet leader to visit Cuba.'
12
13inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors='pt')
14outputs = model.generate(
15 inputs.to(model.device),
16 max_new_tokens=9,
17 do_sample=False,
18)
19output = tokenizer.batch_decode(outputs)[0]
20
21# Model response: "Output: Russian President, Vladimir Putin"
22print(output)
[1] Wang et al., GPT-NER: Named entity recognition via large language models 2023