aashish1904
commited on
Commit
•
84a78b4
1
Parent(s):
9a9561d
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
---
|
3 |
+
|
4 |
+
license: llama3.1
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
tags:
|
8 |
+
- llama3.1
|
9 |
+
- rag
|
10 |
+
- brag
|
11 |
+
- chatrag
|
12 |
+
- chatqa
|
13 |
+
|
14 |
+
---
|
15 |
+
|
16 |
+
![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeiuCm7c8lEwEJuRey9kiVZsRn2W-b4pWlu3-X534V3YmVuVc2ZL-NXg2RkzSOOS2JXGHutDuyyNAUtdJI65jGTo8jT9Y99tMi4H4MqL44Uc5QKG77B0d6-JfIkZHFaUA71-RtjyYZWVIhqsNZcx8-OMaA?key=xt3VSDoCbmTY7o-cwwOFwQ)
|
17 |
+
|
18 |
+
# QuantFactory/BRAG-Llama-3.1-8b-v0.1-GGUF
|
19 |
+
This is quantized version of [maximalists/BRAG-Llama-3.1-8b-v0.1](https://huggingface.co/maximalists/BRAG-Llama-3.1-8b-v0.1) created using llama.cpp
|
20 |
+
|
21 |
+
# Original Model Card
|
22 |
+
|
23 |
+
# BRAG-Llama-3.1-8b-v0.1 Model Card
|
24 |
+
|
25 |
+
## Model Description
|
26 |
+
|
27 |
+
BRAG-Llama-3.1-8b-v0.1 is part of the [BRAG series of SLMs (Small Language Models)](https://huggingface.co/collections/maximalists/brag-v01-66aefc10e3a6c29c496c7476), specifically trained for RAG (Retrieval-Augmented Generation) tasks, including:
|
28 |
+
|
29 |
+
1. RAG with tables and text.
|
30 |
+
2. RAG with conversational chat.
|
31 |
+
|
32 |
+
**Authors**: [Pratik Bhavasar](https://www.linkedin.com/in/bhavsarpratik/), [Ravi Theja](https://www.linkedin.com/in/ravidesetty/)
|
33 |
+
|
34 |
+
## Key Features
|
35 |
+
|
36 |
+
- **Capabilities**: RAG tasks with both tables and text, as well as conversational chat.
|
37 |
+
- **Model Size**: 8 billion parameters
|
38 |
+
- **Context Length**: Supports up to 128k tokens
|
39 |
+
- **Language**: Trained and evaluated for English, but the base model has multi-lingual capabilities.
|
40 |
+
|
41 |
+
## Other Resources
|
42 |
+
|
43 |
+
[BRAG-v0.1 Model Collection](https://huggingface.co/collections/maximalists/brag-v01-66aefc10e3a6c29c496c7476) | [Blog](https://themaximalists.substack.com/p/brag)
|
44 |
+
|
45 |
+
## Performance
|
46 |
+
|
47 |
+
| Model Type | Model Name | Model Size | Context Length | ChatRAG-Bench (all) |
|
48 |
+
|------------|---------------------------|------------|----------------|---------------------|
|
49 |
+
| LLM | Command-R-Plus | -- | 128k | 50.93 |
|
50 |
+
| LLM | GPT-4-Turbo-2024-04-09 | -- | 128k | 54.03 |
|
51 |
+
| SLM | ChatQA-1.5-8B | 8b | 8k | 55.17 |
|
52 |
+
| BRAG SLM | BRAG-Qwen2-7b-v0.1 | 7b | 128k | 53.23 |
|
53 |
+
| BRAG SLM | BRAG-Llama-3.1-8b-v0.1 | 8b | 128k | 52.29 |
|
54 |
+
| BRAG SLM | BRAG-Llama-3-8b-v0.1 | 8b | 8k | 51.70 |
|
55 |
+
| BRAG Ultra SLM | BRAG-Qwen2-1.5b-v0.1 | 1.5b | 32k | 46.43 |
|
56 |
+
|
57 |
+
## Usage
|
58 |
+
|
59 |
+
#### Prompt Format
|
60 |
+
|
61 |
+
Below is the message prompt format required for using the model.
|
62 |
+
|
63 |
+
```
|
64 |
+
messages = [
|
65 |
+
{"role": "system", "content": "You are an assistant who gives helpful, detailed, and polite answers to the user's questions based on the context with appropriate reasoning as required. Indicate when the answer cannot be found in the context."},
|
66 |
+
{"role": "user", "content": """Context: <CONTEXT INFORMATION> \n\n <USER QUERY>"""},
|
67 |
+
]
|
68 |
+
|
69 |
+
```
|
70 |
+
|
71 |
+
#### Running with the `pipeline` API
|
72 |
+
|
73 |
+
```python
|
74 |
+
import transformers
|
75 |
+
import torch
|
76 |
+
|
77 |
+
model_id = "maximalists/BRAG-Llama-3.1-8b-v0.1"
|
78 |
+
|
79 |
+
pipeline = transformers.pipeline(
|
80 |
+
"text-generation",
|
81 |
+
model=model_id,
|
82 |
+
model_kwargs={"torch_dtype": torch.bfloat16},
|
83 |
+
device_map="auto",
|
84 |
+
)
|
85 |
+
|
86 |
+
messages = [
|
87 |
+
{"role": "system", "content": "You are an assistant who gives helpful, detailed, and polite answers to the user's questions based on the context with appropriate reasoning as required. Indicate when the answer cannot be found in the context."},
|
88 |
+
{"role": "user", "content": """Context:\nArchitecturally, the school has a Catholic character. Atop the Main Building\'s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend "Venite Ad Me Omnes". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary.\n\nTo whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?"""},
|
89 |
+
]
|
90 |
+
|
91 |
+
outputs = pipeline(
|
92 |
+
messages,
|
93 |
+
max_new_tokens=256,
|
94 |
+
)
|
95 |
+
|
96 |
+
print(outputs[0]["generated_text"][-1])
|
97 |
+
```
|
98 |
+
|
99 |
+
#### Running the model on a single / multi GPU
|
100 |
+
|
101 |
+
```python
|
102 |
+
# pip install accelerate
|
103 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
104 |
+
import torch
|
105 |
+
|
106 |
+
model_id = "maximalists/BRAG-Llama-3.1-8b-v0.1"
|
107 |
+
|
108 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
109 |
+
model = AutoModelForCausalLM.from_pretrained(
|
110 |
+
model_id,
|
111 |
+
device_map="auto",
|
112 |
+
)
|
113 |
+
|
114 |
+
messages = [
|
115 |
+
{"role": "system", "content": "You are an assistant who gives helpful, detailed, and polite answers to the user's questions based on the context with appropriate reasoning as required. Indicate when the answer cannot be found in the context."},
|
116 |
+
{"role": "user", "content": """Context:\nArchitecturally, the school has a Catholic character. Atop the Main Building\'s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend "Venite Ad Me Omnes". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary.\n\nTo whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?"""},
|
117 |
+
]
|
118 |
+
|
119 |
+
text = tokenizer.apply_chat_template(
|
120 |
+
messages,
|
121 |
+
tokenize=False,
|
122 |
+
add_generation_prompt=True
|
123 |
+
)
|
124 |
+
model_inputs = tokenizer([text], return_tensors="pt").to("cuda")
|
125 |
+
|
126 |
+
generated_ids = model.generate(
|
127 |
+
model_inputs.input_ids,
|
128 |
+
max_new_tokens=256
|
129 |
+
)
|
130 |
+
generated_ids = [
|
131 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
132 |
+
]
|
133 |
+
|
134 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
135 |
+
|
136 |
+
print(response)
|
137 |
+
```
|
138 |
+
|
139 |
+
|
140 |
+
## Limitations
|
141 |
+
|
142 |
+
The model is specifically trained for short contexts and may not perform well with longer ones. It has been fine-tuned on an English dataset. To avoid underperformance and the potential for hallucinations, please use the system prompt mentioned above.
|
143 |
+
|
144 |
+
## Citation
|
145 |
+
|
146 |
+
To cite this model, please use the following:
|
147 |
+
|
148 |
+
```bibtex
|
149 |
+
@misc{BRAG-Llama-3.1-8b-v0.1,
|
150 |
+
title = {BRAG-Llama-3.1-8b-v0.1},
|
151 |
+
year = {2024},
|
152 |
+
publisher = {HuggingFace},
|
153 |
+
url = {https://huggingface.co/maximalists/BRAG-Llama-3.1-8b-v0.1},
|
154 |
+
author = {Pratik Bhavsar and Ravi Theja}
|
155 |
+
}
|
156 |
+
```
|
157 |
+
|
158 |
+
## Additional Information
|
159 |
+
|
160 |
+
For more details on the BRAG series and updates, please refer to the official [blog](https://themaximalists.substack.com/p/brag).
|