Files changed (2) hide show
  1. README.md +0 -198
  2. config.json +1 -1
README.md CHANGED
@@ -1,201 +1,3 @@
1
  ---
2
  license: apache-2.0
3
- pipeline_tag: text-generation
4
  ---
5
-
6
- <p align="center" style="font-size:34px;"><b>Buddhi-128K-Chat</b></p>
7
-
8
- # Buddhi-128K-Chat (7B) vLLM Inference: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/11_8W8FpKK-856QdRVJLyzbu9g-DMxNfg?usp=sharing)
9
-
10
- # Read release article: [🔗 Introducing Buddhi: Open-Source Chat Model with a 128K Context Window 🔗 ](https://medium.aiplanet.com/introducing-buddhi-open-source-chat-model-with-a-128k-context-window-06a1848121d0)
11
-
12
- ![4.png](https://cdn-uploads.huggingface.co/production/uploads/630f3058236215d0b7078806/VUY0c4xOGpH9jTNmf6XNU.png)
13
-
14
- ## Model Description
15
-
16
- Buddhi-128k-Chat is a general-purpose first chat model with 128K context length window. It is meticulously fine-tuned on the Mistral 7B Instruct, and optimised to handle an extended context length of up to 128,000 tokens using the innovative YaRN (Yet another Rope Extension) Technique. This enhancement allows Buddhi to maintain a deeper understanding of context in long documents or conversations, making it particularly adept at tasks requiring extensive context retention, such as comprehensive document summarization, detailed narrative generation, and intricate question-answering.
17
-
18
- ## Architecture
19
- The Buddhi-128K-Chat model is fine-tuned on the Mistral-7B Instruct base model. We selected the Mistral 7B Instruct v0.2 as the parent model due to its superior reasoning capabilities. The architecture of the Mistral-7B model includes features like Grouped-Query Attention and Byte-fallback BPE tokenizer. Originally, this model has 32,768 maximum position embeddings. To increase the context size to 128K, we needed to modify the positional embeddings, which is where YaRN comes into play.
20
-
21
- In our approach, we utilized the NTK-aware technique, which recommends alternative interpolation techniques for positional interpolation. One experimentation involved Dynamic-YARN, suggesting the dynamic value of the 's' scale factor. This is because during inference, the sequence length changes by 1 after every word prediction. By integrating these position embeddings with the Mistral-7B Instruct base model, we achieved the 128K model.
22
-
23
- Additionally, we fine-tuned the model on our dataset to contribute one of the very few 128K chat-based models available in the open-source community with greater reasoning capabilities than all of it.
24
-
25
- ### Hardware requirements:
26
- > For 128k Context Length
27
- > - 80GB VRAM - A100 Preferred
28
-
29
- > For 32k Context Length
30
- > - 40GB VRAM - A100 Preferred
31
-
32
- ### vLLM - For Faster Inference
33
-
34
- #### Installation
35
-
36
- ```
37
- !pip install vllm
38
- !pip install flash_attn # If Flash Attention 2 is supported by your System
39
- ```
40
- Please check out [Flash Attention 2](https://github.com/Dao-AILab/flash-attention) Github Repository for more instructions on how to Install it.
41
-
42
- **Implementation**:
43
-
44
- > Note: The actual hardware requirements to run the model is roughly around 70GB VRAM. For experimentation, we are limiting the context length to 75K instead of 128K. This make it suitable for testing the model in 30-35 GB VRAM
45
-
46
- ```python
47
- from vllm import LLM, SamplingParams
48
-
49
- llm = LLM(
50
- model='aiplanet/buddhi-128k-chat-7b',
51
- trust_remote_code=True,
52
- dtype = 'bfloat16',
53
- gpu_memory_utilization=1,
54
- max_model_len= 75000
55
- )
56
-
57
- prompts = [
58
- """<s> [INST] Please tell me a joke. [/INST] """,
59
- """<s> [INST] What is Machine Learning? [/INST] """
60
- ]
61
-
62
- sampling_params = SamplingParams(
63
- temperature=0.8,
64
- top_p=0.95,
65
- max_tokens=1000
66
- )
67
-
68
- outputs = llm.generate(prompts, sampling_params)
69
-
70
- for output in outputs:
71
- prompt = output.prompt
72
- generated_text = output.outputs[0].text
73
- print(generated_text)
74
- print("\n\n")
75
-
76
- # we have also attached a colab notebook, that contains: 2 more experimentations: Long Essay and Entire Book
77
- ```
78
-
79
- For Output, do check out the colab notebook: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/11_8W8FpKK-856QdRVJLyzbu9g-DMxNfg?usp=sharing)
80
-
81
- ### Transformers - Basic Implementation
82
-
83
- ```python
84
- import torch
85
- import transformers
86
- from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
87
-
88
- bnb_config = BitsAndBytesConfig(
89
- load_in_4bit=True,
90
- bnb_4bit_use_double_quant=True,
91
- bnb_4bit_quant_type="nf4",
92
- bnb_4bit_compute_dtype=torch.bfloat16
93
- )
94
-
95
- model_name = "aiplanet/Buddhi-128K-Chat"
96
-
97
- model = AutoModelForCausalLM.from_pretrained(
98
- model_name,
99
- quantization_config=bnb_config,
100
- device_map="sequential",
101
- trust_remote_code=True
102
- )
103
-
104
- tokenizer = AutoTokenizer.from_pretrained(
105
- model,
106
- trust_remote_code=True
107
- )
108
-
109
- prompt = "<s> [INST] Please tell me a small joke. [/INST] "
110
-
111
- tokens = tokenizer(prompt, return_tensors="pt").to("cuda")
112
- outputs = model.generate(
113
- **tokens,
114
- max_new_tokens=100,
115
- do_sample=True,
116
- top_p=0.95,
117
- temperature=0.8,
118
- )
119
-
120
- decoded_output = tokenizer.batch_decode(outputs.detach().cpu().numpy(), skip_special_tokens=True)[0]
121
- print(f"Output:\n{decoded_output[len(prompt):]}")
122
- ```
123
-
124
- Output
125
-
126
- ```
127
- Output:
128
- Why don't scientists trust atoms?
129
-
130
- Because they make up everything.
131
- ```
132
-
133
-
134
- ## Prompt Template for Buddi-128-Chat
135
-
136
- In order to leverage instruction fine-tuning, your prompt should be surrounded by [INST] and [/INST] tokens. The very first instruction should begin with a begin of sentence id. The next instructions should not. The assistant generation will be ended by the end-of-sentence token id.
137
-
138
- ```
139
- "<s>[INST] What is your favourite condiment? [/INST]"
140
- "Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!</s> "
141
- "[INST] Do you have mayonnaise recipes? [/INST]"
142
-
143
- ```
144
-
145
- # Benchmarks
146
-
147
- ### Long Context Benchmark
148
-
149
- <strong>LongICLBench Banking77</strong>
150
- <div>
151
-
152
- | Model | 1R/2k | 2R/4K | 3R/7K | 4R/9K | 5R/14K |
153
- |-----------------------------------------|-------|-------|-------|-------|--------|
154
- | aiplanet/buddhi-128k-chat-7b | 47.8 | 60.8 | 57.8 | 62.4 | 57.2 |
155
- | NousResearch/Yarn-Mistral-7b-128k | 31.6 | 68.6 | 68 | 47 | 65.6 |
156
- | CallComply/zephyr-7b-beta-128k | 40.2 | 41.2 | 33.6 | 03 | 0 |
157
- | Eric111/Yarn-Mistral-7b-128k-DPO | 28.6 | 62.8 | 58 | 41.6 | 59.8 |
158
-
159
- </div>
160
-
161
- <strong>Short Context Benchmark</strong>
162
- <div>
163
-
164
- | Model | # Params | Average | ARC (25-shot) | HellaSwag (10-shot) | Winogrande (5-shot) | TruthfulOA (0-shot) | MMLU (5-shot) |
165
- |-----------------------------------|----------|---------|---------------|---------------------|---------------------|---------------------|---------------|
166
- | aiplanet/buddhi-128k-chat-7b | 7B | 64.42 | 60.84 | 84 | 77.27 | 65.72 | 60.42 |
167
- | migtissera/Tess-XS-vl-3-yarn-128K | 7B | 62.66 | 61.09 | 82.95 | 74.43 | 50.13 | 62.15 |
168
- | migtissera/Tess-XS-v1-3-yarn-128K | 7B | 62.49 | 61.6 | 82.96 | 74.74 | 50.2 | 62.1 |
169
- | Eric111/Yarn-Mistral-7b-128k-DPO | 7B | 60.15 | 60.84 | 82.99 | 78.3 | 43.55 | 63.09 |
170
- | NousResearch/Yam-Mistral-7b-128k | 7B | 59.42 | 59.64 | 82.5 | 76.95 | 41.78 | 63.02 |
171
- | CallComply/openchat-3.5-0106-128k | 7B | 59.38 | 64.25 | 77.31 | 77.66 | 46.5 | 57.58 |
172
- | CallComply/zephyr-7b-beta-128k | 7B | 54.45 | 58.28 | 81 | 74.74 | 46.1 | 53.57 |
173
-
174
- </div>
175
-
176
- ## Get in Touch
177
-
178
- You can schedule a 1:1 meeting with our DevRel & Community Team to get started with AI Planet Open Source LLMs and GenAI Stack. Schedule the call here: [https://calendly.com/jaintarun](https://calendly.com/jaintarun)
179
-
180
- Stay tuned for more updates and be a part of the coding evolution. Join us on this exciting journey as we make AI accessible to all at AI Planet!
181
-
182
-
183
- ### Framework versions
184
-
185
- - Transformers 4.39.2
186
- - Pytorch 2.2.1+cu121
187
- - Datasets 2.18.0
188
- - Accelerate 0.27.2
189
- - flash_attn 2.5.6
190
-
191
- ### Citation
192
-
193
- ```
194
- @misc {Chaitanya890, lucifertrj ,
195
- author = { Chaitanya Singhal, Tarun Jain },
196
- title = { Buddhi-128k-Chat by AI Planet},
197
- year = 2024,
198
- url = { https://huggingface.co/aiplanet//Buddhi-128K-Chat },
199
- publisher = { Hugging Face }
200
- }
201
- ```
 
1
  ---
2
  license: apache-2.0
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
config.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "_name_or_path": "aiplanet/buddhi-128k-chat-7b",
3
  "architectures": [
4
  "MistralForCausalLM"
5
  ],
 
1
  {
2
+ "_name_or_path": "aiplanet/Buddhi-128K-Chat",
3
  "architectures": [
4
  "MistralForCausalLM"
5
  ],