Upload README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,123 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
inference: false
|
4 |
+
---
|
5 |
+
|
6 |
+
# Model Card for Model ID
|
7 |
+
|
8 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
+
|
10 |
+
bling-phi-2-v0 is part of the BLING ("Best Little Instruct No GPU Required ...") model series, RAG-instruct trained on top of a Microsoft Phi-2B base model.
|
11 |
+
|
12 |
+
BLING models are fine-tuned with high-quality custom instruct datasets, designed for rapid prototyping in RAG scenarios.
|
13 |
+
|
14 |
+
For models with comparable size and performance in RAG deployments, please see:
|
15 |
+
|
16 |
+
[**bling-stable-lm-3b-4e1t-v0**](https://huggingface.co/llmware/bling-stable-lm-3b-4e1t-v0)
|
17 |
+
[**bling-sheared-llama-2.7b-0.1**](https://huggingface.co/llmware/bling-sheared-llama-2.7b-0.1)
|
18 |
+
[**bling-red-pajamas-3b-0.1**](https://huggingface.co/llmware/bling-red-pajamas-3b-0.1)
|
19 |
+
|
20 |
+
### Benchmark Tests
|
21 |
+
|
22 |
+
Evaluated against the benchmark test: [RAG-Instruct-Benchmark-Tester](https://www.huggingface.co/datasets/llmware/rag_instruct_benchmark_tester)
|
23 |
+
Average of 2 Test Runs 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.
|
24 |
+
|
25 |
+
--**Accuracy Score**: **93.0** correct out of 100
|
26 |
+
--Not Found Classification: 95.0%
|
27 |
+
--Boolean: 85.0%
|
28 |
+
--Math/Logic: 82.5%
|
29 |
+
--Complex Questions (1-5): 3 (Above Average - multiple-choice, causal)
|
30 |
+
--Summarization Quality (1-5): 3 (Above Average)
|
31 |
+
--Hallucinations: No hallucinations observed in test runs.
|
32 |
+
|
33 |
+
For test run results (and good indicator of target use cases), please see the files ("core_rag_test" and "answer_sheet" in this repo).
|
34 |
+
|
35 |
+
### Model Description
|
36 |
+
|
37 |
+
<!-- Provide a longer summary of what this model is. -->
|
38 |
+
|
39 |
+
- **Developed by:** llmware
|
40 |
+
- **Model type:** Phi-2B
|
41 |
+
- **Language(s) (NLP):** English
|
42 |
+
- **License:** Apache 2.0
|
43 |
+
- **Finetuned from model:** Microsoft Phi-2B-Base
|
44 |
+
|
45 |
+
## Uses
|
46 |
+
|
47 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
48 |
+
|
49 |
+
The intended use of BLING models is two-fold:
|
50 |
+
|
51 |
+
1. Provide high-quality RAG-Instruct models designed for fact-based, no "hallucination" question-answering in connection with an enterprise RAG workflow.
|
52 |
+
|
53 |
+
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.
|
54 |
+
|
55 |
+
|
56 |
+
### Direct Use
|
57 |
+
|
58 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
59 |
+
|
60 |
+
BLING is designed for enterprise automation use cases, especially in knowledge-intensive industries, such as financial services,
|
61 |
+
legal and regulatory industries with complex information sources.
|
62 |
+
|
63 |
+
BLING models have been trained for common RAG scenarios, specifically: question-answering, key-value extraction, and basic summarization as the core instruction types
|
64 |
+
without the need for a lot of complex instruction verbiage - provide a text passage context, ask questions, and get clear fact-based responses.
|
65 |
+
|
66 |
+
|
67 |
+
## Bias, Risks, and Limitations
|
68 |
+
|
69 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
70 |
+
|
71 |
+
Any model can provide inaccurate or incomplete information, and should be used in conjunction with appropriate safeguards and fact-checking mechanisms.
|
72 |
+
|
73 |
+
|
74 |
+
## How to Get Started with the Model
|
75 |
+
|
76 |
+
The fastest way to get started with BLING is through direct import in transformers:
|
77 |
+
|
78 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
79 |
+
tokenizer = AutoTokenizer.from_pretrained("bling-phi-2-v0", trust_remote_code=True)
|
80 |
+
model = AutoModelForCausalLM.from_pretrained("bling-phi-2-v0", trust_remote_code=True)
|
81 |
+
|
82 |
+
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.
|
83 |
+
|
84 |
+
The dRAGon model was fine-tuned with a simple "\<human> and \<bot> wrapper", so to get the best results, wrap inference entries as:
|
85 |
+
|
86 |
+
full_prompt = "<human>: " + my_prompt + "\n" + "<bot>:"
|
87 |
+
|
88 |
+
The BLING model was fine-tuned with closed-context samples, which assume generally that the prompt consists of two sub-parts:
|
89 |
+
|
90 |
+
1. Text Passage Context, and
|
91 |
+
2. Specific question or instruction based on the text passage
|
92 |
+
|
93 |
+
To get the best results, package "my_prompt" as follows:
|
94 |
+
|
95 |
+
my_prompt = {{text_passage}} + "\n" + {{question/instruction}}
|
96 |
+
|
97 |
+
|
98 |
+
If you are using a HuggingFace generation script:
|
99 |
+
|
100 |
+
# prepare prompt packaging used in fine-tuning process
|
101 |
+
new_prompt = "<human>: " + entries["context"] + "\n" + entries["query"] + "\n" + "<bot>:"
|
102 |
+
|
103 |
+
inputs = tokenizer(new_prompt, return_tensors="pt")
|
104 |
+
start_of_output = len(inputs.input_ids[0])
|
105 |
+
|
106 |
+
# temperature: set at 0.3 for consistency of output
|
107 |
+
# max_new_tokens: set at 100 - may prematurely stop a few of the summaries
|
108 |
+
|
109 |
+
outputs = model.generate(
|
110 |
+
inputs.input_ids.to(device),
|
111 |
+
eos_token_id=tokenizer.eos_token_id,
|
112 |
+
pad_token_id=tokenizer.eos_token_id,
|
113 |
+
do_sample=True,
|
114 |
+
temperature=0.3,
|
115 |
+
max_new_tokens=100,
|
116 |
+
)
|
117 |
+
|
118 |
+
output_only = tokenizer.decode(outputs[0][start_of_output:],skip_special_tokens=True)
|
119 |
+
|
120 |
+
|
121 |
+
## Model Card Contact
|
122 |
+
|
123 |
+
Darren Oberst & llmware team
|