SeanLee97 commited on
Commit
1fc2572
·
verified ·
1 Parent(s): 8f1d264

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +54 -11
README.md CHANGED
@@ -1,7 +1,5 @@
1
  ---
2
  library_name: peft
3
- tags:
4
- - generated_from_trainer
5
  metrics:
6
  - precision
7
  - recall
@@ -11,6 +9,12 @@ base_model: NousResearch/Llama-2-7b-hf
11
  model-index:
12
  - name: billm-llama-7b-conll03-ner
13
  results: []
 
 
 
 
 
 
14
  ---
15
 
16
  <!-- This model card has been generated automatically according to the information the Trainer had access to. You
@@ -18,7 +22,8 @@ should probably proofread and complete it, then remove this comment. -->
18
 
19
  # billm-llama-7b-conll03-ner
20
 
21
- This model is a fine-tuned version of [NousResearch/Llama-2-7b-hf](https://huggingface.co/NousResearch/Llama-2-7b-hf) on an unknown dataset.
 
22
  It achieves the following results on the evaluation set:
23
  - Loss: 0.1664
24
  - Precision: 0.9243
@@ -26,19 +31,38 @@ It achieves the following results on the evaluation set:
26
  - F1: 0.9319
27
  - Accuracy: 0.9860
28
 
29
- ## Model description
30
 
31
- More information needed
 
 
32
 
33
- ## Intended uses & limitations
 
 
 
34
 
35
- More information needed
36
 
37
- ## Training and evaluation data
 
 
 
 
 
 
 
 
 
 
 
38
 
39
- More information needed
 
 
 
 
40
 
41
- ## Training procedure
42
 
43
  ### Training hyperparameters
44
 
@@ -73,4 +97,23 @@ The following hyperparameters were used during training:
73
  - Transformers 4.38.2
74
  - Pytorch 2.0.1
75
  - Datasets 2.16.0
76
- - Tokenizers 0.15.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  library_name: peft
 
 
3
  metrics:
4
  - precision
5
  - recall
 
9
  model-index:
10
  - name: billm-llama-7b-conll03-ner
11
  results: []
12
+ license: mit
13
+ datasets:
14
+ - conll2003
15
+ language:
16
+ - en
17
+ pipeline_tag: token-classification
18
  ---
19
 
20
  <!-- This model card has been generated automatically according to the information the Trainer had access to. You
 
22
 
23
  # billm-llama-7b-conll03-ner
24
 
25
+ This model is a fine-tuned version of [NousResearch/Llama-2-7b-hf](https://huggingface.co/NousResearch/Llama-2-7b-hf) using [BiLLM](https://github.com/WhereIsAI/BiLLM).
26
+
27
  It achieves the following results on the evaluation set:
28
  - Loss: 0.1664
29
  - Precision: 0.9243
 
31
  - F1: 0.9319
32
  - Accuracy: 0.9860
33
 
34
+ ## Inference
35
 
36
+ ```bash
37
+ python -m pip install -U billm
38
+ ```
39
 
40
+ ```python
41
+ from transformers import AutoTokenizer, pipeline
42
+ from peft import PeftModel, PeftConfig
43
+ from billm import MistralForTokenClassification
44
 
 
45
 
46
+ label2id = {'O': 0, 'B-PER': 1, 'I-PER': 2, 'B-ORG': 3, 'I-ORG': 4, 'B-LOC': 5, 'I-LOC': 6, 'B-MISC': 7, 'I-MISC': 8}
47
+ id2label = {v: k for k, v in label2id.items()}
48
+ model_id = 'WhereIsAI/billm-llama-7b-conll03-ner'
49
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
50
+ peft_config = PeftConfig.from_pretrained(model_id)
51
+ model = MistralForTokenClassification.from_pretrained(
52
+ peft_config.base_model_name_or_path,
53
+ num_labels=len(label2id), id2label=id2label, label2id=label2id
54
+ )
55
+ model = PeftModel.from_pretrained(model, model_id)
56
+ # merge_and_unload is necessary for inference
57
+ model = model.merge_and_unload()
58
 
59
+ token_classifier = pipeline("token-classification", model=model, tokenizer=tokenizer, aggregation_strategy="simple")
60
+ sentence = "I live in Hong Kong. I am a student at Hong Kong PolyU."
61
+ tokens = token_classifier(sentence)
62
+ print(tokens)
63
+ ```
64
 
65
+ ## Training Details
66
 
67
  ### Training hyperparameters
68
 
 
97
  - Transformers 4.38.2
98
  - Pytorch 2.0.1
99
  - Datasets 2.16.0
100
+ - Tokenizers 0.15.0
101
+
102
+ ## Citation
103
+
104
+ ```bibtex
105
+ @inproceedings{li2024bellm,
106
+ title = "BeLLM: Backward Dependency Enhanced Large Language Model for Sentence Embeddings",
107
+ author = "Li, Xianming and Li, Jing",
108
+ booktitle = "Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics",
109
+ year = "2024",
110
+ publisher = "Association for Computational Linguistics"
111
+ }
112
+
113
+ @article{li2023label,
114
+ title={Label supervised llama finetuning},
115
+ author={Li, Zongxi and Li, Xianming and Liu, Yuzhang and Xie, Haoran and Li, Jing and Wang, Fu-lee and Li, Qing and Zhong, Xiaoqin},
116
+ journal={arXiv preprint arXiv:2310.01208},
117
+ year={2023}
118
+ }
119
+ ```