cognitivess commited on
Commit
53d674b
1 Parent(s): b85da04

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +244 -3
README.md CHANGED
@@ -1,3 +1,244 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - text-generation-inference
4
+ - text-generation
5
+ - Sentiment Analysis
6
+ - qlora
7
+ - peft
8
+ license: apache-2.0
9
+ library_name: transformers
10
+ widget:
11
+ - messages:
12
+ - role: user
13
+ content: What is your name?
14
+ language:
15
+ - en
16
+ - ro
17
+ pipeline_tag: text-generation
18
+ model-index:
19
+ - name: CognitivessAI/cognitivess
20
+ results:
21
+ - task:
22
+ type: text-generation
23
+ name: Text Generation
24
+ metrics:
25
+ - name: Perplexity
26
+ type: perplexity
27
+ value: 7.5 # Replace with your actual perplexity value
28
+ - name: ROUGE-L
29
+ type: rouge-l
30
+ value: 0.85 # Replace with your actual ROUGE-L score
31
+ base_model: CognitivessAI/bella-2-8b
32
+ model_type: CognitivessForCausalLM
33
+ quantization_config:
34
+ load_in_8bit: true
35
+ llm_int8_threshold: 6.0
36
+ fine_tuning:
37
+ method: qlora
38
+ peft_type: LORA
39
+ inference:
40
+ parameters:
41
+ max_new_tokens: 8192
42
+ temperature: 0.7
43
+ top_p: 0.95
44
+ do_sample: true
45
+ ---
46
+
47
+ <div align="center">
48
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/65ec00afa735404e87e1359e/u5qyAgn_2-Bh46nzOFlcI.png">
49
+ <h2>Accessible and portable generative AI solutions for developers and businesses.</h2>
50
+ </div>
51
+
52
+ <p align="center" style="margin-top: 0px;">
53
+ <a href="https://cognitivess.com">
54
+ <span class="link-text" style=" margin-right: 5px;">Website</span>
55
+ </a> |
56
+ <a href="https://bella.cognitivess.com">
57
+ <span class="link-text" style=" margin-right: 5px;">Demo</span>
58
+ </a> |
59
+ <a href="https://github.com/Cognitivess/cognitivess">
60
+ <img src="https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png" alt="GitHub Logo" style="width:20px; vertical-align: middle; display: inline-block; margin-right: 5px; margin-left: 5px; margin-top: 0px; margin-bottom: 0px;"/>
61
+ <span class="link-text" style=" margin-right: 5px;">GitHub</span>
62
+ </a>
63
+ </p>
64
+
65
+ # Cognitivess
66
+
67
+ Cognitivess is an advanced language model developed by Cognitivess AI, based in Bucharest, Romania. This model, fine-tuned from the Bella-2-8b base, utilizes Quantized Low-Rank Adaptation (QLoRA) techniques to deliver high-quality text generation while maintaining efficiency.
68
+
69
+ Key features:
70
+ - Built on the LLaMA architecture
71
+ - Fine-tuned using QLoRA for optimal performance and resource utilization
72
+ - Capable of generating text in both English and Romanian
73
+ - Specialized in tasks such as text generation, sentiment analysis, and general question-answering
74
+ - Designed to provide clear, concise, and informative responses in a conversational manner
75
+
76
+ Cognitivess aims to serve as a versatile AI assistant, capable of handling a wide range of queries and tasks while maintaining a friendly and professional demeanor. Whether you need help with analysis, creative writing, or just engaging in informative dialogue, Cognitivess is equipped to assist.
77
+
78
+ This model represents Cognitivess AI's commitment to advancing natural language processing technology and making it accessible for various applications.
79
+
80
+
81
+ ***Under the Cognitivess Open Model License, Cognitivess AI confirms:***
82
+ - Models are commercially usable.
83
+ - You are free to create and distribute Derivative Models.
84
+ - Cognitivess does not claim ownership to any outputs generated using the Models or Derivative Models.
85
+
86
+ ### Intended use
87
+
88
+ Cognitivess is a multilingual chat model designed to support a variety of languages including English, Romanian, Spanish, French, German, and many more, intended for diverse language applications.
89
+
90
+
91
+ **Model Developer:** Cognitivess AI
92
+
93
+ **Model Dates:** Cognitivess was trained between July 2024.
94
+
95
+ **Data Freshness:** The pretraining data has a cutoff of June 2024. Training will continue beyond the current data cutoff date to incorporate new data as it becomes available.
96
+
97
+
98
+ ### Model Architecture:
99
+
100
+ Cognitivess model architecture is Transformer-based and trained with a sequence length of 8192 tokens.
101
+
102
+ **Architecture Type:** Transformer (auto-regressive language model)
103
+
104
+
105
+
106
+ Try this model on [bella.cognitivess.com](https://bella.cognitivess.com/) now.
107
+
108
+
109
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/65ec00afa735404e87e1359e/CQeAV4lwbQp1G8H5n4uWx.png)
110
+
111
+
112
+ # Usage
113
+
114
+ ```python
115
+
116
+ import torch
117
+ from transformers import AutoTokenizer, AutoModelForCausalLM
118
+ from peft import PeftModel, PeftConfig
119
+
120
+ # Set the device
121
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
122
+ print(f"Using device: {device}")
123
+
124
+ # Load the tokenizer
125
+ tokenizer = AutoTokenizer.from_pretrained("CognitivessAI/cognitivess")
126
+
127
+ # Load the PEFT configuration
128
+ peft_config = PeftConfig.from_pretrained("CognitivessAI/cognitivess")
129
+
130
+ # Load the base model
131
+ base_model = AutoModelForCausalLM.from_pretrained(
132
+ peft_config.base_model_name_or_path,
133
+ device_map="auto",
134
+ torch_dtype=torch.float16
135
+ )
136
+
137
+ # Load the PEFT model
138
+ model = PeftModel.from_pretrained(base_model, "CognitivessAI/cognitivess")
139
+
140
+ # Move the model to the appropriate device
141
+ model = model.to(device)
142
+
143
+ # Set the model to evaluation mode
144
+ model.eval()
145
+
146
+ # Function for text generation using the chat template
147
+ def generate_text(model, tokenizer, input_text, max_length=8192, temperature=0.7, top_p=0.95):
148
+ messages = [
149
+ {"role": "user", "content": input_text}
150
+ ]
151
+ chat_input = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
152
+ inputs = tokenizer(chat_input, return_tensors='pt', padding=True, truncation=True, max_length=8192)
153
+ input_ids = inputs['input_ids'].to(device)
154
+ attention_mask = inputs['attention_mask'].to(device)
155
+ try:
156
+ generated_text_ids = model.generate(
157
+ input_ids,
158
+ attention_mask=attention_mask,
159
+ max_length=max_length,
160
+ temperature=temperature,
161
+ top_p=top_p,
162
+ do_sample=True,
163
+ eos_token_id=tokenizer.eos_token_id
164
+ )
165
+ generated_text = tokenizer.decode(generated_text_ids[0], skip_special_tokens=True)
166
+ # Extract the assistant's response
167
+ response = generated_text.split("GPT4 Correct Assistant")[-1].strip()
168
+ return response
169
+ except Exception as e:
170
+ print(f"Error in text generation: {e}")
171
+ return "I'm sorry, I encountered an error while generating a response."
172
+
173
+ # Test the model
174
+ test_prompt = "Who are you?"
175
+ generated_response = generate_text(model, tokenizer, test_prompt, max_length=100)
176
+ print(f"Generated response:\n{generated_response}")
177
+
178
+ print("Testing completed.")import torch
179
+ from transformers import AutoTokenizer, AutoModelForCausalLM
180
+ from peft import PeftModel, PeftConfig
181
+
182
+ # Set the device
183
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
184
+ print(f"Using device: {device}")
185
+
186
+ # Load the tokenizer
187
+ tokenizer = AutoTokenizer.from_pretrained("CognitivessAI/cognitivess")
188
+
189
+ # Load the PEFT configuration
190
+ peft_config = PeftConfig.from_pretrained("CognitivessAI/cognitivess")
191
+
192
+ # Load the base model
193
+ base_model = AutoModelForCausalLM.from_pretrained(
194
+ peft_config.base_model_name_or_path,
195
+ device_map="auto",
196
+ torch_dtype=torch.float16
197
+ )
198
+
199
+ # Load the PEFT model
200
+ model = PeftModel.from_pretrained(base_model, "CognitivessAI/cognitivess")
201
+
202
+ # Move the model to the appropriate device
203
+ model = model.to(device)
204
+
205
+ # Set the model to evaluation mode
206
+ model.eval()
207
+
208
+ # Function for text generation using the chat template
209
+ def generate_text(model, tokenizer, input_text, max_length=8192, temperature=0.7, top_p=0.95):
210
+ messages = [
211
+ {"role": "user", "content": input_text}
212
+ ]
213
+ chat_input = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
214
+ inputs = tokenizer(chat_input, return_tensors='pt', padding=True, truncation=True, max_length=8192)
215
+ input_ids = inputs['input_ids'].to(device)
216
+ attention_mask = inputs['attention_mask'].to(device)
217
+ try:
218
+ generated_text_ids = model.generate(
219
+ input_ids,
220
+ attention_mask=attention_mask,
221
+ max_length=max_length,
222
+ temperature=temperature,
223
+ top_p=top_p,
224
+ do_sample=True,
225
+ eos_token_id=tokenizer.eos_token_id
226
+ )
227
+ generated_text = tokenizer.decode(generated_text_ids[0], skip_special_tokens=True)
228
+ # Extract the assistant's response
229
+ response = generated_text.split("GPT4 Correct Assistant")[-1].strip()
230
+ return response
231
+ except Exception as e:
232
+ print(f"Error in text generation: {e}")
233
+ return "I'm sorry, I encountered an error while generating a response."
234
+
235
+ # Test the model
236
+ test_prompt = "Who are you?"
237
+ generated_response = generate_text(model, tokenizer, test_prompt, max_length=100)
238
+ print(f"Generated response:\n{generated_response}")
239
+
240
+
241
+ ```
242
+
243
+ **Contact:**
244
+ <a href="mailto:hello@cognitivess.com">hello@cognitivess.com</a>