doberst commited on
Commit
fc50d4a
1 Parent(s): dc40517

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +125 -3
README.md CHANGED
@@ -1,3 +1,125 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ inference: false
4
+ ---
5
+
6
+ # bling-phi-3
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+ bling-phi-3 is part of the BLING ("Best Little Instruct No-GPU") model series, RAG-instruct trained on top of a Microsoft Phi-3 base model.
11
+
12
+
13
+ ### Benchmark Tests
14
+
15
+ Evaluated against the benchmark test: [RAG-Instruct-Benchmark-Tester](https://www.huggingface.co/datasets/llmware/rag_instruct_benchmark_tester)
16
+ 1 Test Run (temperature=0.0, sample=False) with 1 point for correct answer, 0.5 point for partial correct or blank / NF, 0.0 points for incorrect, and -1 points for hallucinations.
17
+
18
+ --**Accuracy Score**: **99.5** correct out of 100
19
+ --Not Found Classification: 95.0%
20
+ --Boolean: 97.5%
21
+ --Math/Logic: 80.0%
22
+ --Complex Questions (1-5): 4 (Above Average - multiple-choice, causal)
23
+ --Summarization Quality (1-5): 4 (Above Average)
24
+ --Hallucinations: No hallucinations observed in test runs.
25
+
26
+ For test run results (and good indicator of target use cases), please see the files ("core_rag_test" and "answer_sheet" in this repo).
27
+
28
+ Note: compare results with [bling-phi-2](https://www.huggingface.co/llmware/bling-phi-2-v0), and [dragon-mistral-7b](https://www.huggingface.co/llmware/dragon-mistral-7b-v0).
29
+
30
+ Note: see also the quantized gguf version of the model- [bling-phi-3-gguf](https://www.huggingface.co/llmware/bling-phi-3-gguf).
31
+
32
+ Note: the Pytorch version answered 1 question with "Not Found" while the quantized version answered it correctly, hence the small difference in scores.
33
+
34
+ ### Model Description
35
+
36
+ <!-- Provide a longer summary of what this model is. -->
37
+
38
+ - **Developed by:** llmware
39
+ - **Model type:** bling
40
+ - **Language(s) (NLP):** English
41
+ - **License:** Apache 2.0
42
+ - **Finetuned from model:** Microsoft Phi-3
43
+
44
+ ## Uses
45
+
46
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
47
+
48
+ The intended use of BLING models is two-fold:
49
+
50
+ 1. Provide high-quality RAG-Instruct models designed for fact-based, no "hallucination" question-answering in connection with an enterprise RAG workflow.
51
+
52
+ 2. BLING models are fine-tuned on top of leading base foundation models, generally in the 1-3B+ range, and purposefully rolled-out across multiple base models to provide choices and "drop-in" replacements for RAG specific use cases.
53
+
54
+
55
+ ### Direct Use
56
+
57
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
58
+
59
+ BLING is designed for enterprise automation use cases, especially in knowledge-intensive industries, such as financial services,
60
+ legal and regulatory industries with complex information sources.
61
+
62
+ BLING models have been trained for common RAG scenarios, specifically: question-answering, key-value extraction, and basic summarization as the core instruction types
63
+ without the need for a lot of complex instruction verbiage - provide a text passage context, ask questions, and get clear fact-based responses.
64
+
65
+
66
+ ## Bias, Risks, and Limitations
67
+
68
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
69
+
70
+ Any model can provide inaccurate or incomplete information, and should be used in conjunction with appropriate safeguards and fact-checking mechanisms.
71
+
72
+
73
+ ## How to Get Started with the Model
74
+
75
+ The fastest way to get started with BLING is through direct import in transformers:
76
+
77
+ from transformers import AutoTokenizer, AutoModelForCausalLM
78
+ tokenizer = AutoTokenizer.from_pretrained("llmware/bling-phi-3", trust_remote_code=True)
79
+ model = AutoModelForCausalLM.from_pretrained("llmware/bling-phi-3", trust_remote_code=True)
80
+
81
+ Please refer to the generation_test .py files in the Files repository, which includes 200 samples and script to test the model. The **generation_test_llmware_script.py** includes built-in llmware capabilities for fact-checking, as well as easy integration with document parsing and actual retrieval to swap out the test set for RAG workflow consisting of business documents.
82
+
83
+ The BLING model was fine-tuned with a simple "\<human> and \<bot> wrapper", so to get the best results, wrap inference entries as:
84
+
85
+ full_prompt = "<human>: " + my_prompt + "\n" + "<bot>:"
86
+
87
+ (As an aside, we intended to retire "human-bot" and tried several variations of the new Microsoft Phi-3 prompt template and ultimately had slightly better results with the very simple "human-bot" separators, so we opted to keep them.)
88
+
89
+
90
+ The BLING model was fine-tuned with closed-context samples, which assume generally that the prompt consists of two sub-parts:
91
+
92
+ 1. Text Passage Context, and
93
+ 2. Specific question or instruction based on the text passage
94
+
95
+ To get the best results, package "my_prompt" as follows:
96
+
97
+ my_prompt = {{text_passage}} + "\n" + {{question/instruction}}
98
+
99
+
100
+ If you are using a HuggingFace generation script:
101
+
102
+ # prepare prompt packaging used in fine-tuning process
103
+ new_prompt = "<human>: " + entries["context"] + "\n" + entries["query"] + "\n" + "<bot>:"
104
+
105
+ inputs = tokenizer(new_prompt, return_tensors="pt")
106
+ start_of_output = len(inputs.input_ids[0])
107
+
108
+ # temperature: set at 0.0 with do_sample=False for consistency of output
109
+ # max_new_tokens: set at 100 - may prematurely stop a few of the summaries
110
+
111
+ outputs = model.generate(
112
+ inputs.input_ids.to(device),
113
+ eos_token_id=tokenizer.eos_token_id,
114
+ pad_token_id=tokenizer.eos_token_id,
115
+ do_sample=False,
116
+ temperature=0.0,
117
+ max_new_tokens=100,
118
+ )
119
+
120
+ output_only = tokenizer.decode(outputs[0][start_of_output:],skip_special_tokens=True)
121
+
122
+
123
+ ## Model Card Contact
124
+
125
+ Darren Oberst & llmware team