Tobias Kerner
commited on
Commit
·
0301308
1
Parent(s):
ce860b4
init
Browse files- README.md +29 -85
- output.safetensors → model.safetensors +0 -0
README.md
CHANGED
|
@@ -1,101 +1,45 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
- glaiveai/RAG-v1
|
| 5 |
-
language:
|
| 6 |
-
- en
|
| 7 |
-
tags:
|
| 8 |
-
- RAG
|
| 9 |
-
---
|
| 10 |
-
# Llama-3-8B-RAG-v1
|
| 11 |
|
| 12 |
-
This model is a fine-tuned version of Llama-3-8B for Retrieval-Augmented Generation (RAG) tasks on the Glaive-RAG-v1 dataset.
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
* **Developed by:** [Glaive](https://glaive.ai)
|
| 17 |
-
* **Model type:** Llama-3 finetuned for RAG tasks
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
## How to Get Started with the Model
|
| 21 |
-
|
| 22 |
-
Use the code below to get started with the model:
|
| 23 |
-
|
| 24 |
-
NOTE: Try to use the same system prompt and document formatting as the example provided below, this is the same format that was used to finetune the model.
|
| 25 |
|
| 26 |
```python
|
| 27 |
-
from transformers import AutoTokenizer, pipeline
|
| 28 |
-
|
| 29 |
-
model_name = "glaiveai/Llama-3-8B-RAG-v1"
|
| 30 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 31 |
-
|
| 32 |
-
# Example user query
|
| 33 |
-
user_query = """Document:0
|
| 34 |
|
| 35 |
-
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
|
| 47 |
-
Question: How does the CEO of Black Knight, Inc. ensure compliance with the Securities Exchange Act of 1934, and what are the implications of the certification provided?"""
|
| 48 |
|
| 49 |
-
# Prepare chat template
|
| 50 |
-
chat = [
|
| 51 |
-
{"role": "system", "content": "You are a conversational AI assistant that is provided a list of documents and a user query to answer based on information from the documents. The user also provides an answer mode which can be 'Grounded' or 'Mixed'. For answer mode Grounded only respond with exact facts from documents, for answer mode Mixed answer using facts from documents and your own knowledge. Cite all facts from the documents using <co: doc_id></co> tags."},
|
| 52 |
-
{"role": "user", "content": user_query}
|
| 53 |
-
]
|
| 54 |
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
top_k=50,
|
| 64 |
-
top_p=0.95,
|
| 65 |
-
temperature=0.5,
|
| 66 |
-
do_sample=True,
|
| 67 |
-
return_full_text=False
|
| 68 |
)
|
| 69 |
|
| 70 |
-
print(
|
| 71 |
-
```
|
| 72 |
|
| 73 |
-
## Output of above code block
|
| 74 |
```
|
| 75 |
-
Cited Documents: 1
|
| 76 |
-
Answer: <co:1>The CEO of Black Knight, Inc., Anthony M. Jabbour, ensures compliance with the Securities Exchange Act of 1934 by certifying that the periodic financial report and financial statements comply fully with the requirements of Section 13(a) or 15(d) of the Act. This certification confirms that the information in the reports fairly presents, in all material respects, the financial condition and results of operations of Black Knight, Inc.</co> This certification is crucial as it assures stakeholders of the reliability of the financial statements provided by the company, thereby maintaining investor confidence and adherence to legal financial reporting standards.
|
| 77 |
-
In this output:
|
| 78 |
-
|
| 79 |
-
The model cites Document 1 as the source of its information.
|
| 80 |
-
It provides a grounded answer based on the content of Document 1, as requested in the "Answer Mode: Grounded" instruction.
|
| 81 |
-
The answer explains how the CEO ensures compliance and the implications of the certification.
|
| 82 |
-
The citation is marked with <co:1></co> tags, indicating that this information comes directly from Document 1.
|
| 83 |
-
```
|
| 84 |
-
|
| 85 |
-
## Answer mode and citations
|
| 86 |
-
|
| 87 |
-
The model can be instructed to answer only using grounded information from the documents, or to combine it's internal knowledge as well by using Answer Mode: Grounded/Mixed in the user prompt.
|
| 88 |
-
|
| 89 |
-
Citations are generated at the beginning of each answer, and also present within the text in <co: doc_id> </co> blocks.
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
## Future work
|
| 93 |
-
|
| 94 |
-
We are working on the following improvements for the next version of the dataset:
|
| 95 |
-
|
| 96 |
-
- Multi turn data
|
| 97 |
-
- Diverse document sources
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
|
|
|
| 1 |
+
exllamav2-quantized version of Llama-3-8B-RAG-v1 from glaiveai: https://huggingface.co/glaiveai/Llama-3-8B-RAG-v1
|
| 2 |
+
bpw: 6.0
|
| 3 |
+
head-bpw: 8.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
|
|
|
| 5 |
|
| 6 |
+
example usage with exllamav2:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
```python
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
from exllamav2 import ExLlamaV2, ExLlamaV2Config, ExLlamaV2Cache, ExLlamaV2Tokenizer
|
| 11 |
+
from exllamav2.generator import ExLlamaV2Sampler, ExLlamaV2DynamicGenerator
|
| 12 |
|
| 13 |
+
model_path = /path/to/model_folder
|
| 14 |
|
| 15 |
+
config = ExLlamaV2Config(model_path)
|
| 16 |
+
model = ExLlamaV2(config)
|
| 17 |
+
cache = ExLlamaV2Cache(model, max_seq_len = 4096, lazy = True)
|
| 18 |
+
model.load_autosplit(cache, progress = True)
|
| 19 |
+
tokenizer = ExLlamaV2Tokenizer(config)
|
| 20 |
|
| 21 |
+
generator = ExLlamaV2DynamicGenerator(
|
| 22 |
+
model = model,
|
| 23 |
+
cache = cache,
|
| 24 |
+
tokenizer = tokenizer,
|
| 25 |
+
)
|
| 26 |
|
|
|
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
gen_settings = ExLlamaV2Sampler.Settings(
|
| 30 |
+
temperature = 1.0,
|
| 31 |
+
top_p = 0.1,
|
| 32 |
+
token_repetition_penalty = 1.0
|
| 33 |
+
)
|
| 34 |
|
| 35 |
+
outputs = generator.generate(
|
| 36 |
+
prompt = ["first input", "second input"], # string or list of strings
|
| 37 |
+
max_new_tokens = 1024,
|
| 38 |
+
stop_conditions = [tokenizer.eos_token_id],
|
| 39 |
+
gen_settings = gen_settings,
|
| 40 |
+
add_bos = True,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
)
|
| 42 |
|
| 43 |
+
print(outputs)
|
|
|
|
| 44 |
|
|
|
|
| 45 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output.safetensors → model.safetensors
RENAMED
|
File without changes
|