Tobias Kerner commited on
Commit
0301308
·
1 Parent(s): ce860b4
README.md CHANGED
@@ -1,101 +1,45 @@
1
- ---
2
- license: llama3
3
- datasets:
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
- ## Model Details
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
- Title: Financial Compliance and Company Statements
 
36
 
37
- Text: This document provides a detailed overview of the financial compliance measures and statements issued by corporations. It discusses various aspects of financial reporting, the importance of accurate financial disclosures, and the role of chief executive officers in certifying financial documents. The document elaborates on the legal frameworks that govern corporate financial disclosures, including the Securities Exchange Act of 1934, which mandates that public companies must provide periodic reports detailing their financial status. These reports are crucial for investors, regulators, and other stakeholders who rely on them to make informed decisions. The document also highlights the penalties for non-compliance with financial reporting requirements, which can include fines and criminal charges for executives who misreport financial information.
38
 
39
- Document:1
 
 
 
 
40
 
41
- Title: Certification of Financial Reports by CEO of Black Knight, Inc.
42
-
43
- Text: Pursuant to 18 U.S.C. §1350, the Chief Executive Officer of Black Knight, Inc., a corporation registered in Delaware, has officially certified the periodic financial report containing the company's financial statements. The certification confirms that these reports comply fully with the requirements of Section 13(a) or 15(d) of the Securities Exchange Act of 1934. The CEO, Anthony M. Jabbour, asserts that the information contained within these reports fairly presents, in all material respects, the financial condition and results of operations of Black Knight, Inc. The certification is part of the official documents filed with the Securities and Exchange Commission and serves as a testament to the accuracy and fairness of the financial disclosures made by the company. This certification is crucial as it assures stakeholders of the reliability of the financial statements provided by Black Knight, Inc.
44
-
45
- Answer Mode: Grounded
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
- prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
 
 
 
 
56
 
57
- # Set up pipeline and generate response
58
- pipe = pipeline('text-generation', model=model_name, tokenizer=model_name, device=0)
59
- output = pipe(
60
- prompt,
61
- max_length=1000,
62
- num_return_sequences=1,
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(output[0]['generated_text'])
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