Instructions to use Rishi1708/codegemma-7b-bnb-merged-16bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Rishi1708/codegemma-7b-bnb-merged-16bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Rishi1708/codegemma-7b-bnb-merged-16bit") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Rishi1708/codegemma-7b-bnb-merged-16bit") model = AutoModelForCausalLM.from_pretrained("Rishi1708/codegemma-7b-bnb-merged-16bit") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Rishi1708/codegemma-7b-bnb-merged-16bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Rishi1708/codegemma-7b-bnb-merged-16bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Rishi1708/codegemma-7b-bnb-merged-16bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Rishi1708/codegemma-7b-bnb-merged-16bit
- SGLang
How to use Rishi1708/codegemma-7b-bnb-merged-16bit with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Rishi1708/codegemma-7b-bnb-merged-16bit" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Rishi1708/codegemma-7b-bnb-merged-16bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Rishi1708/codegemma-7b-bnb-merged-16bit" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Rishi1708/codegemma-7b-bnb-merged-16bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Rishi1708/codegemma-7b-bnb-merged-16bit with Docker Model Runner:
docker model run hf.co/Rishi1708/codegemma-7b-bnb-merged-16bit
CodeGemma-7B-Conversational-v1.0
This model is a fine-tuned version of the CodeGemma-7B model, specifically adapted for conversational tasks. It has been trained to generate responses in a multi-turn conversation format, making it suitable for chatbot applications and interactive dialogue systems.
Base Model
The model is based on the CodeGemma-7B model, a language model designed for code generation and understanding. It is loaded with 4-bit quantization to optimize memory usage.
Fine-Tuning
The model was fine-tuned using Low-Rank Adaptation (LoRA) for parameter-efficient training. LoRA enables training of only a small subset of the model's parameters, enhancing efficiency during the fine-tuning process.
LoRA Configuration
- Rank (
r): 16 - Alpha (
lora_alpha): 16 - Dropout (
lora_dropout): 0 - Bias: None
- Random State: 3407
Fine-Tuned Modules
- Query projection (
q_proj) - Key projection (
k_proj) - Value projection (
v_proj) - Output projection (
o_proj) - Gate projection (
gate_proj) - Up projection (
up_proj) - Down projection (
down_proj)
Dataset
The fine-tuning was performed on the Guanaco ShareGPT-style dataset, which consists of multi-turn conversations in the ShareGPT format. This dataset was chosen to train the model on diverse conversational interactions.
The dataset was preprocessed using the ChatML format to structure the conversations appropriately for training.
Training Process
The model was fine-tuned using the Hugging Face Transformers library, leveraging the efficiency of LoRA to adapt the pre-trained model to conversational tasks. The training process optimized the model to generate coherent and contextually relevant responses in a dialogue setting.
Training Configuration
- Batch Size: 1 (with gradient accumulation steps = 4)
- Learning Rate: 2e-4
- Optimizer: AdamW (8-bit)
- Weight Decay: 0.01
- Learning Rate Scheduler: Linear
- Maximum Steps: 20 (for demonstration; adjust for full training)
Usage
To use this model for generating conversational responses, you can load it using the Hugging Face Transformers library. Below is an example of how to load the model and generate a response in a conversation:
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load the model and tokenizer
model_name = "Rishi1708/CodeGemma-7B-Conversational-v1.0"
model = AutoModelForCausalLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
# Prepare the conversation history
messages = [
{"from": "human", "value": "Continue the fibonnaci sequence: 1, 1, 2, 3, 5, 8,"},
]
# Apply chat template
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt"
).to("cuda")
# Generate response
outputs = model.generate(input_ids=inputs, max_new_tokens=128)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
Note: The exact method to prepare inputs and generate outputs may depend on the specific model architecture. Please refer to the base model's documentation for detailed usage instructions.
Dependencies:
transformerstorch
Install these using:
pip install transformers torch
Evaluation
To evaluate the model's performance, you can use standard metrics for conversational models, such as perplexity, BLEU, or human evaluation for coherence and relevance. It is recommended to evaluate the model on a held-out test set from the same dataset or a similar conversational dataset.
Limitations
- The model is fine-tuned on a specific conversational dataset and may not generalize well to other types of conversations or domains not represented in the training data.
- The dataset may contain biases inherent to the collection process, which could affect the model's responses.
- The model should be used as a tool for generating conversational responses and not as a replacement for human interaction in critical applications.
- Downloads last month
- 2
Model tree for Rishi1708/codegemma-7b-bnb-merged-16bit
Base model
google/codegemma-7b