Cognitivess Model
Usage
To use this model, first install the custom package:
# Install required packages
!pip install bitsandbytes accelerate
!pip install git+https://huggingface.co/CognitivessAI/cognitivess
Then, you can use the model like this:
# Import necessary libraries
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
import torch
# Import and register your custom classes
from cognitivess_model import CognitivessConfig, CognitivessForCausalLM
from transformers import AutoConfig, AutoModelForCausalLM
AutoConfig.register("cognitivess", CognitivessConfig)
AutoModelForCausalLM.register(CognitivessConfig, CognitivessForCausalLM)
# Set up quantization config
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained("CognitivessAI/cognitivess")
# Load model configuration
config = CognitivessConfig.from_pretrained("CognitivessAI/cognitivess")
# Set the quantization config in the model configuration
config.quantization_config = quantization_config
# Load model with the updated configuration
model = CognitivessForCausalLM.from_pretrained(
"CognitivessAI/cognitivess",
config=config,
quantization_config=quantization_config,
device_map="auto"
)
# Prepare input
input_text = "Write me a poem about Machine Learning."
inputs = tokenizer(input_text, return_tensors="pt").to("cuda" if torch.cuda.is_available() else "cpu")
# Generate output
with torch.no_grad():
outputs = model.generate(**inputs, max_length=100)
# Decode and print the result
print(tokenizer.decode(outputs[0], skip_special_tokens=True))